/**
 * Progressive Web App (PWA) Interface Styles
 * Supports responsive viewports, light and dark mode.
 */

/* ── 1. Topbar / Header Install Button ─────────────────────────────────────── */
.topbar-install-btn,
.pwa-install-btn {
    display: none; /* revealed dynamically by pwa.js when beforeinstallprompt fires */
    align-items: center;
    gap: 0.45rem;
    padding: 0.38rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #0f4c81 0%, #008080 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 76, 129, 0.25);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    text-decoration: none;
}

.topbar-install-btn:hover,
.pwa-install-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 76, 129, 0.35);
    filter: brightness(1.08);
}

.topbar-install-btn svg,
.pwa-install-btn svg {
    flex-shrink: 0;
}

/* ── 2. Floating Prompts & Toasts ───────────────────────────────────────────── */
.pwa-toast {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999999;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.15rem;
    border-radius: 12px;
    background: #0f172a;
    color: #ffffff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1);
    max-width: 420px;
    animation: pwaToastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    font-size: 0.85rem;
}

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

.pwa-toast-update {
    background: #0f172a;
    border-left: 4px solid #38bdf8;
}

.pwa-toast-warning {
    background: #78350f;
    color: #fef3c7;
    border-left: 4px solid #f59e0b;
}

.pwa-toast-success {
    background: #064e3b;
    color: #d1fae5;
    border-left: 4px solid #10b981;
}

.pwa-toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    flex-shrink: 0;
}

.pwa-toast-content {
    flex: 1;
}

.pwa-toast-title {
    font-weight: 700;
    font-size: 0.88rem;
    margin-bottom: 2px;
}

.pwa-toast-desc {
    font-size: 0.8rem;
    opacity: 0.9;
}

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

/* ── 3. Install Promo Banner (Rich Experience) ──────────────────────────────── */
.pwa-install-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999998;
    max-width: 380px;
    width: calc(100vw - 48px);
    animation: pwaBannerPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pwaBannerPop {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.pwa-banner-fade-out {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
    transition: all 0.25s ease;
}

.pwa-banner-card {
    position: relative;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 16px 36px -6px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(15, 23, 42, 0.05);
}

html[data-theme="dark"] .pwa-banner-card,
html.dark-mode .pwa-banner-card {
    background: #0f172a;
    border-color: #1e293b;
    box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.pwa-banner-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.15s ease;
}

.pwa-banner-close:hover {
    color: #475569;
}

html[data-theme="dark"] .pwa-banner-close:hover {
    color: #f1f5f9;
}

.pwa-banner-body {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    margin-bottom: 1.1rem;
    padding-right: 1.25rem;
}

.pwa-banner-badge-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.pwa-app-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pwa-banner-text {
    flex: 1;
}

.pwa-banner-heading {
    font-size: 0.98rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.2rem;
    letter-spacing: -0.01em;
}

html[data-theme="dark"] .pwa-banner-heading,
html.dark-mode .pwa-banner-heading {
    color: #f8fafc;
}

.pwa-banner-sub {
    font-size: 0.8rem;
    line-height: 1.45;
    color: #64748b;
}

html[data-theme="dark"] .pwa-banner-sub,
html.dark-mode .pwa-banner-sub {
    color: #94a3b8;
}

.pwa-banner-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6rem;
}

.pwa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.5rem 0.95rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.pwa-btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

.pwa-btn-secondary {
    background: transparent;
    border-color: #cbd5e1;
    color: #475569;
}

html[data-theme="dark"] .pwa-btn-secondary,
html.dark-mode .pwa-btn-secondary {
    border-color: #334155;
    color: #cbd5e1;
}

.pwa-btn-secondary:hover {
    background: #f1f5f9;
}

html[data-theme="dark"] .pwa-btn-secondary:hover,
html.dark-mode .pwa-btn-secondary:hover {
    background: #1e293b;
}

.pwa-btn-primary {
    background: linear-gradient(135deg, #0f4c81 0%, #008080 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 76, 129, 0.25);
}

.pwa-btn-primary:hover {
    box-shadow: 0 4px 12px rgba(15, 76, 129, 0.35);
    filter: brightness(1.08);
}

/* ── 4. Standalone Mode Adjustments ─────────────────────────────────────────── */
@media all and (display-mode: standalone) {
    .pwa-install-btn,
    .topbar-install-btn,
    .pwa-install-banner {
        display: none !important;
    }

    body {
        /* Extra padding for devices with safe area notch / title bar */
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* Mobile Responsiveness for PWA UI */
@media (max-width: 640px) {
    .pwa-install-banner {
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
    }

    .pwa-toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }
}
