/* PWA Enhancement Styles */
/* Progressive Web App UI Elements and Features */

:root {
    --pwa-primary: #4CAF50;
    --pwa-secondary: #2196F3;
    --pwa-success: #4CAF50;
    --pwa-warning: #FF9800;
    --pwa-error: #F44336;
    --pwa-offline: #9E9E9E;
    --pwa-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --pwa-shadow-elevated: 0 4px 8px rgba(0,0,0,0.15);
    --pwa-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 12px;
    box-shadow: var(--pwa-shadow-elevated);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 90%;
    width: 400px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--pwa-transition);
}

.pwa-install-banner.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.pwa-install-banner.hide {
    transform: translateX(-50%) translateY(100px);
}

.pwa-install-icon {
    width: 48px;
    height: 48px;
    background: var(--pwa-primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pwa-install-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

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

.pwa-install-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.pwa-install-text {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

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

.pwa-install-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--pwa-transition);
}

.pwa-install-btn.primary {
    background: var(--pwa-primary);
    color: white;
}

.pwa-install-btn.primary:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.pwa-install-btn.secondary {
    background: transparent;
    color: #666;
}

.pwa-install-btn.secondary:hover {
    background: #f5f5f5;
}

/* Offline Indicator */
.pwa-offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--pwa-offline);
    color: white;
    padding: 8px 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pwa-offline-indicator.show {
    transform: translateY(0);
}

.pwa-offline-indicator svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Update Available Banner */
.pwa-update-banner {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--pwa-secondary);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--pwa-shadow-elevated);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

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

.pwa-update-banner svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.pwa-update-btn {
    background: white;
    color: var(--pwa-secondary);
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--pwa-transition);
}

.pwa-update-btn:hover {
    transform: scale(1.05);
}

/* 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.4),
        transparent
    );
    animation: pwa-shimmer 1.5s infinite;
}

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

/* Skeleton Screens */
.pwa-skeleton {
    background: #f0f0f0;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

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

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

.pwa-skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.pwa-skeleton-title {
    height: 24px;
    margin-bottom: 16px;
    border-radius: 4px;
    width: 60%;
}

.pwa-skeleton-card {
    height: 120px;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* Sync Status Indicator */
.pwa-sync-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    box-shadow: var(--pwa-shadow-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--pwa-transition);
    z-index: 900;
}

.pwa-sync-status:hover {
    transform: scale(1.1);
}

.pwa-sync-status.syncing {
    background: var(--pwa-warning);
}

.pwa-sync-status.syncing svg {
    animation: pwa-rotate 1s linear infinite;
}

.pwa-sync-status.success {
    background: var(--pwa-success);
}

.pwa-sync-status.error {
    background: var(--pwa-error);
}

.pwa-sync-status svg {
    width: 24px;
    height: 24px;
    fill: white;
}

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

/* Pull to Refresh */
.pwa-pull-to-refresh {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--pwa-shadow-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: top 0.3s ease;
    z-index: 1000;
}

.pwa-pull-to-refresh.show {
    top: 20px;
}

.pwa-pull-to-refresh.refreshing svg {
    animation: pwa-rotate 1s linear infinite;
}

.pwa-pull-to-refresh svg {
    width: 20px;
    height: 20px;
    fill: var(--pwa-primary);
}

/* Offline Queue Indicator */
.pwa-offline-queue {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: var(--pwa-warning);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--pwa-shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transition: var(--pwa-transition);
}

.pwa-offline-queue.show {
    opacity: 1;
    visibility: visible;
}

.pwa-offline-queue-count {
    background: rgba(255, 255, 255, 0.3);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Progressive Enhancement Classes */
.pwa-enhanced {
    transition: var(--pwa-transition);
}

.pwa-enhanced:hover {
    transform: translateY(-2px);
    box-shadow: var(--pwa-shadow-elevated);
}

/* Touch Feedback */
.pwa-touch-feedback {
    position: relative;
    overflow: hidden;
}

.pwa-touch-feedback::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.pwa-touch-feedback:active::before {
    width: 100%;
    height: 100%;
}

/* App-like Navigation */
.pwa-app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 900;
}

.pwa-app-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    color: #666;
    text-decoration: none;
    transition: var(--pwa-transition);
}

.pwa-app-nav-item:hover,
.pwa-app-nav-item.active {
    color: var(--pwa-primary);
}

.pwa-app-nav-item svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.pwa-app-nav-label {
    font-size: 12px;
    font-weight: 500;
}

/* Responsive Design for PWA */
@media (max-width: 768px) {
    .pwa-install-banner {
        bottom: 70px; /* Above app navigation */
        width: calc(100% - 32px);
        margin: 0 16px;
        left: 0;
        transform: none;
    }
    
    .pwa-install-banner.show {
        transform: none;
    }
    
    .pwa-install-banner.hide {
        transform: translateY(100px);
    }
    
    .pwa-update-banner {
        top: auto;
        bottom: 120px;
        right: 16px;
        left: 16px;
        transform: translateY(200px);
    }
    
    .pwa-update-banner.show {
        transform: translateY(0);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) and (prefers-color-scheme: light) {
    .pwa-install-banner,
    .pwa-sync-status {
        background: #2a2a2a;
        color: white;
    }
    
    .pwa-install-title {
        color: white;
    }
    
    .pwa-install-text {
        color: #ccc;
    }
    
    .pwa-install-btn.secondary {
        color: #ccc;
    }
    
    .pwa-install-btn.secondary:hover {
        background: #333;
    }
    
    .pwa-skeleton {
        background: #333;
    }
    
    .pwa-skeleton::after {
        background: linear-gradient(
            90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent
        );
    }
    
    .pwa-app-nav {
        background: #1a1a1a;
        border-top-color: #333;
    }
    
    .pwa-app-nav-item {
        color: #999;
    }
}

/* Accessibility Improvements */
.pwa-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Visible for Keyboard Navigation */
.pwa-enhanced:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .pwa-enhanced,
    .pwa-install-banner,
    .pwa-update-banner,
    .pwa-offline-indicator,
    .pwa-sync-status {
        transition: none;
    }
    
    .pwa-loading::after,
    .pwa-skeleton::after,
    .pwa-sync-status.syncing svg,
    .pwa-pull-to-refresh.refreshing svg {
        animation: none;
    }
}