/* ==========================================
   AMB NOVEDADES - POS PRO v3.0 (CSS FINAL + MOBILE)
   ========================================== */

:root {
    /* COLORES PRINCIPALES */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* FONDOS Y TEXTOS */
    --bg-app: #f3f4f6;
    --text-main: #1e293b;
    
    /* VARIABLES FALTANTES */
    --border: #e2e8f0;           
    --glass-bg: rgba(255,255,255,0.95); 
    --glass-border: rgba(255,255,255,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* --- SCROLLBAR PERSONALIZADO --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* --- PANTALLA DE LOGIN --- */
.center-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}

.login-box {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 50px 40px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    text-align: center;
    animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-box input {
    width: 100%;
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 16px;
    outline: none;
}

.login-box button {
    width: 100%;
    padding: 15px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.login-box button:hover { background-color: var(--primary-dark); }

/* --- LAYOUT PRINCIPAL --- */
#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: white;
    padding: 0 20px;
    display: grid; 
    grid-template-columns: 250px 1fr 250px; /* Divide en 3 secciones fijas */
    align-items: center;
    border-bottom: 1px solid var(--border);
    height: 70px;
    z-index: 10;
}

.brand-text { font-size: 1.2rem; font-weight: 800; color: var(--primary); letter-spacing: -0.5px; }

.nav-group { 
    display: flex; 
    justify-content: center; /* Centra el menú en el header */
    gap: 5px; /* Reducimos el espacio entre botones */
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 8px 10px; /* Reducimos el relleno interno */
    font-size: 13px; /* Tamaño de fuente ligeramente menor */
    border-radius: 6px;
    color: var(--secondary);
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: flex; 
    gap: 5px; 
    justify-content: center; /* Centra las pestañas */
}

.nav-btn:hover, .nav-btn.active {
    background-color: #eff6ff;
    color: var(--primary);
}

.user-badge {
    background: var(--bg-app);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-right: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Ajuste para la sección de usuario */
.user-section {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.turno-badge {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s;
    margin-right: 15px;
}

.btn-exit {
    background: #fee2e2;
    color: #b91c1c;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 5px 12px;
    font-weight: bold;
}
.btn-exit:hover { background: #fecaca; }

.container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
}

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; height: 100%; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }

.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.card-title {
    margin: 0 0 15px 0;
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.input {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 10px;
}

.input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-exit { background: #ef4444; color: white; font-size: 12px; padding: 6px 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tab-content { display: none; animation: fadeIn 0.3s; }
.tab-content:not(.hidden) { display: block; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }
.admin-only { display: none; }

/* --- ESTILOS PARA MODALES --- */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-in-out;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s ease;
    position: relative;
}

/* --- VENTAS POS --- */
.pos-search-panel { height: calc(100% - 20px); display: flex; flex-direction: column; }
.pos-cart-panel { height: 100%; display: flex; flex-direction: column; }

.lista-productos-busqueda { display: none; }

.cart-items-container {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    margin-bottom: 15px;
    background: #fff;
}

.cart-totals {
    background: #f1f5f9;
    padding: 15px;
    border-radius: 12px;
    border-top: 1px solid #e2e8f0;
}

.total-display {
    text-align: right;
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-main);
    margin-bottom: 15px;
}

.table-container {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 15px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.table th {
    background: #f8fafc;
    color: var(--secondary);
    font-weight: 600;
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid #e2e8f0;
    font-size: 0.85rem;
    white-space: nowrap;
}

.table td {
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
}

.table tbody tr:hover { background: #f8fafc; }

.low-stock {
    color: var(--danger);
    font-weight: bold;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--secondary); }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.w-full { width: 100%; }

/* --- RESPONSIVIDAD MÓVIL (MEJORADO) --- */
@media (max-width: 768px) {
    /* 1. Ajustes Generales */
    body { font-size: 14px; } /* Texto base un poco más grande */
    
    /* 2. Header y Navegación */
    .topbar {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 10px;
        align-items: stretch;
        display: flex; /* Cambiamos a flex en móvil para apilar */
    }

    .brand-text {
        text-align: center;
        width: 100%;
        margin-bottom: 5px;
    }

    /* Ajuste para el menú en móvil */
    .nav-group {
        justify-content: flex-start;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
        width: 100%;
        /* Ocultar scrollbar en navegación móvil para limpieza visual */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    .nav-group::-webkit-scrollbar {
        display: none;
    }

    /* Ocultar texto de botones en móvil para dejar solo iconos */
    .nav-btn span { display: none; }
    .nav-btn {
        padding: 12px;
        flex: 1; /* Los botones se estiran para llenar el ancho */
        justify-content: center;
    }

    /* 3. Layout de Ventas (Grid 2) */
    .grid-2 {
        display: flex;
        flex-direction: column; /* Pila vertical: Busqueda arriba, Carrito abajo */
        gap: 15px;
        height: auto; /* Altura dinámica */
    }

    .pos-search-panel {
        height: auto;
        order: 1; /* Siempre arriba */
    }

    .pos-cart-panel {
        height: auto;
        order: 2; /* Siempre abajo */
    }

    /* 4. Inputs y Botones (Touch Friendly) */
    .input {
        padding: 15px; /* Más alto para dedos grandes */
        font-size: 16px; /* Evita que Safari haga zoom automático */
        border-radius: 10px;
    }

    .btn {
        padding: 15px;
        font-size: 16px;
        border-radius: 10px;
        width: 100%; /* Botones de ancho completo en móvil */
        margin-bottom: 10px;
    }

    /* 5. Carrito */
    .cart-items-container {
        max-height: 200px; /* Limita altura para dejar espacio a los botones de pago */
        font-size: 14px;
    }

    .total-display {
        font-size: 2.5rem; /* Total gigante */
    }

    /* 6. Modales */
    .modal-content {
        width: 95%; /* Casi ancho completo */
        max-height: 90vh;
        overflow-y: auto; /* Scroll si el modal es muy alto */
        padding: 15px;
    }
}

/* ==========================================
   COLORES DE SEDE PARA EL HEADER (AGREGADO)
   ========================================== */

.header-ferrenafe {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%) !important;
    border-bottom: 3px solid #1d4ed8;
}

.header-mesones {
    background: linear-gradient(135deg, #065f46 0%, #10b981 100%) !important;
    border-bottom: 3px solid #047857;
}

/* Ajuste para que el texto resalte sobre los colores */
.topbar h1, .topbar .nav-btn, #sede-actual-badge {
    color: white !important;
}