/**
 * PWA Styles
 * - Install banner
 * - Update notification
 * - Offline indicator
 */

/* ===============================================
   PWA Install Banner
   =============================================== */

.pwa-install-banner {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: pwa-slide-up 0.3s ease-out;
    max-width: 600px;
    margin: 0 auto;
}

@keyframes pwa-slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pwa-banner-hiding {
    animation: pwa-slide-down 0.3s ease-out forwards;
}

@keyframes pwa-slide-down {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.pwa-install-content {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 12px;
}

.pwa-install-icon img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

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

.pwa-install-text strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.pwa-install-text p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

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

.pwa-install-button {
    background: var(--primary-color, #2563eb);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.pwa-install-button:hover {
    background: var(--primary-hover, #1d4ed8);
}

.pwa-install-button:active {
    transform: scale(0.98);
}

.pwa-dismiss-button {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s ease;
}

.pwa-dismiss-button:hover {
    color: #6b7280;
}

/* ===============================================
   PWA Update Notification
   =============================================== */

.pwa-update-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    animation: pwa-fade-in 0.3s ease-out;
}

@keyframes pwa-fade-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pwa-update-content span {
    font-size: 14px;
}

.pwa-update-button {
    background: white;
    color: #1f2937;
    border: none;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.pwa-update-button:hover {
    background: #f3f4f6;
}

.pwa-update-button:active {
    transform: scale(0.98);
}

/* ===============================================
   Offline Indicator
   =============================================== */

.pwa-offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ef4444;
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    z-index: 10000;
    animation: pwa-slide-down-top 0.3s ease-out;
}

@keyframes pwa-slide-down-top {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.pwa-online-indicator {
    background: #10b981;
}

/* ===============================================
   Mobile Responsive
   =============================================== */

@media (max-width: 640px) {
    .pwa-install-banner {
        bottom: 10px;
        left: 10px;
        right: 10px;
    }

    .pwa-install-content {
        padding: 12px;
        gap: 8px;
    }

    .pwa-install-icon img {
        width: 40px;
        height: 40px;
    }

    .pwa-install-text strong {
        font-size: 14px;
    }

    .pwa-install-text p {
        font-size: 12px;
    }

    .pwa-install-button {
        padding: 8px 16px;
        font-size: 13px;
    }

    .pwa-update-notification {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: none;
    }

    @keyframes pwa-fade-in {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .pwa-update-content {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* ===============================================
   PWA Standalone Mode Adjustments
   =============================================== */

@media (display-mode: standalone) {
    /* Adjust top padding for iOS status bar */
    body {
        padding-top: env(safe-area-inset-top);
    }

    /* Hide install banner when already installed */
    .pwa-install-banner {
        display: none;
    }
}

/* ===============================================
   Loading Spinner for PWA
   =============================================== */

.pwa-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9998;
}

.pwa-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: var(--primary-color, #2563eb);
    border-radius: 50%;
    animation: pwa-spin 0.8s linear infinite;
}

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