/* pwa-styles.css - Stili per componenti PWA IntornoaMe */

/* Variabili riutilizzate dal tema principale */
:root {
    --pwa-primary: #00ff88;
    --pwa-primary-rgb: 0, 255, 136;
    --pwa-dark: #00cc6a;
    --pwa-bg: #0a0e1a;
    --pwa-bg-dark: #050810;
    --pwa-text: #ffffff;
    --pwa-text-secondary: #94a3b8;
    --pwa-card: rgba(255, 255, 255, 0.03);
    --pwa-border: rgba(255, 255, 255, 0.08);
    --pwa-success: #10b981;
    --pwa-warning: #f59e0b;
    --pwa-danger: #ef4444;
}

/* ============================================
   PULSANTE INSTALLAZIONE
   ============================================ */
.install-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: linear-gradient(135deg, var(--pwa-primary), var(--pwa-dark));
    color: var(--pwa-bg);
    border: none;
    border-radius: 28px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(var(--pwa-primary-rgb), 0.4),
                0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 999;
}

.install-button.show {
    transform: translateY(0);
    opacity: 1;
}

.install-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 32px rgba(var(--pwa-primary-rgb), 0.5),
                0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.install-button svg {
    width: 20px;
    height: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Versione mobile del pulsante */
@media (max-width: 768px) {
    /* Nasconde il floating button su mobile - verrà mostrato solo nel menu */
    .install-button {
        display: none;
    }
}

/* Pulsante nel menu mobile */
.mobile-nav-install {
    margin-top: 1rem;
    padding: 0 1.5rem;
}

.mobile-install-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--pwa-primary), var(--pwa-dark));
    color: var(--pwa-bg);
    border: none;
    border-radius: 16px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(var(--pwa-primary-rgb), 0.4);
    transition: all 0.3s ease;
}

.mobile-install-btn:hover,
.mobile-install-btn:active {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(var(--pwa-primary-rgb), 0.5);
}

.mobile-install-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Versione in-header del pulsante (solo desktop) */
header .install-button {
    position: relative;
    bottom: auto;
    right: auto;
    transform: none;
    opacity: 0;
    padding: 10px 20px;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(var(--pwa-primary-rgb), 0.3);
}

header .install-button.show {
    opacity: 1;
}

/* Nasconde il pulsante header su mobile */
@media (max-width: 768px) {
    header .install-button {
        display: none;
    }
}

/* ============================================
   BANNER AGGIORNAMENTO
   ============================================ */
.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, 
        rgba(var(--pwa-primary-rgb), 0.95), 
        rgba(0, 204, 106, 0.95));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px;
    transform: translateY(-100%);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10000;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

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

.update-content p {
    margin: 0;
    color: var(--pwa-bg);
    font-weight: 500;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.update-banner button {
    padding: 10px 24px;
    border: none;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.update-btn {
    background: var(--pwa-bg);
    color: var(--pwa-primary);
}

.update-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dismiss-btn {
    background: transparent;
    color: var(--pwa-bg);
    border: 2px solid var(--pwa-bg) !important;
}

.dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   INDICATORE OFFLINE
   ============================================ */
.offline-indicator {
    position: fixed;
    bottom: 24px;
    left: 24px;
    background: var(--pwa-danger);
    color: white;
    padding: 12px 20px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
    transform: translateX(-200%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 998;
}

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

.offline-indicator svg {
    width: 16px;
    height: 16px;
    animation: pulse-opacity 2s infinite;
}

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

/* ============================================
   MESSAGGIO SUCCESSO INSTALLAZIONE
   ============================================ */
.install-success {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: var(--pwa-bg-dark);
    border: 2px solid var(--pwa-primary);
    border-radius: 24px;
    padding: 48px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(var(--pwa-primary-rgb), 0.1),
                inset 0 0 60px rgba(var(--pwa-primary-rgb), 0.05);
    opacity: 0;
    animation: successAppear 0.5s forwards;
    z-index: 10001;
}

@keyframes successAppear {
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.install-success.fade-out {
    animation: successDisappear 0.5s forwards;
}

@keyframes successDisappear {
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

.success-content svg {
    margin-bottom: 24px;
    animation: checkmark 0.6s ease-out 0.3s both;
}

@keyframes checkmark {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

.success-content h3 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--pwa-text);
}

.success-content p {
    color: var(--pwa-text-secondary);
    font-size: 16px;
    margin: 0;
}

/* ============================================
   INDICATORE REFRESH (Pull to refresh)
   ============================================ */
.refresh-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--pwa-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--pwa-border);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    animation: refreshDrop 0.5s ease-out;
}

@keyframes refreshDrop {
    0% {
        transform: translateX(-50%) translateY(-100px);
        opacity: 0;
    }
    100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.refresh-spinner {
    animation: spin 1s linear infinite;
    color: var(--pwa-primary);
}

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

/* ============================================
   MODALITÀ STANDALONE
   ============================================ */
.standalone-mode {
    /* Aggiungi padding top per compensare la status bar su iOS */
    padding-top: env(safe-area-inset-top);
}

.standalone-mode .install-button {
    display: none !important;
}

/* Safe areas per iPhone X+ */
.standalone-mode .offline-indicator {
    bottom: calc(24px + env(safe-area-inset-bottom));
}

.standalone-mode .install-button {
    bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ============================================
   ANIMAZIONI GLOBALI
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   MODALITÀ SCURA/CHIARA (se implementata)
   ============================================ */
@media (prefers-color-scheme: light) {
    /* Puoi aggiungere varianti per tema chiaro se necessario */
}

/* ============================================
   UTILITÀ
   ============================================ */
.pwa-hidden {
    display: none !important;
}

.pwa-invisible {
    visibility: hidden !important;
}

.pwa-no-scroll {
    overflow: hidden !important;
}

/* Overlay generico per modal/popup */
.pwa-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pwa-overlay.show {
    opacity: 1;
}

/* ============================================
   POPUP INSTALLAZIONE PERSONALIZZATO
   ============================================ */
.pwa-install-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.pwa-install-popup.show {
    opacity: 1;
    pointer-events: all;
}

.pwa-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pwa-popup-content {
    position: relative;
    background: linear-gradient(145deg, #0f1420, #0a0e1a);
    border: 1px solid rgba(0, 255, 136, 0.2);
    border-radius: 24px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 100px rgba(0, 255, 136, 0.1),
                inset 0 0 30px rgba(0, 255, 136, 0.05);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-install-popup.show .pwa-popup-content {
    transform: scale(1);
}

.pwa-popup-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--pwa-text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.pwa-popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--pwa-text);
    transform: rotate(90deg);
}

.pwa-popup-icon {
    position: relative;
    display: inline-block;
    margin-bottom: 24px;
}

.pwa-popup-icon img {
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.pwa-popup-icon-badge {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: var(--pwa-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.4);
    animation: badge-bounce 2s infinite;
}

@keyframes badge-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.pwa-popup-content h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--pwa-text);
    background: linear-gradient(135deg, #fff, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pwa-popup-content > p {
    color: var(--pwa-text-secondary);
    font-size: 16px;
    margin-bottom: 32px;
    line-height: 1.5;
}

.pwa-popup-features {
    display: flex;
    justify-content: space-around;
    margin-bottom: 32px;
    gap: 20px;
}

.pwa-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pwa-feature svg {
    width: 24px;
    height: 24px;
}

.pwa-feature span {
    font-size: 12px;
    color: var(--pwa-text-secondary);
}

.pwa-popup-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pwa-popup-install {
    background: linear-gradient(135deg, var(--pwa-primary), var(--pwa-dark));
    color: var(--pwa-bg);
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 255, 136, 0.3);
}

.pwa-popup-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 255, 136, 0.4);
}

.pwa-popup-later {
    background: transparent;
    color: var(--pwa-text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pwa-popup-later:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--pwa-text);
}

/* iOS Specific Popup */
.pwa-popup-ios {
    max-width: 380px;
}

.pwa-ios-steps {
    text-align: left;
    margin-bottom: 24px;
}

.pwa-ios-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.pwa-ios-step-number {
    background: var(--pwa-primary);
    color: var(--pwa-bg);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.pwa-ios-step-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.pwa-ios-step-content span {
    color: var(--pwa-text-secondary);
    font-size: 14px;
    line-height: 1.4;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .pwa-popup-content {
        padding: 30px 20px;
    }
    
    .pwa-popup-content h2 {
        font-size: 24px;
    }
    
    .pwa-popup-features {
        flex-wrap: wrap;
    }
    
    .pwa-feature span {
        font-size: 11px;
    }
    
    .pwa-popup-install,
    .pwa-popup-later {
        font-size: 15px;
        padding: 14px 24px;
    }
}
