/* ============================================
   PHARMADIS - PWA Styles
   Modal d'installation, bannières, statut réseau
   ============================================ */

/* === VARIABLES PWA === */
:root {
    --pwa-primary: #1a1a6e;
    --pwa-primary-dark: #0d0d3d;
    --pwa-accent: #E91E8C;
    --pwa-accent-light: #F5A9D3;
    --pwa-gold: #D4A853;
    --pwa-success: #28A745;
    --pwa-white: #FFFFFF;
    --pwa-overlay: rgba(13, 13, 61, 0.7);
    --pwa-radius: 20px;
    --pwa-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* ============================================
   MODAL D'INSTALLATION PWA - Design Premium
   ============================================ */
.pwa-install-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--pwa-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-install-overlay.active {
    opacity: 1;
    visibility: visible;
}

.pwa-install-modal {
    background: var(--pwa-white);
    border-radius: var(--pwa-radius);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    box-shadow: var(--pwa-shadow);
    transform: translateY(40px) scale(0.95);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.pwa-install-overlay.active .pwa-install-modal {
    transform: translateY(0) scale(1);
}

/* Header du modal avec gradient */
.pwa-modal-header {
    background: linear-gradient(135deg, var(--pwa-primary) 0%, var(--pwa-primary-dark) 60%, var(--pwa-accent) 100%);
    padding: 32px 28px 28px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.pwa-modal-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(233, 30, 140, 0.15) 0%, transparent 60%);
    animation: pwa-glow 8s ease-in-out infinite;
}

@keyframes pwa-glow {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(10%, -10%); }
    66% { transform: translate(-10%, 10%); }
}

.pwa-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.pwa-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.pwa-modal-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    margin: 0 auto 16px;
    position: relative;
    z-index: 1;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    background: white;
}

.pwa-modal-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pwa-modal-header h2 {
    color: white;
    font-family: 'Poppins', sans-serif;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.pwa-modal-header p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    position: relative;
    z-index: 1;
}

/* Corps du modal */
.pwa-modal-body {
    padding: 24px 28px;
}

.pwa-features-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.pwa-feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8f9ff;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.pwa-feature-item:hover {
    background: #eef0ff;
    transform: translateY(-2px);
}

.pwa-feature-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.pwa-feature-icon.speed { background: linear-gradient(135deg, #e3f2fd, #bbdefb); }
.pwa-feature-icon.offline { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); }
.pwa-feature-icon.notif { background: linear-gradient(135deg, #fce4ec, #f8bbd0); }
.pwa-feature-icon.secure { background: linear-gradient(135deg, #fff3e0, #ffe0b2); }

.pwa-feature-text {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

/* Boutons du modal */
.pwa-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pwa-install-btn {
    width: 100%;
    padding: 15px 24px;
    border: none;
    border-radius: 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.pwa-install-btn-primary {
    background: linear-gradient(135deg, var(--pwa-primary) 0%, var(--pwa-accent) 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(26, 26, 110, 0.35);
}

.pwa-install-btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.pwa-install-btn-primary:hover::before {
    left: 100%;
}

.pwa-install-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(26, 26, 110, 0.45);
}

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

.pwa-install-btn-secondary {
    background: transparent;
    color: #888;
    font-size: 14px;
    font-weight: 500;
    padding: 10px;
}

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

/* ============================================
   BANNIÈRE D'INSTALLATION - Bottom Banner
   ============================================ */
.pwa-install-banner {
    position: fixed;
    bottom: 70px;
    left: 12px;
    right: 12px;
    background: white;
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(150%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(26, 26, 110, 0.08);
}

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

.pwa-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pwa-banner-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pwa-banner-content {
    flex: 1;
    min-width: 0;
}

.pwa-banner-title {
    font-weight: 700;
    font-size: 14px;
    color: #1a1a6e;
    margin-bottom: 2px;
}

.pwa-banner-text {
    font-size: 12px;
    color: #777;
    line-height: 1.3;
}

.pwa-banner-install {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--pwa-primary), var(--pwa-accent));
    color: white;
    border: none;
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.pwa-banner-install:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(26, 26, 110, 0.3);
}

.pwa-banner-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.pwa-banner-close:hover {
    background: #e0e0e0;
    color: #555;
}

/* ============================================
   INSTRUCTIONS iOS - Modal spécifique Safari
   ============================================ */
.pwa-ios-modal {
    padding: 0;
}

.pwa-ios-body {
    padding: 24px 28px;
}

.pwa-ios-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.pwa-ios-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px;
    background: #f8f9ff;
    border-radius: 14px;
    transition: all 0.3s ease;
}

.pwa-ios-step:hover {
    background: #eef0ff;
}

.pwa-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pwa-primary), var(--pwa-accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

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

.pwa-step-content strong {
    display: block;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
}

.pwa-step-content span {
    font-size: 12px;
    color: #777;
    line-height: 1.4;
}

.pwa-ios-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #007AFF;
    color: white;
    border-radius: 6px;
    font-size: 16px;
    vertical-align: middle;
    margin: 0 2px;
}

/* ============================================
   INDICATEUR RÉSEAU HORS LIGNE
   ============================================ */
.pwa-offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    text-align: center;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100000;
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 12px rgba(238, 90, 36, 0.3);
}

.pwa-offline-bar.active {
    transform: translateY(0);
}

.pwa-offline-bar .offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.pwa-online-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    text-align: center;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100000;
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pwa-online-bar.active {
    transform: translateY(0);
}

/* ============================================
   NOTIFICATION DE MISE À JOUR
   ============================================ */
.pwa-update-banner {
    position: fixed;
    bottom: 70px;
    left: 12px;
    right: 12px;
    background: linear-gradient(135deg, #1a1a6e, #2a2a8e);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 8px 40px rgba(26, 26, 110, 0.3);
    z-index: 9997;
    display: flex;
    align-items: center;
    gap: 14px;
    transform: translateY(150%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    color: white;
}

.pwa-update-banner.active {
    transform: translateY(0);
}

.pwa-update-icon {
    font-size: 28px;
    flex-shrink: 0;
}

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

.pwa-update-content strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.pwa-update-content span {
    font-size: 12px;
    opacity: 0.8;
}

.pwa-update-btn {
    padding: 10px 20px;
    background: white;
    color: var(--pwa-primary);
    border: none;
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

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

/* ============================================
   TOAST NOTIFICATIONS PWA
   ============================================ */
.pwa-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: white;
    border-radius: 14px;
    padding: 14px 22px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 100001;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 90%;
    border-left: 4px solid var(--pwa-success);
}

.pwa-toast.active {
    transform: translateX(-50%) translateY(0);
}

.pwa-toast.error {
    border-left-color: #DC3545;
}

.pwa-toast-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.pwa-toast-text {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* ============================================
   BADGE "INSTALLÉE" pour PWA Standalone
   ============================================ */
.pwa-standalone-badge {
    display: none;
}

@media all and (display-mode: standalone) {
    .pwa-standalone-badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        background: linear-gradient(135deg, var(--pwa-success), #20c997);
        color: white;
        font-size: 10px;
        font-weight: 700;
        padding: 3px 8px;
        border-radius: 20px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    /* Ajuster le padding top pour standalone */
    body {
        padding-top: env(safe-area-inset-top, 0);
    }
    
    .header {
        padding-top: env(safe-area-inset-top, 0);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .pwa-install-modal {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        position: fixed;
        bottom: 0;
        margin: 0;
    }
    
    .pwa-install-overlay {
        align-items: flex-end;
        padding: 0;
    }
    
    .pwa-install-overlay.active .pwa-install-modal {
        transform: translateY(0);
    }
    
    .pwa-install-modal {
        transform: translateY(100%);
    }
    
    .pwa-modal-header {
        padding: 24px 20px 20px;
        border-radius: 20px 20px 0 0;
    }
    
    .pwa-modal-header::after {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255,255,255,0.3);
        border-radius: 2px;
    }
    
    .pwa-modal-body {
        padding: 20px;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    }
    
    .pwa-features-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .pwa-feature-item {
        padding: 10px;
    }
    
    .pwa-feature-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .pwa-feature-text {
        font-size: 11px;
    }
    
    .pwa-install-banner {
        bottom: 65px;
        left: 8px;
        right: 8px;
    }
    
    .pwa-update-banner {
        bottom: 65px;
        left: 8px;
        right: 8px;
    }
}

@media (max-width: 360px) {
    .pwa-features-grid {
        grid-template-columns: 1fr;
    }
    
    .pwa-modal-header h2 {
        font-size: 18px;
    }
}

/* Animation d'entrée des éléments */
.pwa-install-overlay.active .pwa-feature-item {
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

.pwa-install-overlay.active .pwa-feature-item:nth-child(1) { animation-delay: 0.1s; }
.pwa-install-overlay.active .pwa-feature-item:nth-child(2) { animation-delay: 0.2s; }
.pwa-install-overlay.active .pwa-feature-item:nth-child(3) { animation-delay: 0.3s; }
.pwa-install-overlay.active .pwa-feature-item:nth-child(4) { animation-delay: 0.4s; }

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

/* Animation iOS steps */
.pwa-install-overlay.active .pwa-ios-step {
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

.pwa-install-overlay.active .pwa-ios-step:nth-child(1) { animation-delay: 0.15s; }
.pwa-install-overlay.active .pwa-ios-step:nth-child(2) { animation-delay: 0.3s; }
.pwa-install-overlay.active .pwa-ios-step:nth-child(3) { animation-delay: 0.45s; }

/* Confetti animation pour post-install */
.pwa-confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100002;
}
