/**
 * PWA Native Styles - Conecta Multiservicios
 * Estilos para mejorar la experiencia nativa cuando se instala como PWA
 */

/* ============================================
   DETECCIÓN DE PWA INSTALADA
   ============================================ */

/* Cuando la app está instalada (standalone mode) */
@media (display-mode: standalone) {
    
    /* Ocultar elementos innecesarios en PWA */
    .hide-in-pwa {
        display: none !important;
    }
    
    /* Agregar padding top para compensar status bar en móviles */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Navbar fija con mejor espaciado */
    .navbar {
        padding-top: calc(10px + env(safe-area-inset-top));
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        background: rgba(0, 0, 0, 0.85);
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
    }
    
    /* Hero section con mejor spacing */
    .hero {
        min-height: 100vh;
        padding-top: calc(80px + env(safe-area-inset-top));
    }
    
    /* Botones con mejor feedback táctil */
    .btn,
    button,
    a.btn {
        -webkit-tap-highlight-color: rgba(156, 30, 19, 0.2);
        transform: translateZ(0);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .btn:active,
    button:active,
    a.btn:active {
        transform: scale(0.96);
    }
    
    /* Cards con efecto nativo */
    .service-card,
    .mv-card,
    .value-card,
    .client-card,
    .benefit-item {
        transform: translateZ(0);
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .service-card:active,
    .mv-card:active,
    .value-card:active,
    .client-card:active,
    .benefit-item:active {
        transform: scale(0.98);
    }
    
    /* Pull-to-refresh indicator (iOS style) */
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: linear-gradient(90deg, #9c1e13 0%, #000 100%);
        transform: scaleX(0);
        transform-origin: left;
        transition: transform 0.3s ease;
        z-index: 10001;
    }
    
    /* Scroll suave con momentum */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Animaciones más fluidas */
    .hero-content,
    .section-header,
    [data-aos] {
        will-change: transform, opacity;
    }
}

/* ============================================
   SPLASH SCREEN PERSONALIZADO
   ============================================ */

/* Loading screen cuando la app se inicia */
.pwa-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.pwa-splash.hidden {
    opacity: 0;
    pointer-events: none;
}

.pwa-splash-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    animation: pulse 2s ease-in-out infinite;
}

.pwa-splash-text {
    font-family: 'Poppins', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #000;
    margin-bottom: 10px;
}

.pwa-splash-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #9c1e13;
    font-weight: 500;
}

.pwa-splash-loader {
    margin-top: 40px;
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #9c1e13;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   BADGE DE INSTALACIÓN PWA
   ============================================ */

.pwa-badge {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    background: linear-gradient(135deg, #9c1e13 0%, #000 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(156, 30, 19, 0.3);
    z-index: 9999;
    display: none;
    animation: slideInRight 0.5s ease;
}

@media (display-mode: standalone) {
    .pwa-badge {
        display: block;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   GESTOS NATIVOS
   ============================================ */

/* Swipe indicators */
.swipe-indicator {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 5px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (display-mode: standalone) {
    .swipe-indicator.show {
        opacity: 1;
    }
}

/* ============================================
   OPTIMIZACIONES DE RENDIMIENTO
   ============================================ */

/* Hardware acceleration para elementos animados */
.hero,
.navbar,
.service-card,
.btn {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Reducir animaciones en conexiones lentas */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   STATUS BAR PERSONALIZADA (iOS)
   ============================================ */

/* Agregar una barra de estado personalizada solo en iOS PWA */
@supports (-webkit-touch-callout: none) {
    @media (display-mode: standalone) {
        .ios-status-bar {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: env(safe-area-inset-top);
            background: #000;
            z-index: 10000;
        }
    }
}

/* ============================================
   VIBRACIÓN HÁPTICA (Simulada con CSS)
   ============================================ */

.haptic-feedback:active {
    animation: haptic 0.1s ease;
}

@keyframes haptic {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-2px);
    }
    75% {
        transform: translateX(2px);
    }
}

/* ============================================
   NOTIFICACIÓN TOAST NATIVA
   ============================================ */

.pwa-toast {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10000;
    transform: translateY(150%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.pwa-toast-icon {
    display: inline-block;
    margin-right: 10px;
    font-size: 18px;
}

/* ============================================
   MODO OSCURO PARA PWA
   ============================================ */

@media (prefers-color-scheme: dark) {
    @media (display-mode: standalone) {
        
        /* Ajustes para modo oscuro */
        body {
            background: #121212;
        }
        
        .navbar {
            background: rgba(18, 18, 18, 0.95);
        }
        
        .service-card,
        .mv-card,
        .value-card {
            background: #1e1e1e;
            border: 1px solid #2a2a2a;
        }
        
        h1, h2, h3, h4, h5, h6 {
            color: #ffffff;
        }
        
        p {
            color: #b0b0b0;
        }
    }
}

/* ============================================
   ORIENTACIÓN LANDSCAPE
   ============================================ */

@media (display-mode: standalone) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
        padding: calc(60px + env(safe-area-inset-top)) 20px 60px;
    }
    
    .hero-content {
        flex-direction: row;
        align-items: center;
        gap: 40px;
    }
}

/* ============================================
   PULL TO REFRESH ANIMATION
   ============================================ */

@media (display-mode: standalone) {
    body.pull-to-refresh::before {
        transform: scaleX(1);
    }
}

/* ============================================
   APP SHORTCUTS PREVIEW
   ============================================ */

.shortcut-preview {
    display: none;
}

@media (display-mode: standalone) {
    .shortcut-preview {
        display: block;
        position: fixed;
        top: calc(60px + env(safe-area-inset-top));
        right: 20px;
        background: white;
        padding: 12px 16px;
        border-radius: 10px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
        font-size: 12px;
        color: #666;
        z-index: 9999;
        animation: fadeInOut 3s ease;
    }
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0;
    }
    10%, 90% {
        opacity: 1;
    }
}

