/* =======================================================
   VARIABLES BASE
======================================================= */
:root {
    --color-bg: #eef1f5;
    --color-text: #1a1a1a;

    --sidebar-bg1: #1d2939;
    --sidebar-bg2: #111a24;

    --primary: #1e88e5;
    --primary-dark: #0d6cd1;
    --success: #43a047;
    --danger: #e53935;
    --warning: #fb8c00;

    --table-head: #1e88e5;

    --card-bg: #ffffff;
    --modal-bg: #ffffff;
    --input-bg: #fafafa;
    --border-color: #e0e0e0;

    --smooth: 0.3s ease;
}

/* =======================================================
   RESET Y ESTILOS GENERALES
======================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* =======================================================
   SCROLLBAR PREMIUM (BARRAS DE DESPLAZAMIENTO)
======================================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: #b0bec5;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* =======================================================
   LAYOUT PRINCIPAL (SIDEBAR Y CONTENIDO)
======================================================= */
#app {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 250px;
    background: linear-gradient(180deg, var(--sidebar-bg1), var(--sidebar-bg2));
    color: white;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    transition: var(--smooth);
    z-index: 1000;
}

.sidebar h2 {
    text-align: center;
    margin-bottom: 5px;
    font-size: 22px;
    letter-spacing: 1px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

.sidebar ul li {
    padding: 15px 25px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: var(--smooth);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar ul li:hover {
    background: rgba(255,255,255,0.1);
    padding-left: 30px;
}

.content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background-color: var(--color-bg);
}

.section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.section.visible {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =======================================================
   BOTÓN MENÚ MÓVIL
======================================================= */
#mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 15px;
    font-size: 20px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 1100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* =======================================================
   FORMULARIOS Y CAJAS
======================================================= */
.form-box {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

.form-box h2, .form-box h4 {
    margin-bottom: 20px;
    color: var(--primary);
    border-bottom: 2px solid var(--color-bg);
    padding-bottom: 10px;
}

.form-row-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9em;
    color: #555;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    font-size: 15px;
    transition: var(--smooth);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.15);
}

/* =======================================================
   BOTONES
======================================================= */
button {
    cursor: pointer;
    font-family: inherit;
    transition: var(--smooth);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 15px;
    border-radius: 6px;
    font-weight: 600;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: #e0e0e0;
    color: #333;
    border: none;
    padding: 10px 20px;
    font-size: 15px;
    border-radius: 6px;
    font-weight: 600;
}

.btn-secondary:hover { background: #bdbdbd; }

.btn-editar {
    background: var(--warning);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
}

.btn-editar:hover { background: #e67e22; }

.btn-eliminar {
    background: var(--danger);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
}

.btn-eliminar:hover { background: #c0392b; }

/* =======================================================
   TABLAS RESPONSIVAS
======================================================= */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 10px;
}

.data-table thead {
    background: var(--table-head);
    color: white;
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background-color: rgba(0,0,0,0.02);
}

/* ENVOLTORIO PARA QUE LA TABLA NO ROMPA EL CELULAR */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

.table-responsive .data-table {
    min-width: 600px; /* Fuerza a la tabla a no aplastarse y activa el scroll horizontal */
}

/* =======================================================
   MÓDULO DE CAJA (PUNTO DE VENTA) Y SUGERENCIAS
======================================================= */
.pos-search-container {
    position: relative;
    width: 100%;
}

.sugerencias-box {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 0 0 6px 6px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1050;
}

.sugerencias-box div {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.sugerencias-box div:hover {
    background: #f5f5f5;
}

.sugerencias-box div:last-child {
    border-bottom: none;
}

/* =======================================================
   ESTILOS PARA IMPRIMIR (PDF Y TICKET FÍSICO)
======================================================= */
@media print {
    @page { margin: 0; }
    body { margin: 0; background: white; }
    body * { visibility: hidden; }
    
    #modal-ticket, #modal-ticket * { visibility: visible; }
    
    #modal-ticket {
        position: absolute; left: 0; top: 0; width: 100%;
        background: white; padding: 20px;
        display: flex; justify-content: center; align-items: flex-start;
    }
    
    #modal-ticket > div {
        box-shadow: none !important; 
        width: 80mm !important;
        max-width: 100% !important;
        margin: 0 auto; padding: 0; border-radius: 0;
        color: black;
    }

    .btn-secondary, .btn-primary, #btn-imprimir-ticket { display: none !important; }
}

/* =======================================================
   ADAPTACIÓN PARA MÓVILES (MAGIA RESPONSIVE)
======================================================= */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -250px;
        height: 100%;
    }
    .sidebar.sidebar-open {
        left: 0;
    }
    #mobile-menu-btn {
        display: block;
    }
    .content {
        padding: 60px 15px 20px 15px; /* Espacio para el botón de menú arriba */
    }
    
    /* Que las tarjetas del dashboard se pongan una bajo otra en pantallas muy pequeñas */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* El Punto de Venta se apila: Buscador arriba, Cobro abajo */
    #caja > div {
        flex-direction: column;
    }
    #caja > div > div {
        width: 100%;
        min-width: 100%;
    }
}