/* =========================================
   IMPORTACIÓN DE FUENTES (Estándar SaaS)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* =========================================
   VARIABLES DE COLOR GLOBAL
   ========================================= */
:root {
    --bg-app: #f4f7f6;        /* Fondo general de la app (Gris muy claro) */
    --bg-card: #ffffff;       /* Fondo de los módulos */
    --primary: #0f172a;       /* Pizarra oscuro (Casi negro) para botones y títulos */
    --accent: #2563eb;        /* Azul vibrante para resaltados y focus */
    --text-main: #334155;     /* Texto principal */
    --text-muted: #64748b;    /* Texto secundario/explicativo */
    --border: #e2e8f0;        /* Color de las líneas divisorias */
    --success: #10b981;       /* Verde para confirmaciones */
    --danger: #ef4444;        /* Rojo para errores */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* =========================================
   LAYOUT PRINCIPAL Y SIDEBAR INAMOVIBLE
   ========================================= */
body {
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: flex-start;
    padding: 0;
    margin: 0;
    height: 100vh;
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden; /* Evita el scroll global de la ventana */
}

.sidebar {
    width: 260px;
    min-width: 260px;
    background-color: #ffffff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--border);
}

.brand-logo {
    background: var(--primary);
    color: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.2rem;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-text strong { color: var(--primary); font-size: 0.95rem; }
.brand-text small { color: var(--text-muted); font-size: 0.8rem; }

.nav {
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav a {
    text-decoration: none;
    color: var(--text-main);
    padding: 10px 15px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 500;
}

.nav a:hover, .nav a .active {
    background-color: #f1f5f9;
    color: var(--accent);
}

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto; /* Permite hacer scroll vertical solo en el área de trabajo */
}

/* =========================================
   CONTENEDORES Y TEXTOS
   ========================================= */
.module-container {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 100%;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.module-container h2 {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

.module-container p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 30px;
}

hr {
    border: 0;
    height: 1px;
    background-color: var(--border);
    margin: 30px 0;
}

/* =========================================
   FORMULARIOS Y CONTROLES
   ========================================= */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
input[type="file"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #f8fafc;
    transition: all 0.2s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* =========================================
   BOTONES MODERNOS (SaaS Premium)
   ========================================= */
button {
    background: linear-gradient(135deg, var(--primary) 0%, #1e293b 100%);
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.2), 0 2px 4px -2px rgba(15, 23, 42, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.3), 0 4px 6px -4px rgba(15, 23, 42, 0.1);
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px -1px rgba(15, 23, 42, 0.2);
}

button:disabled {
    background: var(--text-muted) !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Botones específicos forzados (para evitar que queden blancos por la caché) */
#refresh-dashboard {
    background-color: #0f172a !important;
    background-image: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
    color: #ffffff !important;
    border: none;
}

#export-dashboard-btn {
    background-color: #107c41 !important;
    background-image: linear-gradient(135deg, #107c41 0%, #0c6334 100%) !important;
    color: #ffffff !important;
    border: none;
}

/* =========================================
   BARRA DE ACCIÓN, BUSCADOR Y FILTROS
   ========================================= */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: white;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

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

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    background: white;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin: 0;
    text-transform: none; 
    letter-spacing: normal;
}

.filter-toggle input { 
    width: 16px; 
    height: 16px; 
    cursor: pointer; 
}

/* =========================================
   TABLA ESTILO EXCEL (DASHBOARD) - FIX SCROLL
   ========================================= */
#dashboard-container {
    max-height: calc(100vh - 220px); /* La tabla ocupa el alto de la pantalla restante */
    overflow: auto; /* Habilita el scroll vertical y horizontal DENTRO de la tabla */
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background-color: white;
}

.excel-table {
    width: 100%;
    border-collapse: separate; /* Obligatorio para que funcione position: sticky sin bugs */
    border-spacing: 0;
    font-size: 0.85rem;
    background-color: white;
}

.excel-table th, .excel-table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid #cbd5e1;
    border-right: 1px solid #cbd5e1;
}

.excel-table th {
    background-color: #f8fafc;
    color: var(--primary);
    font-weight: 700;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 20; /* Elevado para evitar que el contenido se superponga */
    box-shadow: inset 0 -2px 0 #cbd5e1; /* Crea un borde inferior fuerte para la cabecera sticky */
}

/* Evitar bordes dobles a los costados */
.excel-table td:last-child, .excel-table th:last-child {
    border-right: none;
}

/* Alineación de las primeras dos columnas (Textos) */
.excel-table td:nth-child(1), .excel-table td:nth-child(2),
.excel-table th:nth-child(1), .excel-table th:nth-child(2) {
    text-align: left;
}

.excel-table tr:hover td {
    background-color: #f1f5f9;
}

.transit-badge {
    font-size: 0.7rem;
    color: #d97706;
    background: #fef3c7;
    padding: 2px 5px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: bold;
    display: inline-block;
}
/* =========================================
   CORRECCIÓN DE PESTAÑAS (TABS)
   ========================================= */
.tab-btn {
    color: #64748b !important;
    background: transparent !important;
    text-shadow: none !important;
}
.tab-btn:hover {
    color: #0f172a !important;
    background: #f1f5f9 !important;
}
.tab-btn.active {
    color: #2563eb !important;
    background: #eff6ff !important;
    border-bottom: 3px solid #2563eb !important;
}
