/* PWA Enhancement Styles for Blazor WebAssembly */

/* Connectivity Status Indicator */
.connectivity-status {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.connectivity-status.online {
    background-color: #28a745;
    color: white;
}

.connectivity-status.offline.ready {
    background-color: #17a2b8;
    color: white;
}

.connectivity-status.offline.limited {
    background-color: #ffc107;
    color: #212529;
}

/* Offline Ready Indicator */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.offline-indicator.ready {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.offline-indicator.limited {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* PWA Install Button */
.pwa-install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    display: none;
}

.pwa-install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.pwa-install-button:active {
    transform: translateY(0);
}

/* Update Notification */
.update-notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    z-index: 9999;
    display: none;
    animation: slideDown 0.3s ease;
}

.update-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.update-content span {
    font-weight: 500;
}

.update-content button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 16px;
    border-radius: 4px;
    margin-left: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.update-content button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.update-content button:first-of-type {
    background: rgba(255, 255, 255, 0.9);
    color: #17a2b8;
    font-weight: 600;
}

.update-content button:first-of-type:hover {
    background: white;
}

/* Offline Ready Toast */
.offline-ready-toast {
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 4.7s;
}

/* Body States for Global Styling */
body.app-offline {
    /* Add any global offline styles */
}

body.app-online {
    /* Add any global online styles */
}

body.offline-ready {
    /* Add styles when app is ready for offline use */
}

/* Loading States for Offline */
.app-offline .loading-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.app-offline .loading-message::after {
    content: " (Offline Mode)";
    color: #17a2b8;
    font-weight: 500;
}

/* Offline Message Styles */
.offline-message {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3);
}

.offline-message h3 {
    margin: 0 0 10px 0;
    font-weight: 600;
}

.offline-message p {
    margin: 0;
    opacity: 0.9;
}

/* PWA Splash Screen Enhancement */
@media (display-mode: standalone) {
    /* Styles specific to PWA mode */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .connectivity-status {
        top: calc(10px + env(safe-area-inset-top));
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .connectivity-status {
        top: 5px;
        right: 5px;
        font-size: 11px;
        padding: 4px 8px;
    }

    .offline-indicator {
        bottom: 10px;
        left: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }

    .pwa-install-button {
        bottom: 10px;
        right: 10px;
        padding: 10px 20px;
        font-size: 12px;
    }

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

    .update-content button {
        margin: 0 5px;
    }
}

/* Animations */
@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Blazor Loading Enhancement for Offline */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Enhanced loading screen for offline scenarios */
.blazor-loading-offline {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.blazor-loading-offline .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #dee2e6;
    border-top: 4px solid #17a2b8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.blazor-loading-offline .message {
    color: #495057;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    text-align: center;
    max-width: 300px;
}

.blazor-loading-offline .offline-badge {
    background: #17a2b8;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Network status indicators in navigation */
.navbar .network-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
}

.navbar .network-status.online {
    color: #28a745;
}

.navbar .network-status.offline {
    color: #ffc107;
}

.navbar .network-status::before {
    content: "●";
    font-size: 16px;
}