/* PWA Specific Styles */

/* Offline indicator */
body.offline::before {
    content: "⚠️ Offline";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fbbf24;
    color: #92400e;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Adjust content when offline indicator is shown */
body.offline {
    padding-top: 2.5rem;
}

/* PWA Standalone mode adjustments */
.pwa-standalone {
    /* Add safe area padding for devices with notches */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Status bar overlay for iOS standalone */
.pwa-standalone .gradient-bg {
    padding-top: max(env(safe-area-inset-top), 1rem);
}

/* Install prompt styles */
#pwa-install-banner {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* PWA specific animations */
@keyframes pwa-bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

.pwa-bounce {
    animation: pwa-bounce 1s ease-in-out;
}

/* Touch-friendly adjustments for PWA */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets for mobile */
    button, .btn-primary, .btn-secondary, .btn-success, .btn-warning, .btn-danger {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Improve form inputs on touch devices */
    input, select, textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Better touch feedback */
    button:active, .btn-primary:active, .btn-secondary:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* PWA splash screen style (iOS) */
@media (display-mode: standalone) {
    body {
        background-color: #2563eb;
    }
    
    /* Hide address bar simulation */
    .standalone-hidden {
        display: none !important;
    }
}

/* Network status styles */
.network-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    transition: transform 0.3s ease;
}

.network-status.online {
    background: #10b981;
    color: white;
    transform: translateY(-100%);
}

.network-status.offline {
    background: #f59e0b;
    color: #92400e;
    transform: translateY(0);
}

/* PWA loading states */
.pwa-loading {
    position: relative;
    overflow: hidden;
}

.pwa-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: pwa-shimmer 1.5s infinite;
}

@keyframes pwa-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* PWA specific responsive design */
@media screen and (max-width: 390px) {
    /* iPhone 12 mini and smaller */
    .max-w-md {
        max-width: calc(100vw - 2rem);
    }
}

@media screen and (max-height: 667px) {
    /* Short screens adjustments */
    .min-h-screen {
        min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
}

/* Dark mode support for PWA */
@media (prefers-color-scheme: dark) {
    .pwa-dark-mode .bg-white {
        background-color: #1f2937 !important;
        color: #f9fafb !important;
    }
    
    .pwa-dark-mode .text-gray-900 {
        color: #f9fafb !important;
    }
    
    .pwa-dark-mode .text-gray-600 {
        color: #d1d5db !important;
    }
    
    .pwa-dark-mode .border-gray-300 {
        border-color: #4b5563 !important;
    }
}

/* PWA update notification */
.pwa-update-banner {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    background: #3b82f6;
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.pwa-update-banner.show {
    transform: translateY(0);
}

/* Improved accessibility for PWA */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus improvements for keyboard navigation in PWA */
.pwa-focus-visible:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.25rem;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary, .btn-secondary, .btn-success {
        border: 2px solid currentColor;
    }
}

/* Print styles for PWA */
@media print {
    .no-print, #pwa-install-banner, .network-status {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}
