/**
 * mobile-enhancements.css
 * Estilos adicionales para mejorar la experiencia móvil
 * Incluir después de estilos.css
 */

/* ========================================= */
/* RESET Y BASE */
/* ========================================= */

* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ========================================= */
/* SECCIONES CON SCROLL HORIZONTAL */
/* ========================================= */

/* IMPORTANTE: No cambiar colores de fondo, respetar los originales */
.mobile-horizontal-section,
.notificaciones-publicas-section {
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* ========================================= */
/* TÍTULOS ESTILO APP MODERNA */
/* ========================================= */

.section-title-modern {
    font-size: 1.3rem !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    margin: 0 0 8px 0 !important;
    padding: 0 20px !important;
    text-align: left !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.section-subtitle-modern {
    font-size: 0.9rem !important;
    color: #666 !important;
    margin: 0 0 15px 0 !important;
    padding: 0 20px !important;
    line-height: 1.4 !important;
    text-align: left !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========================================= */
/* CONTENEDORES DE SCROLL */
/* ========================================= */

.horizontal-scroll-container {
    position: relative;
}

/* Indicadores de scroll (gradientes) */
.horizontal-scroll-container::before,
.horizontal-scroll-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 20px;
    width: 20px;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.horizontal-scroll-container::before {
    left: 0;
    background: linear-gradient(to right, rgba(255,255,255,0.9), transparent);
}

.horizontal-scroll-container::after {
    right: 0;
    background: linear-gradient(to left, rgba(255,255,255,0.9), transparent);
}

.horizontal-scroll-container.has-scroll-left::before {
    opacity: 1;
}

.horizontal-scroll-container.has-scroll-right::after {
    opacity: 1;
}

/* ========================================= */
/* ESTILOS MÓVIL */
/* ========================================= */

@media (max-width: 768px) {
    
    /* One Clik Section */
    .mobile-horizontal-section .container {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        padding: 0 10px 20px 10px !important;
        gap: 15px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        scrollbar-width: none;
    }
    
    .mobile-horizontal-section .container::-webkit-scrollbar {
        display: none;
    }
    
    .mobile-horizontal-section .panel {
        flex: 0 0 280px !important;
        min-width: 280px !important;
        max-width: 280px !important;
        margin: 0 !important;
        scroll-snap-align: start;
        transition: transform 0.2s ease;
    }
    
    .mobile-horizontal-section .panel:active {
        transform: scale(0.98);
    }
    
    /* CORRECCIÓN: Permitir que las imágenes se ajusten naturalmente */
    .mobile-horizontal-section .panel img {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        min-height: 150px !important;
        object-fit: cover !important;
        display: block !important;
    }
    
    .mobile-horizontal-section .panel {
        min-height: auto !important;
        height: auto !important;
    }
    
    /* Notificaciones Públicas Section */
    .notificaciones-publicas-section .route-cards {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 15px;
        padding: 0 10px 20px 10px !important;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        scrollbar-width: none;
    }
    
    .notificaciones-publicas-section .route-cards::-webkit-scrollbar {
        display: none;
    }
    
    .notificaciones-publicas-section .route-card {
        flex: 0 0 280px !important;
        min-width: 280px !important;
        max-width: 280px !important;
        scroll-snap-align: start;
        transition: transform 0.2s ease;
    }
    
    .notificaciones-publicas-section .route-card:active {
        transform: scale(0.98);
    }
    
    /* CORRECCIÓN: Mantener altura fija solo en route-card images */
    .notificaciones-publicas-section .route-card .route-image,
    .notificaciones-publicas-section .route-card img {
        width: 100% !important;
        height: 180px !important;
        object-fit: cover !important;
        display: block !important;
    }
    
    .notificaciones-publicas-section .route-image-container {
        height: 180px !important;
        overflow: hidden !important;
    }
}

/* ========================================= */
/* BOTTOM NAVIGATION - ICONOS VERDES #42ba25 */
/* ========================================= */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    padding: 8px 0;
    padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: block;
    }
}

.mobile-bottom-nav ul {
    display: flex;
    justify-content: space-around;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-bottom-nav li {
    flex: 1;
}

.mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #666;
    padding: 8px;
    transition: all 0.2s ease;
    position: relative;
}

/* ICONOS EN VERDE #42ba25 */
.mobile-bottom-nav i {
    font-size: 24px !important;
    margin-bottom: 0 !important;
    color: #42ba25 !important;
}

.mobile-bottom-nav a.active {
    color: #42ba25;
}

.mobile-bottom-nav a.active i {
    transform: scale(1.1);
}

.mobile-bottom-nav a:active {
    transform: scale(0.95);
}

.mobile-nav-label {
    font-size: 11px;
    font-weight: 500;
    display: none !important;
}

/* Badge en bottom nav */
.mobile-bottom-nav .message-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 20px);
}

/* Indicador inferior verde */
.mobile-bottom-nav a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: #42ba25;
    transition: width 0.3s ease;
}

.mobile-bottom-nav a.active::before {
    width: 30px;
}

/* ========================================= */
/* BUSCADOR PLEGABLE */
/* ========================================= */

.search-container {
    margin: 20px auto;
    max-width: 1200px;
    padding: 0 20px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.search-toggle-btn {
    display: none;
    width: 100%;
    background: linear-gradient(135deg, #42ba25, #36a11f);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 15px;
    box-shadow: 0 4px 12px rgba(66, 186, 37, 0.3);
    transition: all 0.3s ease;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.search-toggle-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 6px rgba(66, 186, 37, 0.2);
}

.search-toggle-btn i {
    transition: transform 0.3s ease;
}

.search-toggle-btn.active i {
    transform: rotate(180deg);
}

#searchForm {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

@media (max-width: 768px) {
    /* Mostrar botón toggle en móvil */
    .search-toggle-btn {
        display: flex;
    }
    
    /* Formulario colapsado por defecto */
    #searchForm.collapsed {
        max-height: 0;
        opacity: 0;
        transform: translateY(-20px);
        pointer-events: none;
        margin: 0;
    }
    
    #searchForm.expanded {
        max-height: 1000px;
        opacity: 1;
        transform: translateY(0);
        pointer-events: all;
        margin-bottom: 20px;
    }
    
    .search-container {
        padding: 0 15px;
    }
    
    /* Prevenir scroll del body cuando el teclado está abierto */
    body.keyboard-active {
        position: fixed;
        width: 100%;
        overflow: hidden;
        height: 100vh;
    }
    
    /* Ajustar header cuando el teclado está abierto */
    body.keyboard-active .header {
        position: absolute;
    }
    
    /* Ocultar animaciones cuando teclado activo */
    body.keyboard-active .header-content > div[id*="animacion"] {
        display: none !important;
    }
    
    body.keyboard-active .header h1,
    body.keyboard-active .header p {
        margin: 10px 0;
        font-size: 1.2rem;
    }
    
    /* Formulario más compacto en móvil */
    .search-container form {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .input-container {
        width: 100%;
        position: relative;
    }
    
    .input-container input {
        width: 100%;
        padding: 14px 40px 14px 14px;
        font-size: 16px;
        border: 2px solid #e0e0e0;
        border-radius: 10px;
        transition: all 0.3s ease;
        -webkit-appearance: none;
        box-sizing: border-box;
        background: white;
    }
    
    .input-container input:focus {
        border-color: #42ba25;
        outline: none;
        box-shadow: 0 0 0 3px rgba(66, 186, 37, 0.1);
    }
    
    .input-container i {
        position: absolute;
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
        color: #42ba25;
        font-size: 16px;
        pointer-events: none;
    }
    
    input[type="submit"] {
        width: 100%;
        padding: 14px;
        background: linear-gradient(135deg, #42ba25, #36a11f);
        color: white;
        border: none;
        border-radius: 10px;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(66, 186, 37, 0.3);
        transition: all 0.3s ease;
    }
    
    input[type="submit"]:active {
        transform: scale(0.98);
        box-shadow: 0 2px 6px rgba(66, 186, 37, 0.2);
    }
}

/* ========================================= */
/* OVERLAY PARA INPUTS */
/* ========================================= */

body.overlay-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.overlay {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.overlay.active {
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-content {
    background-color: #fefefe;
    margin: 0;
    padding: 24px 20px;
    padding-bottom: max(24px, calc(24px + env(safe-area-inset-bottom)));
    border: none;
    width: 100%;
    border-radius: 20px 20px 0 0;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.close-btn {
    color: #666;
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-btn:hover,
.close-btn:active {
    background-color: rgba(0, 0, 0, 0.05);
    color: #333;
}

#overlay-input {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

#overlay-input:focus {
    border-color: #42ba25;
    outline: none;
    box-shadow: 0 0 0 3px rgba(66, 186, 37, 0.1);
}

/* ========================================= */
/* PULL TO REFRESH */
/* ========================================= */

.pull-to-refresh {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 999;
    transition: all 0.3s ease;
}

.pull-to-refresh.active {
    transform: translateX(-50%) scale(1);
}

.pull-to-refresh i {
    color: #42ba25;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================= */
/* SPLASH SCREEN */
/* ========================================= */

.mobile-splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #42ba25 0%, #36a11f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.3s ease;
}

.mobile-splash-screen.fade-out {
    opacity: 0;
}

.mobile-splash-screen img {
    width: 120px;
    height: 120px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* ========================================= */
/* KEYBOARD VISIBLE */
/* ========================================= */

@media (max-width: 768px) {
    body.keyboard-visible .mobile-bottom-nav {
        display: none;
    }
    
    body.has-bottom-nav {
        padding-bottom: 60px;
    }
    
    body.has-bottom-nav.keyboard-visible {
        padding-bottom: 0;
    }
}

/* ========================================= */
/* MEJORAS DE PERFORMANCE */
/* ========================================= */

.panel,
.route-card,
.mobile-bottom-nav a,
.horizontal-scroll-container {
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ========================================= */
/* TRANSICIONES SUAVES */
/* ========================================= */

.smooth-scroll {
    scroll-behavior: smooth;
}

/* ========================================= */
/* SAFE AREAS PARA iOS */
/* ========================================= */

@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
    
    body.has-bottom-nav {
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }
}

/* ========================================= */
/* MEJORAS iOS */
/* ========================================= */

@supports (-webkit-touch-callout: none) {
    input[type="text"],
    input[type="submit"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    .search-container,
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================= */
/* LOADING SKELETON */
/* ========================================= */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================= */
/* MODO OSCURO */
/* ========================================= */

@media (prefers-color-scheme: dark) {
    .mobile-bottom-nav {
        background: #1a1a1a;
        border-top: 1px solid #333;
    }
    
    .mobile-bottom-nav a {
        color: #999;
    }
    
    .mobile-bottom-nav a.active {
        color: #5dd946;
    }
    
    .mobile-bottom-nav i {
        color: #42ba25 !important;
    }
}

/* ========================================= */
/* UTILIDADES */
/* ========================================= */

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none;
    }
    
    .show-mobile {
        display: block;
    }
}

/* ========================================= */
/* AJUSTES PANTALLAS PEQUEÑAS */
/* ========================================= */

@media (max-width: 380px) {
    .search-toggle-btn {
        font-size: 14px;
        padding: 12px 16px;
    }
    
    .input-container input {
        font-size: 15px;
        padding: 12px 36px 12px 12px;
    }
    
    input[type="submit"] {
        font-size: 15px;
        padding: 12px;
    }
    
    .mobile-bottom-nav i {
        font-size: 20px !important;
    }
}