/**
 * PWA Install Banner - Design Innovant
 * Effets glassmorphism, particules, animations fluides
 */

/* Container principal avec glassmorphism */
.pwa-install-banner {
    position: fixed;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999;
    width: calc(100% - 2rem);
    max-width: 420px;
    border-radius: 24px;
    overflow: hidden;
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-install-banner.show {
    bottom: 24px;
    opacity: 1;
}

.pwa-install-banner.hide {
    bottom: -200px;
    opacity: 0;
    transform: translateX(-50%) scale(0.9);
}

/* Fond animé avec dégradé */
.pwa-install-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 111, 177, 0.15) 0%,
        rgba(165, 107, 255, 0.15) 50%,
        rgba(59, 130, 246, 0.15) 100%
    );
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: -2;
}

/* Bordure animée arc-en-ciel */
.pwa-install-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 24px;
    padding: 2px;
    background: linear-gradient(
        var(--border-angle, 0deg),
        #FF6FB1,
        #A56BFF,
        #3B82F6,
        #10B981,
        #F59E0B,
        #FF6FB1
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: border-rotate 4s linear infinite;
    z-index: -1;
}

@keyframes border-rotate {
    to { --border-angle: 360deg; }
}

/* Support pour la variable CSS animée */
@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}


/* Fond sombre semi-transparent */
.pwa-install-banner .pwa-bg {
    position: absolute;
    inset: 2px;
    background: rgba(10, 10, 20, 0.85);
    border-radius: 22px;
    z-index: -1;
}

/* Particules flottantes */
.pwa-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 24px;
    pointer-events: none;
}

.pwa-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #FF6FB1;
    border-radius: 50%;
    opacity: 0;
    animation: particle-float 3s ease-in-out infinite;
}

.pwa-particle:nth-child(1) { left: 10%; animation-delay: 0s; background: #FF6FB1; }
.pwa-particle:nth-child(2) { left: 30%; animation-delay: 0.5s; background: #A56BFF; }
.pwa-particle:nth-child(3) { left: 50%; animation-delay: 1s; background: #3B82F6; }
.pwa-particle:nth-child(4) { left: 70%; animation-delay: 1.5s; background: #10B981; }
.pwa-particle:nth-child(5) { left: 90%; animation-delay: 2s; background: #F59E0B; }

@keyframes particle-float {
    0% {
        bottom: -10px;
        opacity: 0;
        transform: scale(0);
    }
    20% {
        opacity: 1;
        transform: scale(1);
    }
    80% {
        opacity: 1;
    }
    100% {
        bottom: 100%;
        opacity: 0;
        transform: scale(0.5);
    }
}

/* Contenu principal */
.pwa-install-content {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    z-index: 1;
}

/* Icône de l'app */
.pwa-install-icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(255, 111, 177, 0.3), rgba(165, 107, 255, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 4px 15px rgba(255, 111, 177, 0.3);
    animation: icon-pulse 2s ease-in-out infinite;
}

.pwa-install-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes icon-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Texte */
.pwa-install-text {
    flex: 1;
    min-width: 0;
}

.pwa-install-text strong {
    display: block;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    background: linear-gradient(90deg, #fff, #FF6FB1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pwa-install-text span {
    display: block;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Actions */
.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Bouton installer */
.pwa-install-btn {
    position: relative;
    padding: 0.85rem 1.75rem;
    background: linear-gradient(135deg, #FF6FB1, #A56BFF);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(255, 111, 177, 0.4);
}

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

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

.pwa-install-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 30px rgba(255, 111, 177, 0.6);
}

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

/* Bouton fermer */
.pwa-install-dismiss {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-install-dismiss:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: rotate(90deg);
}

/* iOS specific */
.pwa-install-ios .pwa-install-text span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.ios-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 1rem;
}

.pwa-install-ios .pwa-install-dismiss {
    width: auto;
    padding: 0.6rem 1.5rem;
    background: linear-gradient(135deg, #FF6FB1, #A56BFF);
    color: white;
    font-weight: 600;
    border-radius: 25px;
    border: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .pwa-install-banner {
        left: 0.75rem;
        right: 0.75rem;
        transform: none;
        width: auto;
        max-width: none;
        border-radius: 20px;
    }
    
    .pwa-install-banner.show {
        bottom: 16px;
    }
    
    .pwa-install-content {
        padding: 1rem;
        gap: 0.875rem;
    }
    
    .pwa-install-icon {
        width: 50px;
        height: 50px;
        border-radius: 12px;
    }
    
    .pwa-install-text strong {
        font-size: 1rem;
    }
    
    .pwa-install-text span {
        font-size: 0.8rem;
    }
    
    .pwa-install-btn {
        padding: 0.7rem 1.25rem;
        font-size: 0.85rem;
    }
    
    .pwa-install-dismiss {
        width: 32px;
        height: 32px;
    }
}

/* Animation d'entrée spéciale */
.pwa-install-banner.show .pwa-install-icon {
    animation: icon-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes icon-bounce {
    0% { transform: scale(0) rotate(-180deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.pwa-install-banner.show .pwa-install-text {
    animation: text-slide 0.5s ease 0.3s both;
}

@keyframes text-slide {
    0% { opacity: 0; transform: translateX(-20px); }
    100% { opacity: 1; transform: translateX(0); }
}

.pwa-install-banner.show .pwa-install-btn {
    animation: btn-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
}

@keyframes btn-pop {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1); }
}

/* ============================================
   PWA ADVANCED COMPONENTS
   ============================================ */

/* Bouton favoris */
.pwa-favorite-btn {
    position: relative;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s ease;
    padding: 0.5rem;
}

.pwa-favorite-btn:hover { transform: scale(1.2); }
.pwa-favorite-btn.active { animation: heart-beat 0.4s ease; }

@keyframes heart-beat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1); }
    75% { transform: scale(1.2); }
}

/* Badge live */
.pwa-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    background: #ef4444;
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    animation: live-pulse 2s ease-in-out infinite;
}

.pwa-live-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: live-dot 1s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

@keyframes live-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Bouton partage */
.pwa-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-share-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Network status indicator */
.pwa-network-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 99999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.pwa-network-status.offline {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    color: white;
    transform: translateY(0);
}

.pwa-network-status.slow {
    background: linear-gradient(90deg, #f59e0b, #d97706);
    color: white;
    transform: translateY(0);
}

/* Scroll to top button */
.pwa-scroll-top {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #FF6FB1, #A56BFF);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(255, 111, 177, 0.4);
    z-index: 9999;
}

.pwa-scroll-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pwa-scroll-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(255, 111, 177, 0.6);
}

/* Shortcut menu */
.pwa-shortcuts-menu {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem;
}

.pwa-shortcut {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: white;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pwa-shortcut:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.pwa-shortcut-icon { font-size: 2rem; }
.pwa-shortcut-name { font-size: 0.85rem; opacity: 0.8; }

/* Progress bar for donations */
.pwa-progress-bar {
    position: relative;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.pwa-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FF6FB1, #A56BFF, #3B82F6);
    background-size: 200% 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
    animation: progress-shine 2s linear infinite;
}

@keyframes progress-shine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Countdown timer */
.pwa-countdown {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.pwa-countdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    min-width: 60px;
}

.pwa-countdown-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #FF6FB1;
}

.pwa-countdown-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
}

/* Standalone mode specific styles */
@media (display-mode: standalone) {
    body { padding-top: env(safe-area-inset-top); }
    
    .pwa-install-banner { display: none !important; }
    
    /* Bottom nav safe area */
    .bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
}
