/**
 * Styles pour les composants PWA
 * Bouton d'installation, notifications de mise à jour, indicateurs
 */

/* ============================================
   BOUTON D'INSTALLATION PWA
   ============================================ */

.pwa-install-button {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 9998;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(100px);
    pointer-events: none;
}

.pwa-install-button.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.pwa-install-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.6);
}

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

.pwa-install-button svg {
    width: 20px;
    height: 20px;
}

/* Responsive mobile */
@media (max-width: 768px) {
    .pwa-install-button {
        left: 50%;
        transform: translateX(-50%) translateY(100px);
        bottom: 20px;
        padding: 12px 20px;
        font-size: 14px;
    }

    .pwa-install-button.visible {
        transform: translateX(-50%) translateY(0);
    }

    .pwa-install-button:hover {
        transform: translateX(-50%) translateY(-3px);
    }
}

/* ============================================
   NOTIFICATION DE MISE À JOUR
   ============================================ */

.pwa-update-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateX(450px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-update-notification.visible {
    opacity: 1;
    transform: translateX(0);
}

.pwa-update-content {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.pwa-update-icon {
    font-size: 36px;
    animation: rotate 2s linear infinite;
}

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

.pwa-update-text {
    flex: 1;
}

.pwa-update-text strong {
    display: block;
    font-size: 16px;
    color: #333;
    margin-bottom: 5px;
}

.pwa-update-text p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.pwa-update-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.pwa-update-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.pwa-update-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.pwa-update-close:hover {
    background: #f0f0f0;
    color: #333;
}

@media (max-width: 768px) {
    .pwa-update-notification {
        left: 10px;
        right: 10px;
        max-width: none;
        top: 10px;
        transform: translateY(-150px);
    }

    .pwa-update-notification.visible {
        transform: translateY(0);
    }

    .pwa-update-content {
        flex-wrap: wrap;
        padding: 15px;
    }

    .pwa-update-btn {
        width: 100%;
        margin-top: 10px;
    }
}

/* ============================================
   INDICATEUR HORS LIGNE
   ============================================ */

.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff9800;
    color: white;
    padding: 12px 20px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

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

/* Décaler le contenu quand l'indicateur est visible */
body.offline {
    padding-top: 48px;
}

/* ============================================
   MESSAGE DE SUCCÈS
   ============================================ */

.pwa-success-message {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10001;
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-success-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.pwa-success-content {
    background: #4caf50;
    color: white;
    padding: 18px 25px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
}

@media (max-width: 768px) {
    .pwa-success-message {
        bottom: 20px;
        right: 20px;
        left: 20px;
    }

    .pwa-success-content {
        text-align: center;
        justify-content: center;
    }
}

/* ============================================
   MODE STANDALONE (APP INSTALLÉE)
   ============================================ */

.pwa-standalone {
    /* Styles spécifiques quand l'app est installée */
}

/* Masquer certains éléments en mode standalone */
.pwa-standalone .browser-only {
    display: none !important;
}

/* Ajuster le header en mode standalone (pas de barre d'URL) */
.pwa-standalone header {
    padding-top: env(safe-area-inset-top, 0);
}

/* ============================================
   SPLASH SCREEN (iOS)
   ============================================ */

/* Le splash screen est géré via les meta tags dans le HTML */
/* Mais on peut ajouter un loader initial */

.pwa-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.pwa-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.pwa-loading-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
}

.pwa-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.pwa-loading-text {
    margin-top: 20px;
    font-size: 16px;
    color: #666;
}

/* ============================================
   BOUTON PERMISSION NOTIFICATIONS
   ============================================ */

.notification-permission-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border-radius: 12px;
    margin: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.notification-permission-banner .content {
    flex: 1;
}

.notification-permission-banner h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
}

.notification-permission-banner p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.notification-permission-banner .actions {
    display: flex;
    gap: 10px;
}

.notification-permission-banner button {
    background: white;
    color: #667eea;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.notification-permission-banner button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

.notification-permission-banner button.dismiss {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.notification-permission-banner button.dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   SAFE AREAS (iPhone X et plus)
   ============================================ */

@supports (padding: env(safe-area-inset-top)) {
    .pwa-install-button {
        bottom: calc(30px + env(safe-area-inset-bottom));
    }

    .offline-indicator {
        padding-top: calc(12px + env(safe-area-inset-top));
    }

    .pwa-update-notification {
        top: calc(20px + env(safe-area-inset-top));
    }
}

/* ============================================
   MODE SOMBRE POUR LES COMPOSANTS PWA
   ============================================ */

:root[data-theme="dark"] .pwa-update-notification {
    background: #2d2d2d;
}

:root[data-theme="dark"] .pwa-update-text strong {
    color: #e0e0e0;
}

:root[data-theme="dark"] .pwa-update-text p {
    color: #b0b0b0;
}

:root[data-theme="dark"] .pwa-update-close:hover {
    background: #404040;
    color: #e0e0e0;
}

:root[data-theme="dark"] .pwa-loading {
    background: #1a1a1a;
}

:root[data-theme="dark"] .pwa-loading-text {
    color: #b0b0b0;
}

:root[data-theme="dark"] .pwa-loading-spinner {
    border-color: #404040;
    border-top-color: #667eea;
}

/* ============================================
   ANIMATIONS SUPPLÉMENTAIRES
   ============================================ */

@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-in-bottom {
    animation: slideInFromBottom 0.4s ease-out;
}

.animate-slide-in-right {
    animation: slideInFromRight 0.4s ease-out;
}
