/* PWA Specific Styles for Sunrise ERP */

/* PWA Install Container */
.pwa-install-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.3);
    padding: 16px 20px;
    max-width: 90vw;
    width: auto;
    min-width: 300px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.install-prompt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.install-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.install-content i {
    font-size: 1.2rem;
    color: white;
}

.install-content span {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
}

.install-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pwa-install-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.pwa-install-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.pwa-install-btn i {
    margin-right: 8px;
}

.pwa-dismiss-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
}

.pwa-dismiss-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    color: white;
}

/* PWA Install Modal */
#pwa-install-modal .modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.pwa-instructions {
    text-align: center;
    padding: 2rem 1rem;
}

.pwa-instructions .pwa-icon {
    font-size: 4rem;
    color: #f59e0b;
    margin-bottom: 1rem;
}

.pwa-instructions h6 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #1e293b;
}

.instruction-steps {
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
}

.instruction-steps ol {
    padding-left: 1.5rem;
}

.instruction-steps li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ef4444;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    z-index: 9999;
    font-size: 14px;
    font-weight: 500;
}

.offline-indicator i {
    margin-right: 8px;
}

/* Update Notification */
.update-notification {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: #1e293b;
    color: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    max-width: 400px;
    margin: 0 auto;
}

.update-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.update-text {
    display: flex;
    align-items: center;
    flex: 1;
}

.update-text i {
    margin-right: 12px;
    color: #f59e0b;
    animation: spin 2s linear infinite;
}

.update-actions {
    display: flex;
    gap: 8px;
}

.update-actions .btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* PWA Animations */
@keyframes pwa-pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(245, 158, 11, 0.5);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Standalone Mode Adjustments */
@media (display-mode: standalone) {
    /* Adjust layout for standalone PWA mode */
    body {
        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);
    }
    
    /* Hide browser-specific elements */
    .browser-only {
        display: none !important;
    }
    
    /* Adjust header for notch/status bar */
    .sidebar-header {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
    
    /* Add PWA indicator */
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: linear-gradient(90deg, #f59e0b, #d97706);
        z-index: 10000;
    }
}

/* Mobile PWA Optimizations */
@media (max-width: 768px) {
    .pwa-install-container {
        margin: 0.5rem;
        padding: 0.75rem;
    }
    
    .offline-indicator {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
        font-size: 12px;
        padding: 10px;
    }
    
    .update-notification {
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .update-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .update-text {
        justify-content: center;
        text-align: center;
    }
    
    .update-actions {
        justify-content: center;
    }
}

/* High DPI Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    .pwa-install-btn {
        background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .pwa-instructions {
        color: #e2e8f0;
    }
    
    .pwa-instructions h6 {
        color: #f1f5f9;
    }
    
    #pwa-install-modal .modal-content {
        background-color: #1e293b;
        color: #e2e8f0;
    }
}

/* Print Styles - Hide PWA elements */
@media print {
    .pwa-install-container,
    .offline-indicator,
    .update-notification {
        display: none !important;
    }
}

/* Focus Styles for Accessibility */
.pwa-install-btn:focus,
.pwa-dismiss-btn:focus,
.update-actions .btn:focus {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
}

/* Reduce Motion for Users who Prefer it */
@media (prefers-reduced-motion: reduce) {
    .pwa-install-container {
        animation: none;
    }
    
    .update-text i {
        animation: none;
    }
    
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Loading States */
.pwa-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pwa-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

/* Success States */
.pwa-success {
    color: #10b981;
}

.pwa-success i {
    margin-right: 8px;
}

/* Error States */
.pwa-error {
    color: #ef4444;
}

.pwa-error i {
    margin-right: 8px;
}
