/* estilos.css - Diseño limpio y responsivo con foco en impresión */
/* BLOQUEO DEFINITIVO CONTRA CHROME AUTO DARK THEME */
:root {
    color-scheme: light !important;
}

/* Temas predeterminados */
:root {
    --primary: hsl(210, 70%, 45%);
    --primary-dark: hsl(210, 70%, 35%);
    --bg: hsl(0, 0%, 98%);
    --card-bg: hsl(0, 0%, 100%);
    --text: hsl(210, 10%, 20%);
    --muted: hsl(210, 10%, 50%);
    --border: hsl(210, 10%, 85%);
    --radius: 0.5rem;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --print-bg: #fff;
    --print-text: #000;
}

/* FORZAR QUE CHROME NO USE SU PROPIO FONDO OSCURO */
html, body {
    background: var(--bg) !important;
    background-color: var(--bg) !important;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* TEMA DÍA CLÁSICO (Azul) */
body.theme-dia-azul {
    --primary: hsl(210, 70%, 45%);
    --primary-dark: hsl(210, 70%, 35%);
    --bg: hsl(210, 20%, 96%);
    --card-bg: hsl(0, 0%, 100%);
    --text: hsl(210, 20%, 15%);
    --border: hsl(210, 15%, 85%);
}

/* TEMA DÍA ESMERALDA (Verde Premium) */
body.theme-dia-verde {
    --primary: hsl(150, 60%, 35%);
    --primary-dark: hsl(150, 60%, 25%);
    --bg: hsl(120, 20%, 97%);
    --card-bg: hsl(0, 0%, 100%);
    --text: hsl(150, 25%, 15%);
    --border: hsl(150, 15%, 85%);
}

/* TEMA NOCHE DRACULA (Morado) */
body.theme-noche-dracula {
    --primary: hsl(265, 80%, 70%);
    --primary-dark: hsl(265, 80%, 60%);
    --bg: hsl(230, 25%, 12%);
    --card-bg: hsl(230, 20%, 18%);
    --text: hsl(290, 100%, 50%);
    --border: hsl(230, 15%, 28%);
    /* ELIMINADO: color-scheme: dark; para que Chrome no force el fondo oscuro */
}

/* TEMA NOCHE OBSIDIANA (Negro Profundo) */
body.theme-noche-obsidiana {
    --primary: hsl(0, 75%, 50%);
    --primary-dark: hsl(0, 75%, 40%);
    --bg: hsl(0, 0%, 4%);
    --card-bg: hsl(0, 0%, 10%);
    --text: hsl(0, 60%, 50%);
    --border: hsl(0, 0%, 20%);
    /* ELIMINADO: color-scheme: dark; para que Chrome no force el fondo oscuro */
}

/* ============================================================ */
/* ESTILOS BASE */
/* ============================================================ */

body {
    margin: 0;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg) !important;
    background-color: var(--bg) !important;
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}

h1, h2, h3 {
    margin: 0;
    color: var(--primary);
}

.container {
    max-width: 1200px;
    margin: auto;
    padding: 1rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

a.button, button {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.3s, transform 0.1s;
}

a.button:hover, button:hover {
    background: var(--primary-dark);
}

a.button:active, button:active {
    transform: scale(0.98);
}

/* inputs y selects forzados a usar las variables de color del tema */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="month"],
input[type="date"],
select,
textarea {
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.8rem;
    font-family: inherit;
    color: var(--text) !important;
    background-color: var(--card-bg) !important;
    transition: border-color 0.3s, background-color 0.3s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary) !important;
    outline: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th, td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    background: var(--primary);
    color: #fff;
}

tr:hover {
    background: rgba(128, 128, 128, 0.08);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    color: var(--text);
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    border: 1px solid var(--border);
}

.modal-header {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.modal-close, .close {
    float: right;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.5rem;
    color: var(--text);
    opacity: 0.7;
}

.modal-close:hover, .close:hover {
    opacity: 1;
}

/* ============================================================ */
/* ESTILOS DE IMPRESIÓN UNIFICADOS (A4 y T80) */
/* ============================================================ */

@media print {
    /* Ocultar elementos de la aplicación web y resetear dimensiones para evitar hojas en blanco */
    body, html {
        background: #fff !important;
        color: #000 !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
    }
    
    /* Ocultar toda la interfaz visual no imprimible, incluyendo la calculadora flotante y su botón */
    header, footer, nav, .header-container, .month-selector, .summary, .charts-grid, 
    .search-section, .header-buttons, .action-btn, button, a, select, input, .close, .modal,
    div[style*="justify-content: space-between"], .user-actions, 
    #floatCalculator, .float-calc-btn, #btnAbrirCalculadora {
        display: none !important;
    }
    
    /* Hacer visibles únicamente los elementos de impresión designados */
    .print-only {
        display: block !important;
    }
    
    /* Configuración común para las tablas en impresión */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        color: #000 !important;
        background: #fff !important;
        margin-top: 10px !important;
    }
    
    th, td {
        border: 1px solid #000 !important;
        padding: 5px !important;
        font-size: 10pt !important;
        color: #000 !important;
        background: #fff !important;
    }
    
    th {
        background: #f0f0f0 !important;
        color: #000 !important;
    }

    /* ─── FORMATO REPORTE A4 ─── */
    body.print-format-a4 {
        width: auto !important;
        margin: 15mm 20mm !important;
        font-size: 9.5pt !important;
    }
    body.print-format-a4 .header-impresion {
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        border-bottom: 3px solid #2c3e50; /* Línea de cabecera elegante gris/azul oscuro */
        padding-bottom: 12px;
        margin-bottom: 18px;
    }
    body.print-format-a4 .logo-comprobante {
        max-height: 55px;
        max-width: 120px;
        object-fit: contain;
    }
    body.print-format-a4 .titulo-comprobante {
        font-size: 16pt;
        font-weight: bold;
        color: #2c3e50;
        text-transform: uppercase;
        margin-top: 4px;
        line-height: 1.2;
    }
    body.print-format-a4 .meta-comprobante {
        text-align: right;
        font-size: 9pt;
        line-height: 1.4;
    }
    body.print-format-a4 .meta-comprobante .doc-badge {
        background: #2c3e50;
        color: #fff;
        padding: 3px 12px;
        border-radius: 4px;
        font-weight: bold;
        font-size: 10pt;
        display: inline-block;
        margin-bottom: 5px;
        letter-spacing: 1px;
    }

    /* Optimización de tablas en A4: elegante y compacta */
    body.print-format-a4 table {
        margin-top: 8px !important;
        border-collapse: collapse !important;
        width: 100% !important;
    }
    body.print-format-a4 th, 
    body.print-format-a4 td {
        border: none !important;
        border-bottom: 1px solid #e2e8f0 !important; /* Separadores claros */
        padding: 6px 8px !important; /* Compacto pero respirable */
        font-size: 9pt !important;
        color: #2d3748 !important;
    }
    body.print-format-a4 th {
        background: #f7fafc !important;
        border-top: 1px solid #cbd5e0 !important;
        border-bottom: 2px solid #2c3e50 !important;
        font-weight: bold !important;
        color: #2c3e50 !important;
        text-transform: uppercase;
        font-size: 8.5pt !important;
    }
    body.print-format-a4 tr:nth-child(even) td {
        background: #f8fafc !important;
    }

    /* ─── FORMATO TICKET DE 80MM (T80) ─── */
    body.print-format-t80 {
        width: 80mm !important;
        margin: 0 !important;
        padding: 5mm !important;
        font-family: 'Courier New', Courier, monospace !important;
    }
    body.print-format-t80 .header-impresion {
        display: block !important;
        text-align: center;
        border-bottom: 1px dashed #000;
        padding-bottom: 8px;
        margin-bottom: 10px;
    }
    body.print-format-t80 .logo-comprobante {
        max-height: 40px;
        max-width: 80px;
        display: block;
        margin: 0 auto 5px;
    }
    body.print-format-t80 .titulo-comprobante {
        font-size: 12pt;
        font-weight: bold;
    }
    body.print-format-t80 .meta-comprobante {
        text-align: center;
        font-size: 8pt;
        margin-top: 5px;
    }
    body.print-format-t80 table, 
    body.print-format-t80 th, 
    body.print-format-t80 td {
        border: none !important;
        border-bottom: 1px dashed #000 !important;
        font-size: 8pt !important;
    }
    body.print-format-t80 th {
        background: transparent !important;
        border-top: 1px dashed #000 !important;
        border-bottom: 1px dashed #000 !important;
    }
    body.print-format-t80 .t80-hide {
        display: none !important;
    }
}

/* Botón unificado de regreso / navegación secundaria */
.back-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1rem !important;
    background: var(--card-bg) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.back-btn:hover {
    background: var(--border) !important;
    transform: translateX(-3px);
}

.back-btn:active {
    transform: scale(0.97) translateX(-3px);
}