/* 
  Estilos Globales de Utilidades LATAM
  Optimizados para Single Page Application estática 
*/

:root {
    /* Paleta Corporativa LATAM */
    --latam-blue: #1A1A3A;      /* Azul índigo oscuro */
    --latam-blue-light: #2D2F7B;/* Azul para interactivos */
    --latam-red: #E8114B;       /* Rojo/Magenta corporativo */
    
    /* Colores UI Gerenales */
    --bg-page: #F3F5F8;         /* Gris muy sutil para fondo */
    --bg-white: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    
    /* Configuración de Layout */
    --sidebar-width: 260px;
    --topbar-height: 64px;
    
    /* Tipografía */
    --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-primary);
    background-color: var(--bg-page);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* -------------------------------------
   SHELL (Contenedor Principal)
   ------------------------------------- */
#app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* -------------------------------------
   SIDEBAR (Navegación Lateral)
   ------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--latam-blue);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 10;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.logo-badge {
    background-color: var(--latam-red);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.nav-links {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    color: #9CA3AF;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    gap: 12px;
}

.nav-item:hover {
    background-color: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background-color: var(--latam-blue-light);
    color: white;
    font-weight: 600;
    /* Indicador visual de activo */
    position: relative;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 4px;
    background-color: var(--latam-red);
    border-radius: 0 4px 4px 0;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item.active svg {
    opacity: 1;
    color: #fff;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    background: rgba(0,0,0,0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--latam-red) 0%, #ff4b72 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.85rem; font-weight: 600; color: #fff; }
.user-role { font-size: 0.75rem; color: #9CA3AF; }

/* -------------------------------------
   MAIN WRAPPER & TOPBAR
   ------------------------------------- */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 5;
}

.breadcrumb {
    font-size: 0.85rem;
    font-weight: 500;
}
.text-secondary { color: var(--text-secondary); }

.page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #F3F4F6;
    color: var(--latam-blue);
}

/* -------------------------------------
   CONTENIDO DINÁMICO (Inyectado)
   ------------------------------------- */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    position: relative;
}

.fade-in {
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.loader {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.loader::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--latam-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------
   COMPONENTES UI GLOBALES DE MOCKUPS
   ------------------------------------- */
.card {
    background: var(--bg-white);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02), 0 2px 4px -2px rgba(0,0,0,0.02);
    padding: 24px;
    margin-bottom: 24px;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Grillas */
.grid-cols-1 { display: grid; grid-template-columns: repeat(1, 1fr); gap: 24px; }
.grid-cols-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

@media (max-width: 1024px) {
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .grid-cols-2, .grid-cols-3 { grid-template-columns: 1fr; }
    .sidebar { position: absolute; transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); }
}

/* Badges / Etiquetas */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
}
.badge-success { background: #DCFCE7; color: #166534; }
.badge-warning { background: #FEF9C3; color: #854D0E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-info { background: #DBEAFE; color: #1E40AF; }

/* Tabla de Datos */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    background: #F9FAFB;
}

.data-table th:first-child { border-top-left-radius: 8px; }
.data-table th:last-child { border-top-right-radius: 8px; }

.data-table td {
    padding: 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background-color 0.15s; }
.data-table tbody tr:hover { background-color: #F9FAFB; }

/* -------------------------------------
   AIDX TIMELINE & MODULE STYLES
   ------------------------------------- */
.timeline-item {
    position: relative;
    padding-left: 1.5rem;
    border-left: 2px solid var(--border-color);
    padding-bottom: 1rem;
}
.timeline-item:last-child {
    border-left: 2px solid transparent;
}
.timeline-dot {
    position: absolute;
    left: -0.45rem;
    top: 0.25rem;
    height: 0.8rem;
    width: 0.8rem;
    border-radius: 50%;
    background-color: var(--text-secondary);
    border: 2px solid var(--bg-white);
    z-index: 10;
}

/* Timeline status colors */
.timeline-item.actual .timeline-dot { background-color: #16a34a; } 
.timeline-item.estimated .timeline-dot { background-color: #f59e0b; } 
.timeline-item.scheduled .timeline-dot { background-color: var(--latam-blue); } 
.timeline-item.pending .timeline-dot { background-color: #e5e7eb; border-color: #f3f4f6; } 

.timeline-item.pending {
    border-left-style: dashed;
    opacity: 0.7;
}

/* Flight Progress plane positioning */
.aidx-plane-icon {
    position: absolute;
    top: 50%;
    background: var(--bg-white);
    color: var(--latam-blue);
    padding: 4px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    font-size: 1.2rem;
    transition: all 0.8s ease-in-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 10;
}

/* Position helper classes */
.pos-origin { left: 0%; transform: translate(-50%, -50%); }
.pos-flying { left: 50%; transform: translate(-50%, -50%); }
.pos-dest { left: 100%; transform: translate(-50%, -50%); }

/* Two-column layout for AIDX Module using Grid */
.aidx-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}
@media (min-width: 1024px) {
    .aidx-layout {
        grid-template-columns: 4fr 7fr;
    }
}
