/* ═══════════════════════════════════════════
   PWA App-Like Styles & Animations
   Khar Gym Khana - Theme: #033592
   ═══════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    --kgk-primary: #033592;
    --kgk-primary-light: #0D4ABB;
    --kgk-primary-dark: #022872;
    --kgk-accent: #4A90E2;
    --kgk-shadow: 0 4px 20px rgba(3, 53, 146, 0.15);
    --kgk-shadow-lg: 0 8px 30px rgba(3, 53, 146, 0.25);
    --kgk-radius: 16px;
    --kgk-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── PWA Splash Screen ── */
.pwa-splash {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: linear-gradient(135deg, var(--kgk-primary) 0%, var(--kgk-primary-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.pwa-splash.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.pwa-splash-logo {
    width: 100px;
    height: 100px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    animation: splashLogoIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-splash-logo img {
    width: 60px;
    height: auto;
    filter: brightness(0) invert(1);
    animation: splashLogoPulse 2s ease-in-out infinite;
}

.pwa-splash-title {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    animation: splashFadeIn 0.6s ease 0.3s both;
}

.pwa-splash-spinner {
    margin-top: 2rem;
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes splashLogoIn {
    from { opacity: 0; transform: scale(0.5) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes splashLogoPulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── App-Like Header (Mobile) ── */
@media (max-width: 991.98px) {
    .pwa-app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1050;
        background: linear-gradient(135deg, var(--kgk-primary) 0%, var(--kgk-primary-light) 100%);
        padding: 0.65rem 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
        animation: slideDown 0.4s ease;
        min-height: 56px;
    }

    .pwa-app-header .pwa-logo {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        text-decoration: none;
    }

    .pwa-app-header .pwa-logo img {
        height: 32px;
        width: auto;
        filter: brightness(0) invert(1);
    }

    .pwa-app-header .pwa-logo-text {
        color: #fff;
        font-weight: 700;
        font-size: 1.05rem;
        letter-spacing: 0.02em;
    }

    .pwa-app-header .pwa-header-actions {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .pwa-app-header .pwa-icon-btn {
        background: rgba(255, 255, 255, 0.15);
        border: none;
        color: #fff;
        width: 38px;
        height: 38px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.05rem;
        transition: var(--kgk-transition);
        cursor: pointer;
    }

    .pwa-app-header .pwa-icon-btn:active {
        transform: scale(0.92);
        background: rgba(255, 255, 255, 0.25);
    }

    /* Offset content for fixed header */
    .main-content {
        padding-top: 56px;
    }

    /* Hide old header on mobile */
    header { display: none !important; }

    /* PWA Install Button */
    .pwa-install-btn {
        position: fixed;
        top: calc(56px + 8px + env(safe-area-inset-top, 0));
        left: 12px;
        z-index: 1049;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        border: none;
        background: rgba(255, 255, 255, 0.95);
        color: var(--kgk-primary);
        font-size: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        cursor: pointer;
        transition: var(--kgk-transition);
        animation: slideDown 0.4s ease 0.3s both;
    }

    .pwa-install-btn:active {
        transform: scale(0.9);
    }
}

@media (min-width: 992px) {
    .pwa-install-btn { display: none !important; }
}

@media (min-width: 992px) {
    .pwa-app-header { display: none; }
}

/* ── Slide Animations ── */
@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Page Transition Animations ── */
.pwa-page-enter {
    animation: fadeIn 0.35s ease;
}

.pwa-card-enter {
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-stagger > * {
    opacity: 0;
    animation: slideInRight 0.4s ease forwards;
}

.pwa-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.pwa-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.pwa-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.pwa-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.pwa-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.pwa-stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* ── Enhanced Bottom Nav (App-Like) ── */
@media (max-width: 767px) {
    .mobile-bottom-nav {
        height: 62px;
        background: #fff;
        border-top: none;
        box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mobile-bottom-nav .mobile-nav-item {
        color: #94a3b8;
        font-size: 10px;
        gap: 3px;
        transition: var(--kgk-transition);
        position: relative;
    }

    .mobile-bottom-nav .mobile-nav-item i {
        font-size: 20px;
        transition: var(--kgk-transition);
    }

    .mobile-bottom-nav .mobile-nav-item.active {
        color: var(--kgk-primary);
        font-weight: 600;
    }

    .mobile-bottom-nav .mobile-nav-item.active i {
        transform: scale(1.15) translateY(-2px);
    }

    .mobile-bottom-nav .mobile-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 32px;
        height: 3px;
        border-radius: 0 0 6px 6px;
        background: var(--kgk-primary);
        animation: fadeIn 0.3s ease;
    }

    .mobile-bottom-nav .mobile-nav-item:active i {
        transform: scale(0.88);
    }

    .main-content { padding-bottom: 70px; }
}

/* ── Pull-to-Refresh Hint ── */
.pwa-ptr-indicator {
    position: fixed;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 4px;
    background: var(--kgk-primary);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1040;
}

.pwa-ptr-indicator.active {
    opacity: 1;
    transform: translateX(-50%) scale(1.2);
}

/* ── Touch Feedback ── */
@media (max-width: 991.98px) {
    a, button, .btn {
        -webkit-tap-highlight-color: transparent;
    }

    .card, .profile-card, .stat-item {
        transition: var(--kgk-transition);
    }

    .card:active, .profile-card:active {
        transform: scale(0.98);
    }
}

/* ── Safe Area Insets ── */
@supports (padding: env(safe-area-inset-top)) {
    .pwa-app-header {
        padding-top: env(safe-area-inset-top, 0);
        min-height: calc(56px + env(safe-area-inset-top, 0));
    }
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom, 0);
        height: calc(62px + env(safe-area-inset-bottom, 0));
    }
}

/* ── Skeleton Loading ── */
.pwa-skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── No Scroll Bounce (iOS) ── */
html, body {
    overscroll-behavior-y: none;
}

/* ── Smooth Scrolling ── */
html {
    scroll-behavior: smooth;
}

/* ── Update Available Banner ── */
.pwa-update-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    z-index: 1080;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 8px 30px rgba(3, 53, 146, 0.25);
    border: 1px solid rgba(3, 53, 146, 0.12);
    transform: translateY(140%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease, visibility 0.35s;
}

.pwa-update-banner.visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.pwa-update-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(3, 53, 146, 0.1);
    color: var(--kgk-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.pwa-update-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.pwa-update-text strong {
    font-size: 14px;
    color: #0f172a;
}

.pwa-update-text span {
    font-size: 12px;
    color: #64748b;
}

.pwa-update-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    background: var(--kgk-primary);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.2s ease;
}

.pwa-update-btn:active {
    transform: scale(0.94);
}

.pwa-update-btn:disabled {
    opacity: 0.65;
    cursor: default;
}

.pwa-update-dismiss {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    font-size: 13px;
    cursor: pointer;
}

.pwa-update-dismiss:active {
    background: rgba(0, 0, 0, 0.06);
}

@media (min-width: 992px) {
    .pwa-update-banner {
        left: auto;
        right: 20px;
        bottom: 20px;
        max-width: 380px;
    }
}
