/* ==========================================================
 * HOJA DE ESTILOS PARA LA PÁGINA DE USUARIOS (users.html)
 * Versión 3.1 - Arquitectura Modular y Correcciones de Layout
 * ==========================================================
 * ÍNDICE DE CONTENIDO:
 * ----------------------------------------------------------
 * PARTE 1: FUNDAMENTOS Y LOGIN
 * 1.0 Estilos Generales de la Página
 * 1.1 Sección de Login y Formularios
 * 1.2 Estilos para Componentes de Formulario (inputs, botones)
 
 * PARTE 2: ESTRUCTURA Y COMPONENTES DEL DASHBOARD
 * 2.0 Layout Principal del Dashboard (Grid y Header)
 * 2.1 Barra Lateral de Pestañas (Tabs)
 * 2.2 Contenedores de Contenido de Pestañas
 * 2.3 Componentes Reutilizables (KPIs, Tablas, Botones)
 * 2.4 Estilos Específicos (Listas, Historial, Calendario)
 * 2.5 Estilos del Calendario y Tipos de Evento
 
 * PARTE 3: PANELES ESPECIALIZADOS Y RESPONSIVIDAD
 * 3.0 Pestañas Anidadas (Detalles del Conductor)
 * 3.1 Paneles de Análisis (KPIs Clickeables, Desglose)
 * 3.2 Gestión de Personal (Calculadora de Sueldo, Desglose)
 * 3.3 Paneles Desplegables (Acordeón)
 * 3.4 Interfaz de Selección Múltiple (Píldoras y Checkboxes)
 * 3.5 Diseño Responsivo (Media Queries)
 * 3.6 Estilos del Modal de Billetera
 * 3.7: ESTILOS DEL BOTÓN DE DEVOLUCIÓN (CONDUCTOR)

 * PARTE 4: ESTILOS DE AUDITORÍA (V4.0)
 * 4.1 ÍCONO DE LA PESTAÑA DE AUDITORÍA
 * 4.2 ESTILOS PARA LOS BADGES DE ACCIÓN EN LA TABLA
 * 4.3 ESTILOS PARA EL SCROLL DE LA TABLA (¡NUEVO!)

 * PARTE 5: ESTILOS DEL MENÚ AGRUPADO (V5.3) (¡NUEVO!)
 

/* ==========================================================
 * PARTE 1: FUNDAMENTOS Y LOGIN
 * ========================================================== */

/* 1.0 ESTILOS GENERALES DE LA PÁGINA */
.user-access-main {
    max-width: 1200px; /* Ampliamos para el dashboard */
    margin: 0 auto;
    padding: 0 15px;
    padding-top: 30px;
}

/* 1.1 SECCIÓN DE LOGIN Y FORMULARIOS */
#login-section {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    background-color: #fff;
    text-align: center;
}

#login-section h2 {
    color: #1e3a8a;
    margin-bottom: 25px;
    border-bottom: none;
    padding-bottom: 0;
    font-size: 2em;
}

#login-form .form-group {
    margin-bottom: 20px;
    text-align: left;
}

#login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

#login-form input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1.1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#login-form input:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* 1.2 ESTILOS PARA COMPONENTES DE FORMULARIO */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 15px;
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.2s ease;
}

.toggle-password:hover {
    color: #1e3a8a;
}

#login-form button {
    background-color: #d97706;
    color: #fff;
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease-in-out;
    width: 100%;
    margin-top: 15px;
}

#login-form button:hover {
    background-color: #b45309;
    transform: translateY(-2px);
}

.form-message {
    margin-top: 15px;
    font-size: 0.95em;
    font-weight: bold;
}

/* ==========================================================
 * PARTE 2: ESTRUCTURA Y COMPONENTES DEL DASHBOARD
 * ========================================================== */

/* 2.0 LAYOUT PRINCIPAL DEL DASHBOARD */
#dashboard-section {
    width: 100%;
    background-color: transparent;
    box-shadow: none;
    padding: 0;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background-color: #fff;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
}

/* --- ▼▼▼ CORRECCIÓN ESTRUCTURAL CLAVE (Bug #80, regresión de Bug #15) ▼▼▼ --- */
#admin-view, #conductor-view {
    display: grid;
    grid-template-columns: 240px 1fr; 
    gap: 2rem;
    
    /* --- ¡ESTA LÍNEA ES LA CULPABLE! --- */
    /* ¡Comenta o elimina la línea de abajo! */
    /* align-items: start; */ 
    /* --- FIN DE LA LÍNEA CULPABLE --- */

    position: relative; 
    z-index: 1;
}


/* NUEVA REGLA: Contenedor para todo el contenido derecho del admin */
.admin-content-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Previene bugs de overflow en layout de grilla */
}

.admin-view-header {
    padding: 1rem 1.5rem;
    background-color: #1f2937;
    color: #ffffff;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

.admin-view-header h3 {
    margin: 0;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 10px;
}
/* --- ▲▲▲ FIN DE LA CORRECCIÓN ▲▲▲ --- */


/* 2.1 BARRA LATERAL DE PESTAÑAS (TABS) */
/* (A) Estilos comunes para AMBAS barras laterales (admin y conductor) */
#admin-view .tabs, #conductor-view .tabs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: #1f2937;
    padding: 1rem;
    border-radius: 0.75rem;
    position: -webkit-sticky; /* Para compatibilidad con Safari */
    position: sticky;
    top: 100px; /* Espacio desde el header principal fijo. */
    align-self: start; /* Previene que la barra lateral se estire */
}


.tabs .tab-link {
    width: 100%;
    padding: 0.8rem 1.2rem;
    border: none;
    background-color: transparent;
    color: #d1d5db;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tabs .tab-link:hover {
    background-color: #374151;
    color: #ffffff;
}

.tabs .tab-link.active {
    background-color: #3b82f6;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Iconos para la Barra Lateral */
.tab-link[data-tab="admin-resumen-tab"]::before { content: "\f080"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="admin-clientes-tab"]::before { content: "\f0c0"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="admin-conductores-tab"]::before { content: "\f4df"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="admin-trabajadores-tab"]::before { content: "\f522"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="admin-contratos-tab"]::before { content: "\f56c"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="admin-servicios-tab"]::before { content: "\f784"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="admin-gastos-tab"]::before { content: "\f53a"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="admin-mecanica-tab"]::before { content: "\f0ad"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="calendar-tab"]::before { content: "\f073"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.tab-link[data-tab="expenses-tab"]::before { content: "\f543"; font-family: "Font Awesome 6 Free"; font-weight: 900; }


/* 2.2 CONTENEDORES DE CONTENIDO DE PESTAÑAS */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    background-color: #ffffff;
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    position: relative; /* <--- AÑADE ESTA LÍNEA */
    z-index: 2;         /* <--- Y AÑADE ESTA LÍNEA */
}

/* 2.3 COMPONENTES REUTILIZABLES (KPIs, Tablas, Botones) */
/* --- ▼▼▼ CORRECCIÓN CLAVE: Forzar una sola columna vertical ▼▼▼ --- */
.management-grid {
    display: grid;
    grid-template-columns: 1fr; /* Siempre será una sola columna */
    gap: 2rem;
}
/* --- ▲▲▲ FIN DE LA CORRECCIÓN ▲▲▲ --- */

input, select, textarea { width: 100%; padding: 0.75rem; border: 1px solid #d1d5db; border-radius: 0.5rem; font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }
.kpi-card { background-color: #f9fafb; border: 1px solid #e5e7eb; padding: 1.5rem; border-radius: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.kpi-title { font-size: 0.9rem; font-weight: 600; color: #4b5563; }
.kpi-value { font-size: 2rem; font-weight: 700; color: #111827; }
.kpi-card.revenue { border-left: 5px solid #28a745; }
.kpi-card.expenses { border-left: 5px solid #dc3545; }
.kpi-card.profit { border-left: 5px solid #3b82f6; }
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid #e5e7eb; }
thead th { font-weight: 600; color: #4b5563; background-color: #f9fafb; }
tbody tr:hover { background-color: #f3f4f6; }
.status-badge { padding: 3px 10px; border-radius: 15px; font-size: 0.8em; font-weight: bold; text-transform: capitalize; }
.status-badge.status-activo { background-color: #c8e6c9; color: #2e7d32; }
.status-badge.status-inactivo { background-color: #e0e0e0; color: #616161; }
.action-btn { background-color: #3b82f6; color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; font-size: 0.9em; transition: background-color 0.2s; }
.action-btn:hover { background-color: #2563eb; }
.action-btn.secondary-btn { background-color: #6c757d; }
.action-btn.secondary-btn:hover { background-color: #5a6268; }
.delete-btn { background-color: #ef4444; }
.delete-btn:hover { background-color: #dc2626; }

/* 2.4 ESTILOS ESPECÍFICOS (Listas, Historial, Calendario) */
.driver-list { list-style: none; padding: 0; margin-top: 20px; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
.driver-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; border-bottom: 1px solid #e5e7eb; }
.driver-item:last-child { border-bottom: none; }
.driver-item:hover { background-color: #f9f9f9; }
.driver-item span { font-weight: 600; }
.driver-item .actions { display: flex; gap: 10px; }
.history-item { background-color: #fdfdfd; border: 1px solid #e0e0e0; border-left: 5px solid #6c757d; padding: 15px; border-radius: 5px; margin-bottom: 10px; }
.history-summary { cursor: pointer; }
.history-details { display: none; padding: 15px; margin-top: 10px; border-top: 1px solid #ddd; background-color: #fff; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 20px; font-size: 0.9em; justify-content: center; }
.calendar-legend div { display: flex; align-items: center; gap: 8px; }
.day-cell-legend { width: 15px; height: 15px; border-radius: 3px; display: inline-block; }
.day-cell-legend.work { background-color: #ffcdd2; border: 1px solid #ef9a9a; }
.day-cell-legend.off { background-color: #c8e6c9; border: 1px solid #a5d6a7; }
.day-cell-legend.event-dot { background-color: black; border-radius: 50%; width: 8px; height: 8px; }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.calendar-header button { background-color: #3b82f6; color: white; border: none; border-radius: 50%; width: 40px; height: 40px; font-size: 1.2em; cursor: pointer; transition: background-color 0.2s; }
.calendar-header button:hover { background-color: #2563eb; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day-header { font-weight: bold; text-align: center; padding-bottom: 5px; color: #555; }
.day-cell { display: flex; justify-content: center; align-items: center; height: 40px; border-radius: 4px; font-weight: 600; transition: transform 0.2s ease; position: relative; cursor: pointer; transform: translateZ(0); }
.day-cell.work { background-color: #ffcdd2; color: #c62828; }
.day-cell.off { background-color: #c8e6c9; color: #2e7d32; }
.day-cell:hover { transform: scale(1.1); box-shadow: 0 2px 8px rgba(0,0,0,0.2); z-index: 10; }
.day-cell.has-event::after { content: ''; position: absolute; bottom: 4px; right: 4px; width: 8px; height: 8px; background-color: #333; border-radius: 50%; }

/* * PARTE 2.5: ESTILOS DEL CALENDARIO Y TIPOS DE EVENTO */

/* <--- ¡CORRECCIÓN VISUAL #2! ---> */


/* Ahora, en lugar de colorear el fondo, coloreamos el "puntito" */
.day-cell[data-event-type="event-vacaciones"]::after {
    background-color: #3b82f6; /* ¡Tu color azul! */
}

.day-cell.event-vacaciones {
    /* Se eliminan todos los estilos de fondo, color y borde */
    background-color: transparent;
    color: inherit;
    border: none;
}

.day-cell[data-event-type="event-licencia"]::after {
    background-color: #f59e0b; /* Un color naranja/amarillo */
}

.day-cell.event-licencia {
    /* Se eliminan todos los estilos de fondo, color y borde */
    background-color: transparent;
    color: inherit;
    border: none;
}






/* ==========================================================
 * PARTE 3: PANELES ESPECIALIZADOS Y RESPONSIVIDAD
 * ========================================================== */

/* 3.0 PESTAÑAS ANIDADAS (DETALLES DEL CONDUCTOR) */
#admin-driver-details-view .tabs {
    flex-direction: row; /* Las pestañas anidadas son horizontales */
    border-radius: 0.75rem 0.75rem 0 0;
    position: -webkit-sticky;
    position: sticky;
    top: var(--header-height-desktop); /* Usa la variable del header para el espaciado */
    z-index: 10;
    background-color: #f9fafb; /* Fondo gris claro para diferenciar */
    border-bottom: 1px solid #e5e7eb;
}

#admin-driver-details-view .tabs .tab-link {
    color: #4b5563;
    background-color: transparent;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    font-weight: bold;
}

#admin-driver-details-view .tabs .tab-link:hover {
    background-color: #f3f4f6;
    color: #111827;
    border-bottom-color: #d1d5db;
}

#admin-driver-details-view .tabs .tab-link.active {
    color: #3b82f6;
    background-color: #ffffff;
    font-weight: 600;
    border-bottom-color: #3b82f6;
    box-shadow: none; /* Quitamos la sombra que no aplica aquí */
}

/* 3.1 PANELES DE ANÁLISIS (KPIs Clickeables, Desglose) */
.kpi-clickable {
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.kpi-clickable:hover {
    background-color: #eef2ff; /* Un azul muy claro */
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.analisis-breakdown {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
    text-align: left;
    font-size: 1rem;
}

.analisis-breakdown li {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.analisis-breakdown li:last-child {
    border-bottom: none;
}

.analisis-breakdown li span:first-child {
    color: #4b5563; /* Gris oscuro para la descripción */
}

.analisis-breakdown li span:last-child {
    font-weight: 600;
    color: #111827; /* Negro para el valor */
}

.analisis-breakdown li.total {
    font-size: 1.1rem;
    font-weight: bold;
    color: #1e3a8a; /* Azul primario para el total */
    padding-top: 1rem;
    border-top: 2px solid #9ca3af;
}

.info-message {
    background-color: #eef2ff;
    color: #4338ca;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #c7d2fe;
    text-align: center;
}

/* ===> ¡NUEVAS REGLAS PARA MEJORAR LA ESTÉTICA! <=== */
#dashboard-operational-kpi-container {
    border-top: 1px solid #e5e7eb;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

#dashboard-operational-kpi-container .kpi-card {
    padding: 1rem; /* Reducimos el espaciado interno */
}

#dashboard-operational-kpi-container .kpi-title {
    font-size: 0.85rem; /* Hacemos el título un poco más pequeño */
}

#dashboard-operational-kpi-container .kpi-value.small-text {
    font-size: 1.2rem; /* Reducimos significativamente el tamaño del texto largo */
    line-height: 1.3;  /* Damos un poco de espacio si el texto ocupa dos líneas */
    word-wrap: break-word; /* Aseguramos que el texto se corte si es muy largo */
}
/* ===> FIN DE LAS NUEVAS REGLAS <=== */

/* 3.2 GESTIÓN DE PERSONAL (Calculadora, Desglose) */
.salary-calculator {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.input-with-button {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-with-button input {
    flex-grow: 1;
}

.input-with-button button {
    flex-shrink: 0;
    white-space: nowrap;
}

.empleado-row-clickable {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.empleado-row-clickable:hover {
    background-color: #eff6ff;
}

.desglose-row td {
    padding: 0 !important;
    background-color: #f9fafb;
    border-top: 2px solid #3b82f6;
}

.desglose-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
}

@media (min-width: 768px) {
    .desglose-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.desglose-columna h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1em;
    color: #111827;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.desglose-columna table {
    width: 100%;
    font-size: 0.9em;
}

.desglose-columna table td {
    padding: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.desglose-columna table .valor {
    text-align: right;
    font-weight: 600;
    font-family: monospace;
}

.desglose-columna table .total {
    font-weight: bold;
    color: #111827;
    border-top: 2px solid #e5e7eb;
}

/* 3.3 PANELES DESPLEGABLES (ACORDEÓN) */
.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out, padding 0.5s ease-in-out;
    padding-top: 0;
    padding-bottom: 0;
}

.collapsible-content.active {
    max-height: 2000px;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.toggle-button {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-button::after {
    content: '\25BC';
    font-size: 0.8em;
    transition: transform 0.3s ease;
    margin-left: 10px;
}

.toggle-button.active::after {
    transform: rotate(180deg);
}

/* 3.4 INTERFAZ DE SELECCIÓN MÚLTIPLE (PÍLDORAS Y CHECKBOXES) */
.association-section { background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 0.75rem; padding: 1.5rem; margin-top: 1.5rem; }
.association-section h4 { margin-top: 0; margin-bottom: 1rem; font-size: 1.1em; color: #1f2937; }
.multiselect-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-bottom: 1rem; }
@media (min-width: 768px) { .multiselect-grid { grid-template-columns: 1fr 1fr; } }
.multiselect-column label { font-weight: 600; display: block; margin-bottom: 0.5rem; }
.multiselect-dropdown.static { position: static; border: 1px solid #d1d5db; border-radius: 0.5rem; max-height: 180px; overflow-y: auto; background-color: #fff; }
.multiselect-dropdown ul { list-style: none; padding: 0; margin: 0; }
.multiselect-dropdown li { padding: 0.75rem; cursor: pointer; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #f3f4f6; }
.multiselect-dropdown li:last-child { border-bottom: none; }
.multiselect-dropdown li:hover { background-color: #f3f4f6; }
.multiselect-dropdown input[type="checkbox"] { width: auto; cursor: pointer; flex-shrink: 0; }
.multiselect-dropdown label { margin-bottom: 0; font-weight: normal; cursor: pointer; }
.selected-pills-container { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid #d1d5db; border-radius: 0.5rem; margin-top: 0.5rem; background-color: #fff; min-height: 42px; }
.contract-pill { background-color: #e0e7ff; color: #3730a3; padding: 4px 10px; border-radius: 15px; font-size: 0.85em; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.remove-pill-btn { background: none; border: none; color: #4f46e5; cursor: pointer; font-size: 1.1em; padding: 0; line-height: 1; }
.remove-pill-btn:hover { color: #3730a3; }
.details-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid #e5e7eb; }
.details-header h4 { margin: 0; }
.details-filters form { display: flex; align-items: center; gap: 0.5rem; }
.details-filters select, .details-filters input { padding: 6px 10px; font-size: 0.9em; flex-grow: 0; flex-shrink: 0; }
.details-filters select { width: 130px; }
.details-filters input[type="number"] { width: 90px; }

/* 3.5 DISEÑO RESPONSIVO */
@media (max-width: 900px) {
    #admin-view, #conductor-view { grid-template-columns: 1fr; }
    #admin-view .tabs, #conductor-view .tabs { flex-direction: row; overflow-x: auto; position: static; border-radius: 0.75rem 0.75rem 0 0; }
    .tabs .tab-link { white-space: nowrap; }
    .tab-content.active { border-radius: 0 0 0.75rem 0.75rem; }
    #admin-driver-details-view .tabs { top: var(--header-height-mobile); }
}

/* ========================================================== */
/* ESTILOS PARA EL NUEVO MODAL DE DESGLOSE DE DATOS (BOLETA)  */
/* ========================================================== */

/* Hacemos el modal más ancho para que la tabla quepa cómodamente */
.modal-content.large {
    max-width: 800px; 
}

/* El cuerpo del modal donde irá la tabla */
#details-modal-body {
    max-height: 60vh; /* Altura máxima para evitar que sea muy largo */
    overflow-y: auto; /* Añade una barra de scroll vertical si el contenido es muy largo */
    text-align: left; /* Alineamos el texto de la tabla a la izquierda */
}

#details-modal-body table {
    margin-top: 1rem;
}


/* --- Estilos para la Billetera del Conductor --- */
.wallet-container {
    background-color: #eef2ff; /* Un azul muy claro */
    border: 1px solid #c7d2fe;
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.wallet-container h4 {
    margin: 0 0 0.5rem 0;
    color: #4338ca;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.wallet-balance {
    font-size: 2.2em;
    font-weight: 700;
    color: #3730a3;
    margin: 0;
    line-height: 1.2;
}

.wallet-balance.negative {
    color: #dc2626; /* Rojo para saldos negativos */
}

/* ==========================================================
 * PARTE 3.6: ESTILOS DEL MODAL DE BILLETERA
 * ========================================================== */

 .wallet-container {
    background-color: #eef2ff; /* Un azul muy claro */
    border: 1px solid #c7d2fe;
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.wallet-container h4 {
    margin: 0 0 0.5rem 0;
    color: #4338ca;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.wallet-balance {
    font-size: 2.2em;
    font-weight: 700;
    color: #3730a3;
    margin: 0;
    line-height: 1.2;
}

.wallet-balance.negative {
    color: #dc2626; /* Rojo para saldos negativos */
}

/* Estilos para la tabla de historial (la "cartola") */
#wallet-history-container {
    max-height: 400px; /* Le da un alto máximo para que no sea infinita */
    overflow-y: auto; /* Añade una barra de scroll si el contenido es muy largo */
}

#wallet-history-container table .valor {
    text-align: right;
    font-weight: bold;
    font-family: monospace; /* Fuente especial para números */
}

#wallet-history-container .ingreso-row .valor {
    color: #16a34a; /* Verde para los ingresos/abonos */
}
#wallet-history-container .ingreso-row .valor::before {
    content: '+ '; /* Añade un "+" antes del monto */
}

#wallet-history-container .gasto-row .valor {
    color: #dc2626; /* Rojo para los gastos/retiros */
}

/* ==========================================================
 * PARTE 3.7: ESTILOS DEL BOTÓN DE DEVOLUCIÓN (CONDUCTOR)
 * ========================================================== */

/*
 * Modificamos el .wallet-container para que sea flexible
 * y pueda alinear el nuevo botón.
 */
 .wallet-container {
    display: flex;
    flex-wrap: wrap; /* Para que se apile en pantallas pequeñas */
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.wallet-info {
    flex-grow: 1; /* Ocupa el espacio disponible */
    text-align: left; /* Alineamos el texto del saldo a la izquierda */
}

/* * Re-ajustamos los estilos de la billetera que
 * estaban pensados para estar centrados.
 */
.wallet-container h4 {
    justify-content: flex-start; /* Alinea el ícono y texto a la izquierda */
    margin-bottom: 0.25rem;
}

.wallet-balance {
    text-align: left; /* Alinea el monto a la izquierda */
}

.wallet-actions {
    flex-shrink: 0; /* Evita que el botón se encoja */
}

/* Estilo para el nuevo botón de devolución */
#open-devolucion-modal-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9em;
    padding: 0.8rem 1.2rem; /* Lo hacemos un poco más grande */
}

/* ==========================================================
 * PARTE 4: ESTILOS DE AUDITORÍA (V4.0)
 * ========================================================== */

/* 4.1 ÍCONO DE LA PESTAÑA DE AUDITORÍA */
.tab-link[data-tab="admin-auditoria-tab"]::before { 
    content: "\f02d"; /* Ícono de "libro" (fa-book) */
    font-family: "Font Awesome 6 Free"; 
    font-weight: 900; 
}

/* 4.2 ESTILOS PARA LOS BADGES DE ACCIÓN EN LA TABLA */
.audit-action-crear {
    background-color: #dcfce7; /* Verde claro */
    color: #166534;
}
.audit-action-modificar {
    background-color: #ffedd5; /* Naranja claro */
    color: #9a3412;
}
.audit-action-eliminar {
    background-color: #fee2e2; /* Rojo claro */
    color: #991b1b;
}
.audit-action-denegado {
    background-color: #fee2e2; /* Rojo claro */
    color: #991b1b;
}
.audit-action-login {
    background-color: #e0e7ff; /* Azul claro */
    color: #3730a3;
}
.audit-action-default {
    background-color: #e5e7eb; /* Gris claro */
    color: #374151;
}

/* ==========================================================
 * PARTE 4.3: ESTILOS PARA EL SCROLL DE LA TABLA (¡NUEVO!)
 * ========================================================== */
.audit-scroll-container {
    max-height: 70vh; /* Altura máxima (70% de la ventana) */
    overflow-y: auto; /* ¡Esta es la "barrita" (scroll vertical)! */
    
    /* Estilos para que se vea bien contenido */
    border: 1px solid #e5e7eb;
    border-radius: 0 0 0.5rem 0.5rem; /* Bordes redondeados solo abajo */
    border-top: none; /* La cabecera de la tabla será el borde superior */
}

/* Ajuste para que el 'overflow-x' original no entre en conflicto */
.audit-scroll-container.table-container {
    overflow-x: auto; /* Mantenemos el scroll horizontal si es necesario */
}

/* * Cabecera "Pegajosa" (Sticky Header)
 * Esto hace que el <thead> se quede fijo arriba mientras haces scroll
 */
.audit-scroll-container thead th {
   position: -webkit-sticky; /* Para Safari */
   position: sticky;
   top: 0;
   z-index: 10;
   /* La clase 'thead th' ya tiene un 'background-color: #f9fafb;' 
      así que funcionará perfecto para tapar el contenido de abajo. */
}

/* ==========================================================
 * PARTE 5: ESTILOS DEL MENÚ AGRUPADO (V5.3) (¡NUEVO!)
 * ========================================================== */

/* (A) El botón principal del grupo (ej. "Gestión Operativa") */
.tab-group-toggle {
    /* Copiamos los estilos de .tab-link para que se vea igual */
    width: 100%;
    padding: 0.8rem 1.2rem;
    border: none;
    background-color: transparent;
    color: #d1d5db;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 0.75rem;

    /* Estilo único: alinea la flecha a la derecha */
    justify-content: space-between; 
}

.tab-group-toggle:hover {
    background-color: #374151;
    color: #ffffff;
}

/* (B) El sub-menú (contenedor de los links internos) */
.tab-submenu {
    /* Oculto por defecto */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out;

    /* Estilo de indentación */
    margin: 0 0 0.5rem 0; /* Espacio después del grupo, antes del siguiente botón */
    padding-left: 0.5rem; /* Indentación del bloque de sub-menú */
    background-color: rgba(255, 255, 255, 0.03); /* Fondo muy sutil */
    border-radius: 0.5rem;
}

/* (C) El sub-menú CUANDO ESTÁ ACTIVO (abierto) */
.tab-submenu.active {
    max-height: 500px; /* Altura máxima para la animación de apertura */
}

/* (D) La flecha (<i>) dentro del botón del grupo */
.group-arrow {
    transition: transform 0.3s ease-in-out;
    font-size: 0.8em;
}

/* (E) La flecha CUANDO ESTÁ ACTIVA (abierta) */
.tab-group-toggle.active .group-arrow {
    transform: rotate(180deg);
}

/* (F) Los links DENTRO del sub-menú (ej. "Clientes") */
.tab-submenu .tab-link {
    font-size: 0.9rem; /* Un poco más pequeños */
    padding-left: 1.5rem; /* Más indentación para jerarquía */
    /* Usamos el mismo color que el toggle para consistencia */
    color: #d1d5db; 
}

/* (G) El link del sub-menú CUANDO ESTÁ ACTIVO */
/* Lo pintamos del color azul principal, igual que un botón normal */
.tab-submenu .tab-link.active {
    background-color: #3b82f6;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* (H) El botón del grupo (ej. "Gestión Operativa") 
 * CUANDO un link DENTRO de él está activo.
 * (Así el grupo se queda resaltado en blanco)
 */
.tab-group-toggle.active-group {
    color: #ffffff; /* Texto blanco más brillante */
    font-weight: 600;
}