/* Variables CSS para colores del tema restaurante */
:root {
    /* Colores principales */
    --primary-color: #0056A4; /* Azul corporativo */
    --primary-dark: #003E78;
    --primary-light: #2A79C8;
    /* Colores secundarios */
    --secondary-color: #6c757d; /* Gris */
    --secondary-dark: #545b62;
    --secondary-light: #adb5bd;
    /* Colores de fondo */
    --bg-primary: #ffffff; /* Fondo claro */
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-input: #f8f9fa;
    /* Colores de texto */
    --text-primary: #0056A4;
    --text-secondary: #6c757d;
    --text-light: #ffffff;
    --text-muted: #adb5bd;
    /* Colores de estado */
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    /* Sombras */
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.2);
    /* Bordes */
    --border-radius: 12px;
    --border-radius-small: 8px;
    --border-color: #e0e0e0;
    /* Espaciado */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
}

/* Tema oscuro - paleta unificada (estilo login) */
[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1e2433;
    --bg-card: #1e2433;
    --bg-input: #283040;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #3b4557;
    --shadow-light: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.5);
    --login-form-bg: #1e2433;
}

/* Tema claro */
[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f8f9fa;
    --text-primary: #0056A4;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
}

/* Reset y configuración base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    background: var(--bg-primary);
    min-height: 100vh;
    height: 100vh;
    max-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    transition: background-color 0.3s ease;
}

/* Estilos específicos para el login */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    min-height: 100vh;
    overflow: auto;
    background: transparent;
}

/* Wrapper principal: dos paneles en escritorio, uno en móvil (card, no ocupa todo el alto) */
.login-wrapper {
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: row;
}

/* Panel izquierdo: formulario */
.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--login-form-bg, #ffffff);
    overflow-y: auto;
}

/* Tarjeta de login */
.login-card {
    width: 100%;
    max-width: 420px;
    animation: slideInUp 0.6s ease-out;
}

/* Header del formulario en escritorio */
.login-form-header {
    display: none;
}

/* Header móvil: logo + título */
.login-header-mobile {
    text-align: center;
    margin-bottom: var(--spacing-xxl);
}

.logo-container {
    margin-bottom: var(--spacing-lg);
}

.logo-icon {
    display: inline-block;
    margin-bottom: var(--spacing-md);
}

.logo-image {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    box-shadow: 0 4px 20px rgba(0, 86, 164, 0.15);
    transition: all 0.3s ease;
}

.logo-image:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(0, 86, 164, 0.25);
}

.app-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Footer del formulario */
.login-form-footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ==================== PANEL DE MARCA (DERECHO) ==================== */
.login-brand-panel {
    display: none;
}

.brand-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.25rem;
}

.brand-logo-img {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    background: #fff;
    transition: transform 0.3s ease;
}

.brand-logo-img:hover {
    transform: scale(1.05);
}

.brand-title {
    font-size: 3rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.brand-tagline {
    font-size: 1.1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
    letter-spacing: 3px;
}

.brand-separator {
    width: 60px;
    height: 3px;
    background: #E63946;
    border-radius: 2px;
    margin: 0.5rem 0;
}

.brand-description {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.6;
    max-width: 340px;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.brand-feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    font-weight: 500;
}

.brand-feature-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 1rem;
    flex-shrink: 0;
}

.brand-footer {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    margin-top: auto;
    padding-top: 2rem;
}

/* ==================== ESCRITORIO Y TABLET (>= 768px): DOS COLUMNAS ==================== */
@media (min-width: 768px) {
    body.login-page {
        padding: 2rem;
    }

    .login-wrapper {
        flex-direction: row;
        width: 92%;
        max-width: 1200px;
        max-height: 90vh;
        border-radius: 18px;
        overflow: hidden;
        box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    }

    .login-brand-panel {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 0 0 40%;
        max-width: 40%;
        background: linear-gradient(135deg, #0056A4 0%, #003E78 50%, #002B55 100%);
        padding: 3rem;
        position: relative;
        overflow: hidden;
    }

    .login-brand-panel::before {
        content: '';
        position: absolute;
        top: -50%;
        right: -30%;
        width: 80%;
        height: 200%;
        background: radial-gradient(ellipse, rgba(230, 57, 70, 0.15) 0%, transparent 70%);
        pointer-events: none;
    }

    .login-brand-panel::after {
        content: '';
        position: absolute;
        bottom: -20%;
        left: -20%;
        width: 60%;
        height: 60%;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.04) 0%, transparent 70%);
        pointer-events: none;
    }

    .login-form-panel {
        flex: 0 0 60%;
        max-width: 60%;
        padding: 3rem 4rem;
        background: var(--login-form-bg, #ffffff);
        position: relative;
    }

    .login-card {
        max-width: 480px;
    }

    .login-header-mobile {
        display: none;
    }

    .login-form-header {
        display: block;
        margin-bottom: 2.5rem;
    }

    .form-welcome {
        font-size: 2.2rem;
        font-weight: 800;
        color: var(--primary-color);
        margin: 0 0 0.5rem 0;
    }

    .form-welcome-sub {
        font-size: 1rem;
        color: var(--text-secondary);
        margin: 0;
        font-weight: 400;
    }

    .brand-logo-img {
        width: 160px;
        height: 160px;
    }

    .logo-image {
        width: 220px;
        height: 220px;
    }
}

/* Pantallas grandes (>= 1024px) */
@media (min-width: 1024px) {
    .login-form-panel {
        padding: 4rem 5rem;
    }

    .login-card {
        max-width: 520px;
    }

    .brand-logo-img {
        width: 180px;
        height: 180px;
    }

    .brand-title {
        font-size: 3rem;
    }

    .brand-tagline {
        font-size: 1.1rem;
        letter-spacing: 4px;
    }

    .brand-description {
        font-size: 1.05rem;
        max-width: 340px;
    }
}

/* Pantallas muy grandes (>= 1400px) */
@media (min-width: 1400px) {
    .login-brand-panel {
        flex: 0 0 35%;
        max-width: 35%;
    }

    .login-form-panel {
        flex: 0 0 65%;
        max-width: 65%;
    }

    .login-card {
        max-width: 560px;
    }

    .brand-logo-img {
        width: 200px;
        height: 200px;
    }

    .brand-title {
        font-size: 3.5rem;
    }
}

/* Formulario */
.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem;
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: var(--spacing-md);
    font-size: 1.2rem;
    color: var(--text-muted);
    z-index: 2;
    transition: color 0.3s ease;
}

.form-input {
    width: 100%;
    padding: var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-small);
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: all 0.3s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(22, 22, 94, 0.1);
}

.form-input:focus + .input-icon {
    color: var(--primary-color);
}

.form-input.has-value {
    border-color: var(--primary-color);
}

/* Botón de mostrar/ocultar contraseña */
.password-toggle {
    position: absolute;
    right: var(--spacing-md);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
    z-index: 2;
}

.password-toggle:hover {
    color: var(--primary-color);
}

/* Botón de login */
.login-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-light);
    border: none;
    border-radius: var(--border-radius-small);
    padding: var(--spacing-md);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    min-height: 48px;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-button:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.login-button:active:not(:disabled) {
    transform: translateY(0);
}

.login-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Spinner de carga */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Mensaje de error */
.error-message {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid var(--error-color);
    border-radius: var(--border-radius-small);
    padding: var(--spacing-md);
    color: var(--error-color);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    animation: shake 0.5s ease-in-out;
}

.error-icon {
    font-size: 1.1rem;
}

/* Enlace olvidé contraseña */
.forgot-password {
    text-align: right;
    margin-bottom: var(--spacing-lg);
}

.forgot-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.forgot-link:hover {
    color: var(--primary-color);
}

/* Footer del login */
.login-footer {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

.demo-info {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    margin-bottom: var(--spacing-md);
}

.create-account {
    text-align: center;
}

.create-link {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.create-link:hover {
    color: var(--primary-color);
}

/* Animaciones */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ==================== MÓVIL ==================== */
@media (max-width: 767px) {
    body.login-page {
        padding: 1rem;
        align-items: center;
    }

    .login-wrapper {
        flex-direction: column;
        width: 100%;
        max-width: 420px;
        max-height: 92vh;
        border-radius: 16px;
        overflow: hidden;
        overflow-y: auto;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    }

    .login-form-panel {
        flex: none;
        padding: 1.5rem;
        max-width: 100%;
    }

    .login-brand-panel {
        display: none;
    }

    .login-header-mobile {
        display: block;
    }

    .login-form-header {
        display: none;
    }

    .login-card {
        max-width: 100%;
    }

    .logo-image {
        width: 140px;
        height: 140px;
    }

    .app-title {
        font-size: 2rem;
    }

    .form-input {
        font-size: 16px;
    }
}

@media (max-width: 360px) {
    .login-form-panel {
        padding: 1rem;
    }

    .app-title {
        font-size: 1.8rem;
    }
    
    .logo-image {
        width: 120px;
        height: 120px;
    }
}

/* ==================== MODO OSCURO ==================== */

/* Dark mode: toda la pantalla oscura (html y body cuando es página de login) */
html:has(body[data-theme="dark"].login-page) {
    background: #111827 !important;
    min-height: 100%;
}

[data-theme="dark"] body.login-page,
[data-theme="dark"].login-page {
    background: #111827 !important;
    min-height: 100vh;
}

[data-theme="dark"] .login-form-panel {
    background: #1e2433;
}

[data-theme="dark"] .login-wrapper {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .login-brand-panel {
    background: linear-gradient(135deg, #003566 0%, #002244 50%, #001a33 100%);
}

[data-theme="dark"] .form-welcome {
    color: #ffffff;
}

[data-theme="dark"] .form-welcome-sub {
    color: #94a3b8;
}

[data-theme="dark"] .form-label {
    color: #cbd5e1;
}

[data-theme="dark"] .form-input {
    background: #283040;
    border-color: #3b4557;
    color: #f1f5f9;
}

[data-theme="dark"] .form-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .form-input:hover {
    border-color: #4b6a9b;
}

[data-theme="dark"] .form-input::placeholder {
    color: #64748b;
}

[data-theme="dark"] .form-input.has-value {
    border-color: #3b82f6;
}

[data-theme="dark"] .login-button {
    background: linear-gradient(135deg, #0056A4 0%, #003E78 100%);
}

[data-theme="dark"] .login-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #003E78 0%, #0056A4 100%);
}

[data-theme="dark"] .logo-image {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .app-title {
    color: #60a5fa;
}

[data-theme="dark"] .app-subtitle {
    color: #94a3b8;
}

[data-theme="dark"] .login-form-footer {
    color: #64748b;
}

[data-theme="dark"] .error-message {
    background: rgba(220, 53, 69, 0.15);
    border-color: #dc3545;
    color: #f87171;
}

[data-theme="dark"] .keyboard-icon {
    opacity: 0.5;
}

[data-theme="dark"] .password-toggle {
    color: #94a3b8;
}

[data-theme="dark"] .password-toggle:hover {
    color: #cbd5e1;
}

/* Modo oscuro automático (según el navegador/Windows) SOLO si la app no está en modo claro: sin el
   :not([data-theme="light"]) se mezclaban colores claros y oscuros cuando el navegador estaba en oscuro
   y la app en claro. Las variables van en body (no en :root) porque el tema de la app vive en body. */
@media (prefers-color-scheme: dark) {
    body:not([data-theme="light"]) {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-card: #333333;
        --bg-input: #444444;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --text-muted: #888888;
        --border-color: #555555;
        --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.3);
        --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.4);
        --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.5);
        --login-form-bg: #1e2433;
    }

    /* html toma su fondo de --bg-primary de :root (claro); con la app sin tema claro, que acompañe a body. */
    html:has(body:not([data-theme="light"])) {
        background-color: #1a1a1a;
    }

    body.login-page:not([data-theme="light"]) {
        background: transparent;
    }

    body:not([data-theme="light"]) .login-wrapper {
        box-shadow: none;
    }

    body:not([data-theme="light"]) .login-brand-panel {
        background: linear-gradient(135deg, #003566 0%, #002244 50%, #001a33 100%);
    }

    body:not([data-theme="light"]) .form-welcome {
        color: #ffffff;
    }

    body:not([data-theme="light"]) .form-welcome-sub {
        color: #94a3b8;
    }

    body:not([data-theme="light"]) .form-label {
        color: #cbd5e1;
    }

    body:not([data-theme="light"]) .form-input {
        background: #283040;
        border-color: #3b4557;
        color: #f1f5f9;
    }

    body:not([data-theme="light"]) .form-input:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    }

    body:not([data-theme="light"]) .form-input::placeholder {
        color: #64748b;
    }

    body:not([data-theme="light"]) .logo-image {
        border-color: rgba(255, 255, 255, 0.2);
    }

    body:not([data-theme="light"]) .app-title {
        color: #60a5fa;
    }

    body:not([data-theme="light"]) .app-subtitle {
        color: #94a3b8;
    }

    body:not([data-theme="light"]) .login-form-footer {
        color: #64748b;
    }

    body:not([data-theme="light"]) .error-message {
        background: rgba(220, 53, 69, 0.15);
        color: #f87171;
    }
}

/* Mejoras de accesibilidad */
.form-input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.login-button:focus-visible {
    outline: 2px solid var(--text-light);
    outline-offset: 2px;
}

/* Efectos de hover mejorados */
.form-input:hover {
    border-color: var(--primary-light);
}

/* Transiciones suaves */
* {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

/* Input con teclado personalizado */
.input-with-keyboard {
    position: relative;
    width: 100%;
}

.keyboard-icon {
    position: absolute;
    right: 3rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    pointer-events: none;
    opacity: 0.6;
    z-index: 2;
}

.input-with-password-toggle .keyboard-icon {
   /* right: 3.5rem;*/
}

.input-with-keyboard .form-input {
    cursor: pointer;
    padding-right: 5rem;
}

.input-with-keyboard.input-with-password-toggle .form-input {
    padding-right: 6rem;
}

/* Clave de mesero: botón ABC para abrir el teclado alfanumérico (claves con letras, p. ej. K1).
   Ocupa el lugar del ojo del campo de contraseña, así los dos campos quedan alineados. */
.input-with-keyboard.input-with-alt-keyboard .form-input {
    padding-right: 6rem;
}

/* Icono ⌨️ + botón ABC en un mismo grupo, centrados verticalmente y alineados entre sí. */
.keyboard-trailing {
    position: absolute;
    right: var(--spacing-md);
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1;
}

/* Dentro del grupo el icono deja de ir "flotando". Doble clase a propósito: crear-mesa.css se carga
   DESPUÉS y fija .keyboard-icon (absolute, right: 1rem) para toda la app. */
.keyboard-trailing .keyboard-icon {
    position: static;
    transform: none;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

/* Botón discreto, del tamaño del icono ⌨️: solo se resalta al pasar el cursor o al tocarlo. */
.keyboard-alt-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.4rem;
    padding: 0 0.3rem;
    border-radius: 5px;
    border: none;
    background: transparent;
    color: var(--text-muted, #6c757d);
    font-size: 0.66rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.04em;
    opacity: 0.75;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.keyboard-alt-toggle:hover,
.keyboard-alt-toggle:focus-visible {
    opacity: 1;
    background: rgba(0, 86, 164, 0.1);
    color: var(--primary-color, #0056A4);
}

[data-theme="dark"] .keyboard-alt-toggle {
    color: #94a3b8;
}

[data-theme="dark"] .keyboard-alt-toggle:hover,
[data-theme="dark"] .keyboard-alt-toggle:focus-visible {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

.input-with-keyboard .form-input.has-value {
    background: rgba(22, 22, 94, 0.05);
}

[data-theme="dark"] .input-with-keyboard .form-input.has-value {
    background: rgba(59, 130, 246, 0.1);
}

/* Teclado numérico */
.keyboard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    padding: 0;
}

.keyboard-container {
    width: 100%;
    max-width: 500px;
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    margin: 0;
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
}

/* Teclado alfanumérico - usar todo el ancho */
.keyboard-container.keyboard-alfanumerico {
    max-width: 100%;
    width: 100%;
    margin: 0;
    left: 0;
    bottom: 20px;
    transform: translateX(0);
    border-radius: 20px 20px 0 0;
}

@keyframes slideUpKeyboard {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Animación específica para teclado numérico (centrado) */
.keyboard-container:not(.keyboard-alfanumerico) {
    animation: slideUpKeyboardNumeric 0.3s ease-out;
}

@keyframes slideUpKeyboardNumeric {
    from {
        transform: translateX(-50%) translateY(calc(100% + 50px));
    }
    to {
        transform: translateX(-50%) translateY(0);
    }
}

/* Animación para teclado alfanumérico (ancho completo) */
.keyboard-container.keyboard-alfanumerico {
    animation: slideUpKeyboardAlphanumeric 0.3s ease-out;
}

@keyframes slideUpKeyboardAlphanumeric {
    from {
        transform: translateX(0) translateY(100%);
    }
    to {
        transform: translateX(0) translateY(0);
    }
}

.keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4a90e2 100%);
    color: white;
}

.keyboard-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.keyboard-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.3s ease;
}

.keyboard-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.keyboard-display {
    padding: 1.5rem;
    background: var(--bg-primary);
}

.keyboard-display-input {
    width: 100%;
    padding: 1.25rem;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    border: 3px solid var(--primary-color);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 2px 10px rgba(22, 22, 94, 0.2);
    outline: none;
    letter-spacing: 0.1em;
}

.keyboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding: 1.5rem;
    background: var(--bg-card);
}

.keyboard-btn {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 70px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.keyboard-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.keyboard-btn:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border-color: var(--primary-color);
}

.keyboard-btn-clear {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: white;
    border-color: #ff9800;
}

.keyboard-btn-clear:hover {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
}

.keyboard-btn-backspace {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border-color: #c82333;
    font-size: 1.5rem;
}

.keyboard-btn-backspace:hover {
    background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
}

.keyboard-footer {
    padding: 1rem 1.5rem 0;
    background: var(--bg-card);
    margin-bottom: 0;
}

.keyboard-btn-confirm {
    width: 100%;
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--success-color) 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
    margin-bottom: 0;
}

.keyboard-btn-confirm:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(40, 167, 69, 0.3);
}

.keyboard-btn-confirm:hover {
    background: linear-gradient(135deg, #20c997 0%, #1e7e34 100%);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

/* Teclado alfanumérico */
.keyboard-alfanumerico {
    width: 100%;
}

.keyboard-alfanumerico .keyboard-container {
    max-width: 100%;
    width: 100%;
}

.keyboard-alfanumerico .keyboard-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    width: 100%;
}

.keyboard-row-alfanumerico {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    flex-wrap: nowrap;
    width: 100%;
}

.keyboard-row-alfanumerico .keyboard-btn {
    flex: 1;
    min-width: 0;
    padding: 1rem 0.5rem;
    font-size: 1.25rem;
    min-height: 55px;
}

.keyboard-row-numbers .keyboard-btn {
    flex: 1;
    min-width: 0;
}

.keyboard-row-special .keyboard-btn {
    flex: 1;
    min-width: 0;
}

.keyboard-btn-shift {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    border-color: #5a6268;
}

.keyboard-btn-shift:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
}

.keyboard-btn-special {
    background: linear-gradient(135deg, #adb5bd 0%, #868e96 100%);
    color: white;
    border-color: #868e96;
    font-size: 1.1rem;
}

.keyboard-btn-special:hover {
    background: linear-gradient(135deg, #868e96 0%, #6c757d 100%);
}

.keyboard-btn-toggle {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    color: white;
    border-color: #343a40;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 60px;
}

.keyboard-btn-toggle:hover {
    background: linear-gradient(135deg, #343a40 0%, #23272b 100%);
}

.keyboard-btn-space {
    flex: 2;
    min-width: 100px;
}

.keyboard-row-bottom {
    justify-content: space-between;
}

.keyboard-row-bottom .keyboard-btn {
    flex: 0 1 auto;
}

/* Estilos modo oscuro para teclados */
[data-theme="dark"] .keyboard-overlay {
    background: rgba(0, 0, 0, 0.85);
}

[data-theme="dark"] .keyboard-container {
    background: #1e2433;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .keyboard-display {
    background: #111827;
}

[data-theme="dark"] .keyboard-display-input {
    background: #283040;
    border-color: #3b82f6;
    color: #f1f5f9;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .keyboard-grid {
    background: #1e2433;
}

[data-theme="dark"] .keyboard-btn {
    background: linear-gradient(135deg, #283040 0%, #1e2433 100%);
    border-color: #3b4557;
    color: #f1f5f9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .keyboard-btn:hover {
    background: linear-gradient(135deg, #3b4557 0%, #283040 100%);
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .keyboard-footer {
    background: #1e2433;
}

/* Responsive para teclados */
@media (max-width: 480px) {
    .keyboard-container {
        border-radius: 15px;
        bottom: 50px;
    }
    
    .keyboard-container.keyboard-alfanumerico {
        border-radius: 15px 15px 0 0;
        bottom: 0;
    }

    /* Teclado alfanumérico siempre a todo ancho en móviles */
        .keyboard-container.keyboard-alfanumerico {
            max-width: 100%;
            width: 100%;
            max-height: 80vh;
            margin-bottom: 70px;
        }

    .keyboard-display {
        padding: 0.5rem;
    }

    .keyboard-display-input {
        font-size: 1.25rem;
        padding: 0.625rem;
    }

    .keyboard-grid {
        gap: 0.5rem;
        padding: 0.875rem;
    }

    .keyboard-btn {
        padding: 1rem;
        font-size: 1.25rem;
        min-height: 55px;
    }

    .keyboard-row-alfanumerico {
        gap: 0.25rem;
    }

    .keyboard-row-alfanumerico .keyboard-btn {
        min-height: 40px;
        font-size: 0.875rem;
        padding: 0.5rem 0.125rem;
        flex: 1;
        min-width: 0;
        border-width: 1px;
    }

    .keyboard-header {
        padding: 0.625rem 0.875rem;
    }

    .keyboard-header h3 {
        font-size: 0.9rem;
    }

    .keyboard-close {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .keyboard-footer {
        padding: 0.5rem 0.875rem 0;
        margin-bottom: 0;
    }

    .keyboard-btn-confirm {
        padding: 0.75rem;
        font-size: 1rem;
        border-radius: 12px;
        margin-bottom: 0;
    }

    .keyboard-alfanumerico .keyboard-grid {
        padding: 0.5rem 0.75rem;
        gap: 0.25rem;
        overflow-y: auto;
        max-height: calc(50vh - 120px);
    }

    .keyboard-btn-shift,
    .keyboard-btn-special {
        font-size: 0.8rem;
    }

    .keyboard-btn-backspace,
    .keyboard-btn-clear {
        font-size: 0.875rem;
        min-height: 40px;
    }
}

@media (max-width: 360px) {
    .keyboard-container.keyboard-alfanumerico {
        max-height: 45vh;
    }

    .keyboard-row-alfanumerico .keyboard-btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.0625rem;
        min-height: 36px;
    }

    .keyboard-row-numbers .keyboard-btn {
        font-size: 0.875rem;
    }

    .keyboard-row-special .keyboard-btn {
        font-size: 0.7rem;
    }

    .keyboard-alfanumerico .keyboard-grid {
        padding: 0.375rem 0.5rem;
        gap: 0.2rem;
        max-height: calc(45vh - 100px);
    }

    .keyboard-display-input {
        font-size: 1rem;
        padding: 0.5rem;
    }

    .keyboard-header {
        padding: 0.5rem 0.75rem;
    }

    .keyboard-header h3 {
        font-size: 0.825rem;
    }

    .keyboard-btn-confirm {
        padding: 0.625rem;
        font-size: 0.9rem;
        border-radius: 12px;
        margin-bottom: 0;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .keyboard-container.keyboard-alfanumerico {
        max-height: 55vh;
    }

    .keyboard-row-alfanumerico {
        gap: 0.375rem;
    }

    .keyboard-row-alfanumerico .keyboard-btn {
        font-size: 1rem;
        padding: 0.625rem 0.25rem;
        min-height: 45px;
    }

    .keyboard-alfanumerico .keyboard-grid {
        padding: 0.75rem 1rem;
        gap: 0.375rem;
        max-height: calc(55vh - 140px);
        overflow-y: auto;
    }

    .keyboard-display {
        padding: 0.75rem;
    }

    .keyboard-display-input {
        font-size: 1.5rem;
        padding: 0.875rem;
    }

    .keyboard-header {
        padding: 0.75rem 1rem;
    }

    .keyboard-footer {
        padding: 0.75rem 1rem 0;
        margin-bottom: 0;
    }
    
    .keyboard-btn-confirm {
        border-radius: 12px;
        margin-bottom: 0;
    }
    
    /* Botón de espacio ocupa todo el espacio en tabletas - solo para teclado alfanumérico */
    .keyboard-alfanumerico .keyboard-row-bottom {
        justify-content: flex-start;
        gap: 0.5rem;
    }
    
    .keyboard-alfanumerico .keyboard-btn-space {
        flex: 1;
        min-width: 0;
        width: auto;
        max-width: none;
        font-size: 1.1rem;
        padding: 0.75rem 1rem;
    }
    
    /* Botón de backspace 3 veces más grande en tabletas - solo para teclado alfanumérico */
    .keyboard-alfanumerico .keyboard-btn-backspace {
        min-width: 150px;
        width: 150px;
        font-size: 2.5rem;
        padding: 1rem 1.5rem;
        min-height: 70px;
        flex: 0 0 150px;
    }
    
    /* Ajustar otros botones de la fila inferior en tabletas - solo para teclado alfanumérico */
    .keyboard-alfanumerico .keyboard-row-bottom .keyboard-btn-toggle {
        flex: 0 0 auto;
        min-width: 80px;
        width: auto;
    }
    
    /* Botones de punto, coma, guion bajo y limpiar más grandes en tabletas */
    .keyboard-alfanumerico .keyboard-row-bottom .keyboard-btn-special {
        min-width: 60px;
        width: 60px;
        font-size: 1.3rem;
        padding: 0.75rem 1rem;
        min-height: 50px;
        flex: 0 0 60px;
    }
    
    .keyboard-alfanumerico .keyboard-row-bottom .keyboard-btn-clear {
        min-width: 70px;
        width: 70px;
        font-size: 1.4rem;
        padding: 0.75rem 1rem;
        min-height: 50px;
        flex: 0 0 70px;
    }
}

/* Para pantallas grandes */
@media (min-width: 769px) {
    /* Teclado numérico - centrado */
    .keyboard-container:not(.keyboard-alfanumerico) {
        border-radius: 20px;
        max-width: 400px;
        margin: 0 auto;
    }

    /* Contenedor fijo en la parte inferior */
    .keyboard-container:not(.keyboard-alfanumerico) {
        left: 50%;
        transform: translateX(-50%) translateY(0);
    }

    /* Teclado alfanumérico - todo el ancho */
    .keyboard-container.keyboard-alfanumerico {
        border-radius: 20px 20px 0 0;
        max-width: 100%;
        width: 100%;
        margin: 0;
        max-height: 60vh;
        bottom: 0;
    }

    .keyboard-row-alfanumerico .keyboard-btn {
        font-size: 1.3rem;
        padding: 1rem 0.5rem;
        min-height: 58px;
    }

    .keyboard-alfanumerico .keyboard-grid {
        padding: 1.25rem 1.5rem;
        gap: 0.625rem;
        max-height: calc(60vh - 180px);
        overflow-y: auto;
    }

    .keyboard-row-alfanumerico {
        gap: 0.625rem;
    }
    
    /* Botón de espacio ocupa todo el espacio en escritorio - solo para teclado alfanumérico */
    .keyboard-alfanumerico .keyboard-row-bottom {
        justify-content: flex-start;
        gap: 0.625rem;
    }
    
    .keyboard-alfanumerico .keyboard-btn-space {
        flex: 1;
        min-width: 0;
        width: auto;
        max-width: none;
        font-size: 1.2rem;
        padding: 1rem 1.5rem;
    }
    
    /* Botón de backspace 3 veces más grande en escritorio - solo para teclado alfanumérico */
    .keyboard-alfanumerico .keyboard-btn-backspace {
        min-width: 200px;
        width: 200px;
        font-size: 3rem;
        padding: 1.5rem 2rem;
        min-height: 90px;
        flex: 0 0 200px;
    }
    
    /* Ajustar otros botones de la fila inferior en escritorio - solo para teclado alfanumérico */
    .keyboard-alfanumerico .keyboard-row-bottom .keyboard-btn-toggle {
        flex: 0 0 auto;
        min-width: 100px;
        width: auto;
    }
    
    /* Botones de punto, coma, guion bajo y limpiar más grandes en escritorio */
    .keyboard-alfanumerico .keyboard-row-bottom .keyboard-btn-special {
        min-width: 80px;
        width: 80px;
        font-size: 1.5rem;
        padding: 1rem 1.25rem;
        min-height: 60px;
        flex: 0 0 80px;
    }
    
    .keyboard-alfanumerico .keyboard-row-bottom .keyboard-btn-clear {
        min-width: 90px;
        width: 90px;
        font-size: 1.6rem;
        padding: 1rem 1.5rem;
        min-height: 60px;
        flex: 0 0 90px;
    }
}

/* Para pantallas grandes */
@media (min-width: 769px) {
    /* Teclado numérico - centrado */
    .keyboard-container:not(.keyboard-alfanumerico) {
        border-radius: 20px;
        max-width: 400px;
        margin: 0 auto;
    }

    /* Teclado alfanumérico - todo el ancho */
    .keyboard-container.keyboard-alfanumerico {
        border-radius: 20px 20px 0 0;
        max-width: 100%;
        width: 100%;
        margin: 0;
        left: 0;
        transform: translateX(0);
    }
}