/* ============================================================
   ECONATOURS TITANIUM UI v10.4.0 
   MASTER SCROLL, LAYER FIX & DESKTOP ENTERPRISE LAYOUT
   Optimizado para: iOS Safe Areas, Modal Priority & Escritorio
   ============================================================ */

:root {
    /* Paleta Titanium Premium */
    --eco-blue-dark: #1e3a8a;
    --eco-blue-light: #3b82f6;
    --eco-sidebar-bg: #0f172a;
    --eco-success: #10b981;
    --eco-danger: #ef4444;
    --eco-warning: #f59e0b;
    --eco-gray-soft: #64748b;
    --eco-bg: #f4f7fe; 
    --card-bg: #ffffff;
    --nav-height: 72px;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Tipografía */
    --eco-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* =====================================================
   1. BLINDAJE DEL BODY (Anti-Rebote System) 
   ===================================================== */
body:has(#eco-app-shell) {
    background-color: var(--eco-bg) !important;
    margin: 0 !important;
    padding: 0 !important;
    position: fixed !important; 
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important; 
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
}

/* =====================================================
   2. CONTENEDOR MAESTRO (App Shell) 
   ===================================================== */
#eco-app-shell {
    position: fixed !important; 
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; 
    flex-direction: column; /* Móvil por defecto */
    z-index: 99999;
    background: var(--eco-bg);
    font-family: var(--eco-font);
}

/* =====================================================
   3. ELEMENTOS MÓVILES POR DEFECTO 
   ===================================================== */
.eco-header {
    flex-shrink: 0 !important;
    background: #ffffff;
    padding: 0 20px;
    height: 72px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
}

.eco-brand { font-size:18px; font-weight:900; color:var(--eco-blue-dark); }
.eco-user { font-size:13px; font-weight:700; color:#334155; display: flex; align-items: center; gap: 8px;}

/* Sidebar y Header Desktop ocultos en móvil */
.eco-sidebar { display: none; }
.eco-header-desktop { display: none; }

.eco-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.eco-main-viewport, .eco-main-content, .eco-main {
    flex: 1 !important; 
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important; 
    position: relative;
}

#eco-dynamic-content {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important; 
    padding: 15px 15px 140px 15px; 
    background: var(--eco-bg);
}

/* Navbar Inferior Móvil */
.eco-manager-menu {
    flex-shrink: 0 !important;
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #e2e8f0;
    z-index: 5000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    text-decoration: none;
    background: none;
    border: none;
    font-weight: 800;
    font-size: 10px;
    transition: 0.2s;
    gap: 4px;
    cursor: pointer;
}

.nav-item.active { color: var(--eco-blue-dark); }
.nav-item span { font-size: 11px; }

/* Botón Flotante Móvil */
.eco-fab-add {
    position: fixed;
    bottom: calc(var(--nav-height) + 25px + env(safe-area-inset-bottom));
    right: 20px;
    width: 60px; height: 60px;
    background: var(--eco-blue-dark);
    color: white;
    border-radius: 50%;
    border: none;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 25px rgba(30, 58, 138, 0.4);
    z-index: 6000;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.eco-fab-add:active { transform: scale(0.85); }

/* =====================================================
   4. MODAL MAESTRO & UI 
   ===================================================== */
.eco-modal-overlay {
    position: fixed !important;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000000 !important; 
    display: flex; align-items: flex-end; justify-content: center;
}

.eco-modal-card {
    background: white;
    width: 100%; max-width: 550px;
    border-radius: 30px 30px 0 0;
    max-height: 94vh;
    display: flex; flex-direction: column;
    box-shadow: 0 -15px 50px rgba(0,0,0,0.2);
    animation: ecoSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header-master {
    padding: 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex; justify-content: space-between; align-items: center;
    position: relative;
    flex-shrink: 0;
}

.modal-body-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 120px !important;
    -webkit-overflow-scrolling: touch;
}

/* Fichas de Viaje */
.eco-ficha-viaje, .viaje-publico-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 18px;
    margin-bottom: 15px;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(226, 232, 240, 0.6);
    transition: transform 0.2s;
}
.eco-ficha-viaje:active, .viaje-publico-card:active { transform: scale(0.98); }

/* =====================================================
   5. EFECTO BLUR PARA INVITADOS 
   ===================================================== */
.blur-activo {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
    opacity: 0.6;
    transition: all 0.3s ease;
}

/* Animaciones */
@keyframes ecoSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.animate-up { animation: ecoFadeUp 0.4s ease-out forwards; }
@keyframes ecoFadeUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.eco-loader { padding-top: 120px; text-align: center; }
.eco-spinner {
    width: 32px; height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--eco-blue-dark);
    border-radius: 50%;
    animation: ecoSpin 0.7s linear infinite;
    margin: 30px auto;
}
@keyframes ecoSpin { to { transform: rotate(360deg); } }

/* =====================================================
   6. LAYOUT DESKTOP ENTERPRISE (El diseño de la imagen)
   ===================================================== */
@media (min-width: 768px) {
    
    #eco-app-shell {
        flex-direction: row !important; /* Sidebar a la izquierda, contenido derecha */
    }

    /* Ocultar elementos móviles */
    .eco-header, 
    .eco-manager-menu {
        display: none !important;
    }

    /* Mostrar y estilizar Sidebar Oscuro */
    .eco-sidebar {
        display: flex !important;
        flex-direction: column;
        width: 260px !important;
        height: 100vh !important;
        background: var(--eco-sidebar-bg) !important;
        color: #94a3b8;
        padding: 20px;
        flex-shrink: 0;
        overflow-y: auto;
        border-right: 1px solid #1e293b;
    }

    .eco-logo {
        font-weight: 900;
        font-size: 20px;
        margin-bottom: 30px;
        color: white;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .eco-nav {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .nav-item-desktop {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 20px !important;
        color: #94a3b8;
        cursor: pointer;
        border-radius: 12px !important;
        transition: 0.2s;
        font-weight: 700;
        user-select: none;
        font-size: 14px !important;
        margin-bottom: 4px;
    }

    .nav-item-desktop:hover {
        background: #1e293b;
        color: white;
    }

    .nav-item-desktop.active {
        background: var(--eco-blue-light) !important;
        color: white !important;
    }

    /* Desktop Header (Barra de búsqueda superior) */
    .eco-header-desktop {
        display: flex !important;
        height: 72px;
        background: white;
        border-bottom: 1px solid #e2e8f0;
        padding: 0 30px;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
    }

    .eco-search {
        width: 350px;
        max-width: 100%;
        padding: 10px 16px;
        border-radius: 20px;
        border: 1px solid #e2e8f0;
        outline: none;
        background: #f8fafc;
        font-family: var(--eco-font);
        transition: 0.2s;
    }
    
    .eco-search:focus {
        border-color: var(--eco-blue-light);
        background: #ffffff;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

    /* Ajustes Dynamic Content en Desktop */
    #eco-dynamic-content {
        padding: 30px !important; /* Más respiro en desktop */
    }

    .eco-modal-overlay { align-items: center; }
    .eco-modal-card { 
        border-radius: 24px; 
        height: auto; 
        max-height: 85vh; 
        margin: 20px;
    }
    .modal-body-scroll { padding-bottom: 40px !important; }

    /* FAB Desktop position */
    .eco-fab-add {
        bottom: 40px;
        right: 40px;
        width: 65px;
        height: 65px;
    }
}