/* ==========================================
   LIBRERÍA LOS CHINITOS - POS PRO v4.0 (TEMA: CUADERNO & ÚTILES)
   ========================================== */

:root {
    /* PALETA: ÚTILES ESCOLARES */
    --primary: #4f46e5;       /* Índigo / Tinta */
    --primary-dark: #3730a3;
    --secondary: #64748b;     /* Lápiz Grafito */
    --success: #10b981;       /* Corrector Verde */
    --warning: #f59e0b;       /* Resaltador Amarillo */
    --danger: #ef4444;        /* Tinta Roja / Borrador */
    
    /* FONDOS PAPEL */
    --bg-app: #f8fafc;        /* Blanco Sucio */
    --text-main: #1e293b;
    
    /* ELEMENTOS DEL CUADERNO */
    --paper-line: #e0f2fe;    /* Color de las líneas */
    --paper-margin: #fca5a5;   /* Línea de margen roja */
    --hole-color: #cbd5e1;    /* Color de los agujeros */
    
    --border: #e2e8f0;
    --glass-bg: rgba(255,255,255,0.95);
}

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

body {
    /* EFECTO: FONDO CUADRICULADO (Cuaderno) */
    background-color: #fff;
    background-image: 
        linear-gradient(90deg, transparent 79px, var(--paper-line) 79px, var(--paper-line) 81px, transparent 81px), /* Líneas verticales */
        linear-gradient(transparent 1px, transparent 1px), /* Líneas horizontales finas */
        linear-gradient(var(--bg-app) 2px, transparent 2px);
    background-size: 100% 100%, 100% 24px, 100% 24px;
    
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--secondary); border-radius: 4px; }

/* --- PANTALLA DE LOGIN (HOJA ANILLADA) --- */
.center-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    /* Fondo Tiza Negra / Pizarra para contraste */
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    position: relative;
}

.login-box {
    background: #fff;
    padding: 60px 50px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    border-radius: 4px; /* Bordes como papel cortado */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    
    /* EFECTO: AGUJEROS DE ANILLADO EN EL BORDE IZQUIERDO */
    background-image: radial-gradient(circle, var(--bg-app) 1.5px, transparent 1.5px);
    background-size: 16px 100%; /* Separación entre agujeros */
    background-position: 12px 0; /* Posición izquierda */
    background-repeat: repeat-y;
    
    /* Márgen interno para no tapar los agujeros */
    padding-left: 40px; 
}

.login-box input {
    width: 100%;
    margin-bottom: 20px;
    padding: 14px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    font-size: 16px;
    outline: none;
    transition: 0.3s;
    background: #f8fafc;
}

.login-box input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.login-box button {
    width: 100%;
    padding: 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 16px; /* Botón redondo estilo "goma" */
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    position: relative;
    overflow: hidden;
}

.login-box button:hover { 
    background-color: var(--primary-dark); 
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

/* --- LOADING SPINNER (Simulación de carga) --- */
.loader-spinner {
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top: 3px solid white;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Clase para activar el estado de carga */
.btn-loading {
    pointer-events: none;
    opacity: 0.8;
    background-color: var(--secondary) !important;
}

.btn-loading span {
    display: none; /* Oculta el texto "INGRESAR" al cargar */
}

.btn-loading::after {
    /* Muestra el spinner */
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    margin: 0 auto;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}


/* --- LAYOUT PRINCIPAL --- */
#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,0.6); /* Semitransparente para ver las líneas del body */
}

.topbar {
    background: white;
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 4px solid var(--warning); /* Borde estilo cinta adhesiva */
    height: 75px;
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.brand-text { 
    font-size: 1.4rem; 
    font-weight: 900; 
    color: var(--primary); 
    letter-spacing: -1px;
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-family: 'Courier New', Courier, monospace; /* Fuente estilo máquina de escribir */
}

/* BOTONES DE NAVEGACIÓN: ESTILO POST-ITS */
.nav-group { display: flex; gap: 8px; }

.nav-btn {
    background: white;
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 8px; /* Bordes ligeramente redondeados */
    color: var(--secondary);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Sombra suave para pegamento */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.nav-btn:hover, .nav-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px) rotate(-1deg); /* Inclinación lúdica al pasar mouse */
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.25);
}

/* Estilo especial para el botón activo (parecer un post-it usado) */
.nav-btn.active {
    border-bottom: 4px solid var(--warning);
}

.user-badge {
    background: #ec4899; /* Rosa borrador */
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(236, 72, 153, 0.4);
}

.turno-badge {
    font-family: 'Courier New', monospace;
    background: var(--success);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 11px;
    margin-right: 10px;
}

.btn-exit {
    background: #fee2e2;
    color: #b91c1c;
    border: none;
    border-radius: 50%; /* Redondo como un botón de equipo de música */
    width: 40px; height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
}

.btn-exit:hover { background: #fecaca; transform: rotate(90deg); transition: 0.3s; }

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

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; height: 100%; }

/* --- CORRECCIÓN AQUÍ --- */
.grid-4 { 
    display: grid; 
    /* Eliminado el paréntesis extra )) que rompía la sintaxis */
    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;
    position: relative;
}

/* --- CLASE FALTANTE --- */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px dashed var(--border);
}

/* Detalle decorativo en las tarjetas (parecer hoja de papel) */
.card::after {
    content: "";
    position: absolute;
    top: 20px; right: 20px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--border);
    box-shadow: 12px 0 0 var(--border), 24px 0 0 var(--border);
}

.card-title {
    margin: 0 0 15px 0;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px dashed var(--border);
    padding-bottom: 10px;
}

.input {
    width: 100%;
    padding: 12px;
    border: 2px dashed #cbd5e1; /* Borde punteado estilo lápiz */
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
    background: #fff;
}

.input:focus {
    border-color: var(--primary);
    border-style: solid; /* Se vuelve sólido al escribir */
    outline: none;
    background: #f8fafc;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 20px; /* Botones muy redondos estilo cápsula */
    cursor: pointer;
    font-weight: 700;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 0 var(--primary-dark); border-bottom: 4px solid transparent; }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 0 0 var(--primary-dark); border-bottom-width: 0; }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.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; }

/* --- MODALES --- */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    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: 16px;
    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;
    border: 4px solid var(--warning); /* Cinta adhesiva en el borde del modal */
}

/* --- POS PANELS --- */
.pos-search-panel { height: calc(100% - 20px); display: flex; flex-direction: column; }
.pos-cart-panel { height: 100%; display: flex; flex-direction: column; background: #fff; border: 2px solid var(--border); }

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

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

.cart-totals {
    background: var(--bg-app);
    padding: 20px;
    border-radius: 12px;
    border-top: 2px solid var(--border);
}

.total-display {
    text-align: right;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary);
    font-family: 'Courier New', monospace; /* Precio estilo recibo */
    margin-bottom: 15px;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.1); /* Sombra de texto 3D */
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 15px;
    background: white;
}

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

.table th {
    background: var(--primary);
    color: white;
    font-weight: 700;
    text-align: left;
    padding: 14px;
    font-size: 0.85rem;
    text-transform: uppercase;
}

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

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

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

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

/* --- RESPONSIVIDAD MÓVIL --- */
@media (max-width: 768px) {
    body { font-size: 14px; }
    
    .topbar {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 10px;
        align-items: stretch;
    }

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

    .nav-group {
        justify-content: space-between;
        overflow-x: auto;
        width: 100%;
        padding-bottom: 5px;
    }

    .nav-btn span { display: none; } /* Ocultar texto en móvil */
    .nav-btn {
        padding: 12px;
        flex: 1;
        justify-content: center;
    }

    .grid-2 {
        display: flex;
        flex-direction: column;
        gap: 15px;
        height: auto;
    }

    .pos-search-panel { height: auto; order: 1; }
    .pos-cart-panel { height: auto; order: 2; }

    .input { padding: 15px; font-size: 16px; border-radius: 10px; }
    
    .btn {
        padding: 15px;
        font-size: 16px;
        border-radius: 10px;
        width: 100%;
        margin-bottom: 10px;
    }

    .cart-items-container { max-height: 200px; font-size: 14px; }
    .total-display { font-size: 2.5rem; }

    .modal-content { width: 95%; max-height: 90vh; overflow-y: auto; padding: 15px; }
}