/**
 * MyEventPics - PWA Styles
 * Stili per Progressive Web App e funzionalità mobile-first
 */

/* ==========================================================================
   PWA Install Button
   ========================================================================== */

.pwa-install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pwa-install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

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

.pwa-install-button i {
    font-size: 16px;
}

/* Nascondi il pulsante quando l'app è installata */
.pwa-installed .pwa-install-button {
    display: none !important;
}

/* ==========================================================================
   Network Status Indicator
   ========================================================================== */

.network-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1001;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.network-indicator.online {
    background: rgba(34, 197, 94, 0.9);
    color: white;
    opacity: 0;
    pointer-events: none;
}

.network-indicator.offline {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    opacity: 1;
    animation: pulse 2s infinite;
}

/* ==========================================================================
   PWA Notifications
   ========================================================================== */

.pwa-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1002;
    max-width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid #3b82f6;
}

.pwa-notification.success {
    border-left-color: #10b981;
}

.pwa-notification.warning {
    border-left-color: #f59e0b;
}

.pwa-notification.error {
    border-left-color: #ef4444;
}

.pwa-notification.info {
    border-left-color: #3b82f6;
}

.notification-content {
    padding: 16px;
    padding-right: 40px;
}

.notification-title {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 4px;
}

.notification-message {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

.notification-action {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s ease;
}

.notification-action:hover {
    background: #2563eb;
}

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

.notification-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* ==========================================================================
   Notification Button
   ========================================================================== */

.notification-button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #475569;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notification-button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.notification-button i {
    color: #3b82f6;
}

/* ==========================================================================
   Mobile-First Responsive Design
   ========================================================================== */

/* Mobile First - Base styles per mobile */
@media (max-width: 768px) {
    .pwa-install-button {
        bottom: 80px; /* Sopra la navigation bar mobile */
        right: 15px;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .pwa-install-button span {
        display: none; /* Mostra solo l'icona su mobile */
    }
    
    .pwa-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .network-indicator {
        top: 5px;
        right: 5px;
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .pwa-install-button {
        bottom: 25px;
        right: 25px;
    }
}

/* Desktop */
@media (min-width: 1025px) {
    .pwa-install-button {
        bottom: 30px;
        right: 30px;
    }
}

/* ==========================================================================
   PWA Standalone Mode
   ========================================================================== */

/* Stili quando l'app è in modalità standalone */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Nascondi elementi non necessari in modalità app */
    .browser-only {
        display: none !important;
    }
    
    /* Aggiusta l'header per la modalità standalone */
    header {
        padding-top: env(safe-area-inset-top);
    }
}

/* iOS Safari specifico */
@supports (-webkit-touch-callout: none) {
    @media (display-mode: standalone) {
        body {
            padding-top: constant(safe-area-inset-top);
            padding-bottom: constant(safe-area-inset-bottom);
        }
        
        header {
            padding-top: constant(safe-area-inset-top);
        }
    }
}

/* ==========================================================================
   Touch and Gesture Optimizations
   ========================================================================== */

/* Migliora l'area di tocco per elementi interattivi */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Rimuovi il highlight di tocco su iOS */
.no-touch-highlight {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Migliora lo scrolling su iOS */
.smooth-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ==========================================================================
   Loading States per PWA
   ========================================================================== */

.pwa-loading {
    position: relative;
    overflow: hidden;
}

.pwa-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ==========================================================================
   Offline Indicators
   ========================================================================== */

.offline-indicator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ef4444;
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

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

/* ==========================================================================
   Share Button Styles
   ========================================================================== */

.share-button {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    color: #475569;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.share-button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.share-button.native-share {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.share-button.native-share:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

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

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

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

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.pwa-fade-in {
    animation: fadeIn 0.3s ease;
}

.pwa-slide-up {
    animation: slideUp 0.3s ease;
}

.pwa-hidden {
    display: none !important;
}

.pwa-visible {
    display: block !important;
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .pwa-notification {
        background: #1f2937;
        border-left-color: #3b82f6;
    }
    
    .notification-title {
        color: #f9fafb;
    }
    
    .notification-message {
        color: #d1d5db;
    }
    
    .notification-close {
        color: #9ca3af;
    }
    
    .notification-close:hover {
        background: #374151;
        color: #f3f4f6;
    }
    
    .notification-button {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
    
    .notification-button:hover {
        background: #4b5563;
        border-color: #6b7280;
    }
    
    .share-button {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
    
    .share-button:hover {
        background: #4b5563;
        border-color: #6b7280;
    }
}

/* ==========================================================================
   High Contrast Mode
   ========================================================================== */

@media (prefers-contrast: high) {
    .pwa-install-button {
        border: 2px solid #000;
        background: #000;
        color: #fff;
    }
    
    .pwa-notification {
        border: 2px solid #000;
    }
    
    .network-indicator {
        border: 2px solid #000;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .pwa-install-button,
    .pwa-notification,
    .network-indicator,
    .notification-close,
    .notification-button,
    .share-button {
        transition: none;
        animation: none;
    }
    
    .pwa-loading::after {
        animation: none;
    }
}