/* ==========================================================================
   SINART FEDOVOLI - ESTILOS PWA & ACELERACIÓN DE NAVEGACIÓN
   ========================================================================== */

/* Barra de Progreso Superior Ultrarrápida al cambiar de vista */
.pwa-nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #ef233c, #60a5fa);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
    z-index: 99999999;
    pointer-events: none;
    opacity: 0;
    transition: width 0.35s cubic-bezier(0.1, 0.8, 0.2, 1), opacity 0.2s ease;
}

.pwa-nav-progress.active {
    opacity: 1;
    width: 78%;
}

.pwa-nav-progress.done {
    width: 100%;
    opacity: 0;
}

/* Aceleración de renderizado DOM para tablas y tarjetas extensas */
.equipo-card,
.alojamiento-card,
.excel-tbody,
.partido-card {
    content-visibility: auto;
    contain-intrinsic-size: auto 160px;
}

/* Optimizaciones para PWA Standalone (Aplicación Instalada) */
@media all and (display-mode: standalone) {
    body {
        -webkit-user-select: none;
        user-select: none;
        overscroll-behavior-y: contain;
    }

    input, textarea, select {
        -webkit-user-select: text;
        user-select: text;
    }

    /* Respetar área segura de muesca (Notch) en iPhone y dispositivos modernos */
    .mobile-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .main-content {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }

    /* Ocultar elementos de instalación cuando ya está instalada */
    .pwa-install-element {
        display: none !important;
    }
}

/* Banner Flotante de Instalación */
.pwa-install-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 420px;
    width: calc(100% - 48px);
    animation: pwaSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    backdrop-filter: blur(12px);
}

@keyframes pwaSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pwa-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.pwa-banner-icon img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.pwa-banner-content {
    flex: 1;
    min-width: 0;
}

.pwa-banner-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-banner-desc {
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.3;
}

.pwa-banner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-pwa-install {
    background: #3b82f6;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-pwa-install:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-pwa-close {
    background: transparent;
    color: #94a3b8;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.btn-pwa-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* En móviles, centrar el banner como bottom sheet */
@media (max-width: 600px) {
    .pwa-install-banner {
        left: 16px;
        right: 16px;
        bottom: 16px;
        width: calc(100% - 32px);
        padding: 14px 16px;
    }
}

/* Botón de instalación en Sidebar */
.pwa-sidebar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 8px 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.25));
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    color: #60a5fa !important;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-sidebar-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.35));
    color: #ffffff !important;
    transform: translateX(3px);
}

.pwa-sidebar-btn i {
    font-size: 1.1rem;
}

/* Botón de instalación en Header Móvil */
.btn-pwa-mobile {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #60a5fa;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 10px;
    transition: all 0.2s;
}

.btn-pwa-mobile:hover {
    background: #3b82f6;
    color: #ffffff;
}

/* Toast de Conectividad (Online / Offline) */
.pwa-status-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-50px);
    z-index: 9999999;
    padding: 10px 20px;
    border-radius: 9999px;
    font-size: 0.88rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-status-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.pwa-status-toast.offline {
    background: #ef4444;
    color: #ffffff;
}

.pwa-status-toast.online {
    background: #10b981;
    color: #ffffff;
}

.pwa-status-toast.update {
    background: #0f172a;
    color: #ffffff;
    border: 1px solid #3b82f6;
}

.pwa-status-toast .btn-update-reload {
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    margin-left: 8px;
}

/* Modal Instructivo para iOS Safari */
.pwa-ios-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 99999999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.pwa-ios-modal.show {
    opacity: 1;
    visibility: visible;
}

.pwa-ios-sheet {
    background: #1e293b;
    color: #f8fafc;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 500px;
    padding: 24px;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    text-align: center;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-ios-modal.show .pwa-ios-sheet {
    transform: translateY(0);
}

.pwa-ios-steps {
    text-align: left;
    margin: 18px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pwa-ios-step {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #0f172a;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #334155;
    font-size: 0.9rem;
}

.pwa-ios-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}
