/**
 * Team Portal - PWA Styles
 * 
 * Styles for:
 * - Install prompt
 * - Update notification
 * - Online/Offline status
 * - Standalone mode adjustments
 * - Touch-friendly UI
 * 
 * @package    Team Portal
 * @subpackage PWA
 * @version    3.0.0
 */

/*==================================================
  Install Prompt
==================================================*/
.pwa-install-prompt {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.pwa-install-prompt.show {
    opacity: 1;
    visibility: visible;
}

.pwa-install-dialog {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.pwa-install-prompt.show .pwa-install-dialog {
    transform: scale(1);
}

.pwa-install-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.pwa-install-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pwa-install-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 12px;
}

.pwa-install-message {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 30px;
}

.pwa-install-actions {
    display: flex;
    gap: 12px;
}

.pwa-install-accept,
.pwa-install-cancel {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pwa-install-accept {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.pwa-install-accept:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.pwa-install-cancel {
    background: #f3f4f6;
    color: #6b7280;
}

.pwa-install-cancel:hover {
    background: #e5e7eb;
}

/*==================================================
  Update Notification
==================================================*/
.pwa-update-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    z-index: 999998;
    transform: translateX(calc(100% + 40px));
    transition: transform 0.3s ease;
}

.pwa-update-notification.show {
    transform: translateX(0);
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pwa-update-icon {
    font-size: 28px;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pwa-update-message {
    flex: 1;
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
}

.pwa-update-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.pwa-update-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/*==================================================
  Status Notification (Online/Offline)
==================================================*/
.pwa-status-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: white;
    padding: 16px 24px;
    border-radius: 50px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 999997;
    transition: transform 0.3s ease;
}

.pwa-status-notification.show {
    transform: translateX(-50%) translateY(0);
}

.pwa-status-notification.offline {
    background: #fef3c7;
    border: 2px solid #fbbf24;
}

.pwa-status-notification.online {
    background: #d1fae5;
    border: 2px solid #10b981;
}

.pwa-status-icon {
    font-size: 24px;
}

.pwa-status-message {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

/*==================================================
  Enable Notifications Button
==================================================*/
.pwa-enable-notifications {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
    }
}

/*==================================================
  Standalone Mode Adjustments
==================================================*/
.pwa-installed {
    /* Add padding for safe areas on iOS */
    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);
}

.pwa-installed #wpadminbar {
    /* Adjust admin bar in standalone mode */
    top: env(safe-area-inset-top);
}

.pwa-installed #wpbody-content {
    /* Adjust content area */
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

/*==================================================
  Loading Screen for PWA
==================================================*/
.pwa-loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.pwa-loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.pwa-loading-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    animation: bounceIn 1s ease;
}

.pwa-loading-text {
    color: white;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
}

.pwa-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/*==================================================
  PWA Status Indicator (Admin Bar)
==================================================*/
#wp-admin-bar-pwa-status .ab-icon {
    font-size: 16px;
    margin-right: 6px;
}

#wp-admin-bar-pwa-status .ab-label {
    font-size: 12px;
}

/*==================================================
  Touch-Friendly Adjustments
==================================================*/
@media (hover: none) and (pointer: coarse) {
    /* Make buttons larger on touch devices */
    button,
    .button,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
    
    /* Increase tap target size */
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    /* Remove hover effects */
    *:hover {
        transform: none !important;
    }
}

/*==================================================
  Responsive Design
==================================================*/
@media (max-width: 768px) {
    .pwa-install-dialog {
        padding: 30px;
    }
    
    .pwa-install-icon {
        width: 80px;
        height: 80px;
    }
    
    .pwa-install-title {
        font-size: 20px;
    }
    
    .pwa-install-message {
        font-size: 14px;
    }
    
    .pwa-update-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .pwa-update-content {
        flex-wrap: wrap;
    }
    
    .pwa-update-btn {
        width: 100%;
        margin-top: 10px;
    }
}

/*==================================================
  Dark Mode Support
==================================================*/
@media (prefers-color-scheme: dark) {
    .pwa-install-dialog {
        background: #1e293b;
    }
    
    .pwa-install-title {
        color: #f1f5f9;
    }
    
    .pwa-install-message {
        color: #cbd5e1;
    }
    
    .pwa-install-cancel {
        background: #334155;
        color: #e2e8f0;
    }
    
    .pwa-install-cancel:hover {
        background: #475569;
    }
    
    .pwa-update-notification {
        background: #1e293b;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
    
    .pwa-update-message {
        color: #e2e8f0;
    }
    
    .pwa-status-notification {
        background: #1e293b;
    }
    
    .pwa-status-notification.offline {
        background: #422006;
        border-color: #f59e0b;
    }
    
    .pwa-status-notification.online {
        background: #064e3b;
        border-color: #10b981;
    }
    
    .pwa-status-message {
        color: #f1f5f9;
    }
}

/*==================================================
  Print Styles
==================================================*/
@media print {
    .pwa-install-prompt,
    .pwa-update-notification,
    .pwa-status-notification,
    .pwa-enable-notifications,
    .pwa-loading-screen {
        display: none !important;
    }
}

/*==================================================
  Accessibility
==================================================*/
.pwa-install-prompt:focus-within,
.pwa-update-notification:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 4px;
}

button:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
