/* --- ESTILOS PERSONALIZADOS PARA LÍNEAS DIVISORIAS DE TABLAS --- */
/* Este archivo no será modificado en futuras actualizaciones. */

/* ====================================================================== */
/* =           1. LÍNEAS DIVISORIAS VERTICALES (SIN CAMBIOS)            = */
/* ====================================================================== */
/* Estas reglas ahora volverán a funcionar correctamente */
#detailed-logbook-container thead tr:first-child th:nth-child(3),
#detailed-logbook-container thead tr:first-child th:nth-child(4),
#detailed-logbook-container thead tr:first-child th:nth-child(5),
#detailed-logbook-container thead tr:first-child th:nth-child(6),
#detailed-logbook-container thead tr:first-child th:nth-child(7),
#detailed-logbook-container thead tr:first-child th:nth-child(8),
#detailed-logbook-container thead tr:first-child th:nth-child(9),
#detailed-logbook-container thead tr:first-child th:nth-child(10),
#detailed-logbook-container thead tr:first-child th:nth-child(11),
#detailed-logbook-container thead tr:first-child th:nth-child(12),
#detailed-logbook-container thead tr:last-child th:nth-child(2),
#detailed-logbook-container thead tr:last-child th:nth-child(10),
#detailed-logbook-container thead tr:last-child th:nth-child(12),
#detailed-logbook-container thead tr:last-child th:nth-child(15),
#detailed-logbook-container thead tr:last-child th:nth-child(17),
#detailed-logbook-container thead tr:last-child th:nth-child(24),
#detailed-logbook-container tbody td:nth-child(3),
#detailed-logbook-container tbody td:nth-child(5),
#detailed-logbook-container tbody td:nth-child(6),
#detailed-logbook-container tbody td:nth-child(14),
#detailed-logbook-container tbody td:nth-child(16),
#detailed-logbook-container tbody td:nth-child(19),
#detailed-logbook-container tbody td:nth-child(21),
#detailed-logbook-container tbody td:nth-child(28),
#detailed-logbook-container tbody td:nth-child(29),
#detailed-logbook-container tbody td:nth-child(30),
#flight-preview-container thead tr:first-child th:nth-child(3),
#flight-preview-container thead tr:first-child th:nth-child(4),
#flight-preview-container thead tr:first-child th:nth-child(5),
#flight-preview-container thead tr:first-child th:nth-child(6),
#flight-preview-container thead tr:first-child th:nth-child(7),
#flight-preview-container thead tr:first-child th:nth-child(8),
#flight-preview-container thead tr:first-child th:nth-child(9),
#flight-preview-container thead tr:first-child th:nth-child(10),
#flight-preview-container thead tr:first-child th:nth-child(11),
#flight-preview-container thead tr:last-child th:nth-child(2),
#flight-preview-container thead tr:last-child th:nth-child(10),
#flight-preview-container thead tr:last-child th:nth-child(12),
#flight-preview-container thead tr:last-child th:nth-child(15),
#flight-preview-container thead tr:last-child th:nth-child(17),
#flight-preview-container thead tr:last-child th:nth-child(24),
#flight-preview-container tbody td:nth-child(3),
#flight-preview-container tbody td:nth-child(5),
#flight-preview-container tbody td:nth-child(6),
#flight-preview-container tbody td:nth-child(14),
#flight-preview-container tbody td:nth-child(16),
#flight-preview-container tbody td:nth-child(19),
#flight-preview-container tbody td:nth-child(21),
#flight-preview-container tbody td:nth-child(28),
#flight-preview-container tbody td:nth-child(29),
#summary-by-page-container thead tr:first-child th:nth-child(1),
#summary-by-page-container thead tr:first-child th:nth-child(2),
#summary-by-page-container thead tr:first-child th:nth-child(3),
#summary-by-page-container thead tr:first-child th:nth-child(4),
#summary-by-page-container thead tr:first-child th:nth-child(5),
#summary-by-page-container thead tr:first-child th:nth-child(6),
#summary-by-page-container thead tr:first-child th:nth-child(7),
#summary-by-page-container tbody td:nth-child(1),
#summary-by-page-container tbody td:nth-child(2),
#summary-by-page-container tbody td:nth-child(10),
#summary-by-page-container tbody td:nth-child(12),
#summary-by-page-container tbody td:nth-child(15),
#summary-by-page-container tbody td:nth-child(17),
#summary-by-page-container tbody td:nth-child(24),
#summary-by-page-container thead tr:last-child th:nth-child(8),
#summary-by-page-container thead tr:last-child th:nth-child(10),
#summary-by-page-container thead tr:last-child th:nth-child(13),
#summary-by-page-container thead tr:last-child th:nth-child(15),
#summary-by-page-container thead tr:last-child th:nth-child(22) {
    border-right: 2px solid #606060;
}


/* ====================================================================== */
/* =           2. BORDES INFERIORES PARA TABLAS NO-STICKY               = */
/* ====================================================================== */

#flight-preview-container thead tr:last-child th,
#flight-preview-container thead tr:first-child th[rowspan],
#summary-by-page-container thead tr:last-child th,
#summary-by-page-container thead tr:first-child th[rowspan] {
    border-bottom: 2px solid #606060;
}


/* ====================================================================== */
/* =        3. SOLUCIÓN DEFINITIVA PARA TABLA STICKY (#detailed-logbook)    = */
/* ====================================================================== */

/* --- Configuración base para elementos STICKY --- */
#detailed-logbook-container thead { 
    position: sticky; 
    top: 0; 
    z-index: 10; 
}
#detailed-logbook-container tbody td:nth-child(1) { 
    position: sticky; 
    left: 0; 
    z-index: 5; 
}
#detailed-logbook-container thead tr:first-child th[rowspan] { 
    position: sticky; 
    left: 0; 
    z-index: 15; 
}
#detailed-logbook-container thead tr:first-child th:nth-child(1) { 
    z-index: 20; 
}

/* --- Fondos sólidos y preparación para pseudo-elementos --- */
#detailed-logbook-container thead th { 
    position: relative; /* CRÍTICO: Permite posicionar el ::after */
    background-color: #2a2a2a;
    /* LA CORRECCIÓN: Eliminamos SOLO el borde inferior para no destruir el derecho */
    border-bottom: none !important;
}
#detailed-logbook-container tbody td:nth-child(1) { 
    background-color: var(--surface-color); 
}
#detailed-logbook-container tbody tr:nth-child(even) td:nth-child(1) { 
    background-color: #242424; 
}

/* --- DIBUJAMOS LAS LÍNEAS HORIZONTALES CON PSEUDO-ELEMENTOS --- */

/* 1. Creamos una línea delgada por defecto en la parte inferior de TODAS las celdas del encabezado */
#detailed-logbook-container thead th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #606060;
}

/* 2. Hacemos que la línea sea GRUESA para las celdas que forman el borde final */
#detailed-logbook-container thead tr:last-child th::after,
#detailed-logbook-container thead tr:first-child th[rowspan]::after {
    height: 2px;
}

/* --- RESUMEN POR PÁGINA: ENCABEZADO Y COLUMNA FIJA --- */
.summary-page-table h3 { position: sticky; left: 0; padding-left: 1rem; margin-bottom: 0.5rem; margin-top: 1rem; background-color: var(--surface-color); width: fit-content; z-index: 40; }
#summary-by-page-container .sticky-col { position: sticky; left: 0; z-index: 20; font-weight: 600; background-color: #2a2a2a; }
#summary-by-page-container thead .sticky-col { z-index: 30; }

/* --- AJUSTE DE ANCHO PARA ENCABEZADOS DE TABLA LARGOS --- */
#detailed-logbook-container thead tr:last-child th:nth-child(18),
#detailed-logbook-container thead tr:last-child th:nth-child(21),
#flight-preview-container thead tr:last-child th:nth-child(18),
#flight-preview-container thead tr:last-child th:nth-child(21) {
    min-width: 120px;
}

/* --- CORRECCIÓN DE ESTILOS PARA MENÚ DESPLEGABLE --- */

#logbook-controls #sort-order-menu {
    /* Estilos que ya deberías tener, asegúrate de que estén */
    position: absolute;
    background-color: var(--surface-hover-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    z-index: 1100;
    right: 0;
    left: auto;
    
    /* --- INICIO DE LAS NUEVAS REGLAS --- */
    display: flex; /* Lo convertimos en un contenedor flex */
    flex-direction: column; /* Apila los elementos verticalmente */
    padding: 0.5rem 0; /* Añade un poco de espacio vertical interno */
    min-width: 200px; /* Le damos un ancho mínimo para que se vea bien */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Sombra para que destaque */
}

#logbook-controls #sort-order-menu .sort-option {
    /* Estilos para cada opción del menú */
    padding: 0.75rem 1.25rem;
    color: var(--text-color-light);
    text-decoration: none;
    white-space: nowrap; /* Evita que el texto se rompa en dos líneas */
    transition: background-color 0.2s;
}

#logbook-controls #sort-order-menu .sort-option:hover {
    background-color: var(--primary-color);
    color: var(--background-color);
}

#logbook-controls #sort-order-menu .sort-option.active {
    font-weight: 600;
    color: var(--primary-color);
    background-color: rgba(212, 175, 55, 0.1); /* Un fondo sutil para la opción activa */
}

/* ====================================================================== */
/* =           VALIDACIÓN DE FORMULARIO DE PERFIL                       = */
/* ====================================================================== */

.field-error {
    display: block;
    font-size: 11px;
    color: #ef4444;
    margin-top: 4px;
    line-height: 1.4;
}

.personal-data-item input.error,
.personal-data-item select.error {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.05);
}
/* ====================================================================== */
/* =           SISTEMA DE LICENCIAS Y HABILITACIONES                   = */
/* ====================================================================== */

.lic-sys { display: flex; flex-direction: column; gap: 20px; }

/* Sección */
.lic-section {
    background: #141414;
    border: 1px solid #222;
    border-radius: 8px;
    overflow: hidden;
}

.lic-section-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #c9a84c;
    padding: 10px 16px;
    background: #1a1710;
    border-bottom: 1px solid #2a2210;
}

.lic-section-body {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Fila de datos */
.lic-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px;
    background: #181818;
    border: 1px solid #252525;
    border-radius: 6px;
}

/* Campo */
.lic-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}

.lic-field.flex2 { flex: 2; }

.lic-field label {
    font-size: 11px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.lic-field input,
.lic-field select {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 7px 10px;
    color: #e2e8f0;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.lic-field input:focus,
.lic-field select:focus { border-color: #c9a84c; }

/* Botón eliminar */
.lic-remove {
    background: none;
    border: none;
    color: #444;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 4px;
    align-self: flex-end;
    margin-bottom: 1px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.lic-remove:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

/* Texto vacío */
.lic-empty {
    color: #444;
    font-size: 13px;
    font-style: italic;
    padding: 4px 0;
}

/* Botón agregar */
.lic-add-btn {
    background: transparent;
    border: 1px dashed #2a2a2a;
    color: #c9a84c;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
    width: 100%;
    margin-top: 4px;
}
.lic-add-btn:hover { border-color: #c9a84c50; background: #1a1710; }

@media (max-width: 600px) {
    .lic-row { flex-direction: column; }
    .lic-field { min-width: unset; width: 100%; }
    .lic-remove { align-self: flex-end; }
}

/* ====================================================================== */
/* =           LAYOUT DE CONFIGURACIÓN CON PANEL LATERAL               = */
/* ====================================================================== */

/* Layout principal */
.settings-layout {
    display: flex;
    gap: 0;
    min-height: 600px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.settings-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #0d0d0d;
    border-right: 1px solid #1a1a1a;
    padding: 20px 0;
}

.settings-sidebar-section {
    margin-bottom: 8px;
}

.settings-sidebar-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #3a3a3a;
    padding: 8px 20px 4px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 20px;
    font-size: 13px;
    color: #666;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    cursor: pointer;
    text-align: left;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.settings-nav-item:hover {
    color: #aaa;
    background: #141414;
}

.settings-nav-item.active {
    color: #c9a84c;
    background: #1a1710;
    border-left-color: #c9a84c;
}

.settings-nav-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Mobile tabs ───────────────────────────────────────────────────── */
.settings-tabs {
    display: none;
    overflow-x: auto;
    background: #0d0d0d;
    border-bottom: 1px solid #1a1a1a;
    padding: 0 8px;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }

.settings-tab-item {
    padding: 12px 14px;
    font-size: 12px;
    color: #555;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.settings-tab-item.active {
    color: #c9a84c;
    border-bottom-color: #c9a84c;
}

/* ── Content area ──────────────────────────────────────────────────── */
.settings-content {
    flex: 1;
    overflow-y: auto;
    min-width: 0;
}

/* ── Panels ────────────────────────────────────────────────────────── */
.settings-panel {
    display: none;
    padding: 28px 32px;
}

.settings-panel.active {
    display: block;
}

.settings-panel-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #1a1a1a;
}

.settings-panel-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px;
}

.settings-panel-header p {
    font-size: 13px;
    color: #555;
    margin: 0;
}

.settings-panel-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 20px;
    margin-top: 24px;
    border-top: 1px solid #1a1a1a;
}

/* ── Botones de configuración ──────────────────────────────────────── */
.settings-save-btn {
    width: auto !important;
    padding: 10px 24px !important;
}

.settings-btn-primary {
    background: #c9a84c;
    color: #000;
    border: none;
    border-radius: var(--border-radius);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
    text-align: left;
}
.settings-btn-primary:hover { opacity: 0.9; }

.settings-btn-success {
    background: #1e4a1e;
    color: #4a9a4a;
    border: 1px solid #2d6a2d;
    border-radius: var(--border-radius);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
    text-align: left;
}
.settings-btn-success:hover { background: #254a25; }

.settings-btn-secondary {
    background: transparent;
    color: #888;
    border: 1px solid #333;
    border-radius: var(--border-radius);
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    width: 100%;
    text-align: left;
}
.settings-btn-secondary:hover { border-color: #555; color: #ccc; }

.settings-btn-danger {
    background: transparent;
    color: #c05050;
    border: 1px solid #7a2020;
    border-radius: var(--border-radius);
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
    text-align: left;
}
.settings-btn-danger:hover { background: rgba(192,80,80,0.1); }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .settings-layout {
        flex-direction: column;
        min-height: unset;
    }
    .settings-sidebar {
        display: none;
    }
    .settings-tabs {
        display: flex;
    }
    .settings-panel {
        padding: 20px 16px;
    }
}