/* --- VARIABLES GLOBALES --- */
:root {
    --bg-color: #f4f7fb;
    --card-bg: #ffffff;
    --text-main: #2b2b44;
    --text-muted: #6b7280;
    --primary: #3b3b8e;
    --green-badge: #057a55;
    --green-badge-bg: #def7ec;
    --red-bg: #fff5f5;
    --red-text: #9b1c1c;
    --border-radius: 12px;
}

/* Escalamos la fuente base a 16px */
body { font-family: 'Segoe UI', system-ui, sans-serif; background-color: var(--bg-color); margin: 0; padding: 20px; color: var(--text-main); font-size: 16px; }

/* Expandimos el contenedor principal de 1000px a 1200px */
.container { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

/* --- COMPONENTES BASE --- */
.card { background: var(--card-bg); border-radius: var(--border-radius); padding: 24px; box-shadow: 0 4px 20px rgba(0,0,0,0.03); display: flex; flex-direction: column; justify-content: center; }
.badge { display: inline-block; background: var(--green-badge-bg); color: var(--green-badge); padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.badge.admin { background: #e1effe; color: #1e429f; }
.btn-volver { display: inline-block; padding: 10px 18px; background: white; border: 1px solid #d1d5db; border-radius: 8px; text-decoration: none; color: var(--text-main); font-weight: bold; margin-bottom: 10px; width: fit-content; transition: background 0.2s; }
.btn-volver:hover { background: #f9fafb; }

/* --- BOTONES GLOBALES Y FORMULARIOS --- */
.form-group { margin-bottom: 18px; }
label { display: block; margin-bottom: 8px; color: var(--primary); font-weight: bold; font-size: 15px; }
/* Inputs más altos y legibles */
input, select { width: 100%; padding: 14px; border: 1px solid #d1d5db; border-radius: 8px; background: #f9fafb; font-size: 16px; box-sizing: border-box; font-family: inherit; transition: border 0.3s; }
input:focus, select:focus { outline: none; border-color: var(--primary); background: white; }
input[readonly] { background: #e5e7eb; color: var(--text-muted); cursor: not-allowed; }
.btn-submit { width: 100%; padding: 16px; background-color: #3498db; color: white; border: none; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer; transition: background 0.3s; margin-top: 10px; }
.btn-submit:hover { background-color: #2980b9; }

/* --- ALERTAS --- */
.alert { padding: 14px; background: #d4edda; color: #155724; border-radius: 8px; margin-bottom: 18px; text-align: center; font-size: 15px; }
.alert-error { background-color: #f8d7da; color: #721c24; }

/* --- HEADER DE DASHBOARD --- */
.header-card { flex-direction: row; align-items: center; gap: 30px; padding: 30px; }
.logo-placeholder { width: 160px; height: auto; }
.header-info h1 { margin: 8px 0; font-size: 32px; color: var(--text-main); }
.header-info p { margin: 0; color: var(--text-muted); font-size: 16px; }

/* --- MENU DROPDOWN Y NAVEGACIÓN --- */
.top-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.date-display { color: var(--text-muted); font-size: 15px; font-weight: 500; }
.user-dropdown { position: relative; display: inline-block; padding-bottom: 15px; }
.dropdown-toggle { background: var(--card-bg); border: 1px solid #d1d5db; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 15px; display: flex; align-items: center; gap: 8px; transition: background 0.2s; }
.dropdown-toggle:hover { background: #f9fafb; }
.dropdown-menu { display: none; position: absolute; right: 0; top: 100%; background: white; min-width: 260px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); border-radius: 10px; z-index: 1000; border: 1px solid #e5e7eb; overflow: hidden; }
.user-dropdown:hover .dropdown-menu { display: block; }
.dropdown-header { padding: 18px; background: #f9fafb; border-bottom: 1px solid #e5e7eb; }
.dropdown-header strong { display: block; color: var(--text-main); font-size: 15px; }
.dropdown-header span { color: var(--text-muted); font-size: 13px; }
.dropdown-item { padding: 14px 18px; text-decoration: none; display: flex; align-items: center; gap: 12px; color: var(--text-main); font-size: 15px; transition: background 0.2s; }
.dropdown-item:hover { background-color: #f3f4f6; }
.dropdown-item.logout { color: var(--red-text); border-top: 1px solid #e5e7eb; }

/* --- CUERPO Y ESTRUCTURA DE PANTALLA COMPLETA --- */
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    color: var(--text-main);
    font-size: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Contenedor principal que empuja el footer hacia abajo si sobra espacio */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
}

/* --- PANTALLA LOGIN PERFECTAMENTE CENTRADA SIN SCROLL --- */
.login-box {
    max-width: 480px;
    width: 90%;
    margin: auto;
    padding: 35px 30px;
    box-sizing: border-box;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}
.login-box h2 {
    color: var(--primary);
    text-align: center;
    margin-bottom: 25px;
    font-size: 24px;
}

/* --- FOOTER CORPORATIVO GLOBAL --- */
.footer-proquimed {
    text-align: center;
    padding: 12px 0;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    width: 100%;
    flex-shrink: 0;
}

/* --- GRIDS DE FORMULARIOS Y TARJETAS --- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; margin-top: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* --- TARJETAS DE DASHBOARD --- */
.card.action { flex-direction: row; align-items: center; gap: 18px; transition: transform 0.2s ease; text-decoration: none; color: inherit; padding: 25px; }
.card.action:hover { transform: translateY(-3px); cursor: pointer; box-shadow: 0 8px 25px rgba(0,0,0,0.06); }
.icon-box { min-width: 55px; width: 55px; height: 55px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; background: #f3f4f6; flex-shrink: 0; }
.action-text { width: 100%; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.title-flex { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.title-flex strong { font-size: 16px; margin: 0; }
.notif-badge { background: #ef4444; color: white; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: bold; flex-shrink: 0; }
.action-text span { font-size: 13px; color: var(--text-muted); }

/* --- TABLAS RESPONSIVAS --- */
.table-responsive { width: 100%; overflow-x: auto; margin-top: 20px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 16px; text-align: left; border-bottom: 1px solid #f3f4f6; font-size: 15px; }
th { background-color: #f8f9fa; font-weight: bold; color: #6b7280; text-transform: uppercase; font-size: 13px; letter-spacing: 0.5px; }

/* --- NUEVO CORTE ESPECÍFICO --- */
.card-header-small { display: flex; align-items: center; gap: 25px; flex-direction: row; padding: 25px; }
.total-box { background: #f0f0fa; border-radius: 12px; padding: 25px; display: flex; justify-content: space-between; align-items: center; margin-top: 30px; margin-bottom: 20px;}
.total-box h3 { margin: 0; color: var(--primary); font-size: 22px; }
.total-amount { font-size: 28px; font-weight: bold; color: var(--primary); }
#loading-msg { display: none; color: #d97706; font-weight: bold; margin-top: 12px; font-size: 15px; }

/* --- VISOR DE AUDITORIA --- */
/* Nuevo contenedor de ancho completo (96%) exclusivo para auditoría */
.container-audit { max-width: 96%; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* Distribución 3 a 1 para darle prioridad al PDF */
.split-layout { display: grid; grid-template-columns: 3fr 1fr; gap: 25px; height: calc(100vh - 130px); min-height: 700px; }
@media (max-width: 768px) { .split-layout { grid-template-columns: 1fr; height: auto; } }

/* Barra superior agrupada como tarjeta */
.top-bar-audit { display: flex; align-items: center; gap: 20px; background: var(--card-bg); padding: 15px 25px; border-radius: var(--border-radius); box-shadow: 0 4px 15px rgba(0,0,0,0.03); margin-bottom: 5px; }
.top-bar-audit h2 { margin: 0; font-size: 20px; color: var(--primary); }

.pdf-container { background: white; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); overflow: hidden; min-height: 550px; }
iframe { width: 100%; height: 100%; border: none; }
.data-container { background: white; border-radius: 16px; padding: 30px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); overflow-y: auto; }
.data-row { display: flex; justify-content: space-between; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid #f3f4f6; }
.data-label { color: #6b7280; font-size: 15px; }
.data-val { font-weight: bold; font-size: 18px; }
.btn-aprobar { width: 100%; background: #057a55; color: white; padding: 18px; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: 25px; transition: background 0.3s; }
.btn-aprobar:hover { background: #046c4e; }

/* --- MODAL DE INACTIVIDAD DE SESIÓN --- */
#session-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
.session-modal-box {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.session-modal-box h3 { color: var(--primary); margin-top: 0; }
.session-modal-box p { color: var(--text-muted); font-size: 14px; margin-bottom: 25px; }
.session-btn-group { display: flex; gap: 10px; }
.btn-extend { background: #057a55; color: white; border: none; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; flex: 1; }
.btn-extend:hover { background: #046c4e; }
.btn-logout-modal { background: #e5e7eb; color: var(--text-main); border: none; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; flex: 1; }
.btn-logout-modal:hover { background: #d1d5db; }

/* --- FOOTER CORPORATIVO GLOBAL --- */
.footer-proquimed {
    text-align: center;
    padding: 15px 0 5px 0;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid #e5e7eb;
    margin-top: auto;
    width: 100%;
}

/* --- ALINEACIÓN A LA IZQUIERDA (EXCLUYENDO EL LOGIN) --- */
.card-header-small, 
.card:has(img):not(.login-box) {
    display: flex;
    align-items: center;
    gap: 25px;
    text-align: left !important;
    justify-content: flex-start !important;
}

.card-header-small img, 
.card:not(.login-box) img {
    margin: 0 !important;
}

/* --- RESTAURAR EL TAMAÑO Y DISEÑO ORIGINAL DEL LOGIN --- */
.login-box {
    max-width: 480px !important;
    width: 100% !important;
    margin: auto !important;
    padding: 45px 40px !important;
    text-align: center !important;
    display: block !important;
}

.login-box img {
    max-width: 140px !important;
    margin: 0 auto 20px auto !important;
    display: block !important;
}
/* --- CORRECCIÓN DEFINITIVA DE SEPARACIÓN EN TOTAL DECLARADO --- */
.total-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f4f5f7;
    padding: 18px 22px;
    border-radius: 12px;
    margin-top: 20px;
}

.total-box .data-label, 
.total-box span:first-child, 
.total-box h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

/* Forzamos un espacio limpio y separado para la cantidad numérica */
.total-box div, 
.total-box strong, 
.total-box span:last-child {
    font-size: 26px !important;
    font-weight: bold;
    color: var(--primary) !important;
    margin: 0 !important;
    margin-left: 20px !important; /* <--- Esto separa holgadamente el texto del número */
    white-space: nowrap;
}

/* =========================================
   FOOTER GLOBAL Y BOTÓN DE AYUDA
   ========================================= */
.footer-proquimed {
    width: 100%;
    padding: 15px 20px;
    box-sizing: border-box;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.footer-responsive-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
}

.footer-btn-container {
    justify-self: end;
}

.btn-manual {
    text-decoration: none;
    background: #e2e8f0;
    color: #334155;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s ease, color 0.2s ease;
}

.btn-manual:hover {
    background: #cbd5e1;
    color: #0f172a;
}

/* ESTILOS RESPONSIVOS PARA EL FOOTER (Celulares) */
@media (max-width: 768px) {
    .footer-responsive-grid {
        display: flex !important;
        flex-direction: column-reverse;
        gap: 12px;
        text-align: center;
    }
    .footer-btn-container {
        align-self: center !important;
    }
}