/**
 * pwa.css — District Work PWA UI Components
 * ==========================================
 * Styles for:
 *   - Install App button (#pwa-install-btn)
 *   - Update available toast (#pwa-update-toast)
 *   - Offline status banner (#pwa-offline-banner)
 *   - Generic toast notifications (.pwa-toast)
 *
 * These are fully self-contained and do not depend on Tailwind or other CSS.
 * Import this sheet in every PHP page that includes pwa-install.js.
 */

/* ── Design tokens (match main site) ─────────────────────────────────────── */
:root {
    --pwa-brand:          #6C63FF;
    --pwa-brand-dark:     #574fd6;
    --pwa-brand-glow:     rgba(108, 99, 255, 0.28);
    --pwa-success:        #10b981;
    --pwa-success-bg:     rgba(16, 185, 129, 0.12);
    --pwa-danger:         #f43f5e;
    --pwa-danger-bg:      rgba(244, 63, 94, 0.12);
    --pwa-warn:           #f59e0b;
    --pwa-info-bg:        rgba(108, 99, 255, 0.12);
    --pwa-toast-bg:       #1a1d2e;
    --pwa-toast-border:   rgba(255, 255, 255, 0.10);
    --pwa-toast-text:     #f1f5f9;
    --pwa-toast-radius:   14px;
    --pwa-shadow:         0 8px 32px rgba(0, 0, 0, 0.40);
    --pwa-shadow-lg:      0 20px 60px rgba(0, 0, 0, 0.50);
    --pwa-transition:     0.3s cubic-bezier(0.22, 1, 0.36, 1);
    --pwa-z-banner:       9000;
    --pwa-z-toast:        9100;
    --pwa-z-install-btn:  9050;
}

[data-theme="light"] {
    --pwa-toast-bg:     #ffffff;
    --pwa-toast-border: rgba(108, 99, 255, 0.14);
    --pwa-toast-text:   #1a1033;
    --pwa-shadow:       0 8px 32px rgba(108, 99, 255, 0.12);
    --pwa-shadow-lg:    0 20px 60px rgba(108, 99, 255, 0.15);
}

/* ══════════════════════════════════════════════════════════════════════════════
   INSTALL BUTTON
   Injected into the navbar by PHP pages. Hidden until beforeinstallprompt fires.
   ══════════════════════════════════════════════════════════════════════════════ */
#pwa-install-btn {
    display: none; /* Hidden by default — JS will show it */
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1.5px solid rgba(108, 99, 255, 0.40);
    background: rgba(108, 99, 255, 0.10);
    color: var(--pwa-brand);
    text-decoration: none;
    white-space: nowrap;
    z-index: var(--pwa-z-install-btn);
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
    transition:
        opacity    var(--pwa-transition),
        transform  var(--pwa-transition),
        background 0.18s ease,
        box-shadow 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

#pwa-install-btn.pwa-install-btn--visible {
    display: inline-flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

#pwa-install-btn:hover {
    background: rgba(108, 99, 255, 0.18);
    box-shadow: 0 4px 16px var(--pwa-brand-glow);
    transform: translateY(-1px) scale(1.02);
}

#pwa-install-btn:active {
    transform: scale(0.97);
}

[data-theme="light"] #pwa-install-btn {
    background: rgba(108, 99, 255, 0.08);
    border-color: rgba(108, 99, 255, 0.30);
}

/* Icon inside install button */
#pwa-install-btn .pwa-btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Mobile: compact install button ─────────────────────────────────────── */
@media (max-width: 480px) {
    #pwa-install-btn .pwa-btn-label {
        display: none; /* Show only icon on very small screens */
    }
    #pwa-install-btn {
        padding: 7px 10px;
    }
}

/* ══════════════════════════════════════════════════════════════════════════════
   OFFLINE BANNER
   Fixed at the top of the page, slides down when offline detected.
   ══════════════════════════════════════════════════════════════════════════════ */
.pwa-offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--pwa-z-banner);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--pwa-danger);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    text-align: center;
    box-shadow: 0 4px 20px rgba(244, 63, 94, 0.35);
    transform: translateY(-100%);
    opacity: 0;
    transition:
        transform var(--pwa-transition),
        opacity   var(--pwa-transition),
        background 0.3s ease;
    will-change: transform;
}

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

.pwa-offline-banner--online {
    background: var(--pwa-success);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.35);
}

.pwa-offline-banner__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

.pwa-offline-banner__text {
    line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS (Update & generic)
   Fixed at bottom-right, stacks naturally.
   ══════════════════════════════════════════════════════════════════════════════ */
.pwa-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--pwa-z-toast);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    max-width: 380px;
    width: calc(100vw - 48px);
    background: var(--pwa-toast-bg);
    border: 1px solid var(--pwa-toast-border);
    border-radius: var(--pwa-toast-radius);
    box-shadow: var(--pwa-shadow-lg);
    color: var(--pwa-toast-text);
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.5;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);

    /* Animation */
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transition:
        opacity   var(--pwa-transition),
        transform var(--pwa-transition);
    pointer-events: none;
}

.pwa-toast--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Icon */
.pwa-toast__icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Message text area */
.pwa-toast__msg {
    flex: 1;
    font-size: 0.875rem;
}
.pwa-toast__msg strong {
    display: block;
    font-weight: 700;
    margin-bottom: 2px;
}

/* Action buttons row inside toast */
.pwa-toast__btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.12s ease;
}

.pwa-toast__btn:active { transform: scale(0.96); }

.pwa-toast__btn--primary {
    background: var(--pwa-brand);
    color: #fff;
    margin-top: 4px;
}
.pwa-toast__btn--primary:hover {
    background: var(--pwa-brand-dark);
}

/* Close button */
.pwa-toast__close {
    align-self: flex-start;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--pwa-toast-text);
    font-size: 1rem;
    opacity: 0.5;
    padding: 0;
    line-height: 1;
    transition: opacity 0.15s ease;
    font-family: inherit;
}
.pwa-toast__close:hover { opacity: 1; }

/* ── Toast type variants ──────────────────────────────────────────────────── */
.pwa-toast--update {
    border-left: 3px solid var(--pwa-brand);
    flex-wrap: wrap;
}
.pwa-toast--success {
    border-left: 3px solid var(--pwa-success);
}
.pwa-toast--error {
    border-left: 3px solid var(--pwa-danger);
}
.pwa-toast--info {
    border-left: 3px solid var(--pwa-brand);
}

/* Stagger multiple toasts */
.pwa-toast + .pwa-toast {
    bottom: calc(24px + 80px);
}

/* ── Mobile adjustments ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .pwa-toast {
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
    }
}
