/**
 * PWA-Specific Styles
 * Stili per installazione, banner, notifiche
 */

/* ==============================================
   INSTALL BANNER
   ============================================== */

.pwa-install-banner {
    position: fixed;
    bottom: -200px;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
    padding: 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: bottom 0.3s ease-out;
}

.pwa-install-banner.show {
    bottom: 0;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.banner-icon img {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.banner-text {
    flex: 1;
}

.banner-text h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px 0;
}

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

.banner-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-install {
    background: white;
    color: #1e40af;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

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

.btn-dismiss {
    background: transparent;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Mobile responsive */
@media (max-width: 768px) {
    .banner-content {
        flex-wrap: wrap;
    }
    
    .banner-icon {
        display: none;
    }
    
    .banner-text h3 {
        font-size: 16px;
    }
    
    .banner-text p {
        font-size: 13px;
    }
    
    .banner-actions {
        width: 100%;
        justify-content: stretch;
        margin-top: 12px;
    }
    
    .btn-install {
        flex: 1;
    }
}

/* ==============================================
   UPDATE NOTIFICATION
   ============================================== */

.pwa-update-notification {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 16px 24px;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    z-index: 10000;
    transition: top 0.3s ease-out;
    min-width: 300px;
}

.pwa-update-notification.show {
    top: 0;
}

.notification-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.notification-content p {
    margin: 0;
    font-weight: 600;
    font-size: 14px;
}

#pwa-update-button {
    background: white;
    color: #10b981;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

#pwa-update-button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ==============================================
   OFFLINE BANNER
   ============================================== */

.offline-banner {
    position: fixed;
    top: -60px;
    left: 0;
    right: 0;
    background: #dc2626;
    color: white;
    padding: 12px;
    text-align: center;
    z-index: 9998;
    transition: top 0.3s ease-out;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.offline-banner.show {
    top: 0;
}

.offline-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
}

.offline-icon {
    font-size: 20px;
}

.offline-queue {
    display: none;
    font-size: 12px;
    opacity: 0.9;
}

/* ==============================================
   STANDALONE MODE ADJUSTMENTS
   ============================================== */

/* Rimuovi safe-area per standalone mode */
@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);
    }
    
    /* Header fisso con safe-area */
    header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
    
    /* Nascondi elementi non necessari in standalone */
    .browser-only {
        display: none !important;
    }
    
    /* Mostra elementi solo per PWA */
    .pwa-only {
        display: block !important;
    }
}

/* ==============================================
   SPLASH SCREEN SIMULATION
   ============================================== */

.pwa-splash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: fadeOut 0.5s ease-out 1s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        pointer-events: none;
    }
}

.pwa-splash-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 24px;
    animation: pulse 1.5s ease-in-out infinite;
}

.pwa-splash-text {
    color: white;
    font-size: 24px;
    font-weight: 700;
}

.pwa-splash-loading {
    margin-top: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ==============================================
   INSTALL BUTTON (in pagina)
   ============================================== */

.install-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #1e40af;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.install-button:hover {
    background: #1e3a8a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
}

.install-button.hidden {
    display: none;
}

/* ==============================================
   PULL TO REFRESH INDICATOR
   ============================================== */

.pull-to-refresh {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 12px 24px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9997;
    transition: top 0.3s ease-out;
}

.pull-to-refresh.active {
    top: 20px;
}

.pull-to-refresh-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #1e40af;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.pull-to-refresh-text {
    font-size: 14px;
    color: #475569;
    font-weight: 500;
}

/* ==============================================
   SHARE TARGET STYLES
   ============================================== */

.share-target-container {
    max-width: 600px;
    margin: 40px auto;
    padding: 24px;
    background: #1e293b;
    border-radius: 12px;
}

.share-target-preview {
    margin-bottom: 24px;
}

.share-target-file {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #0f172a;
    border-radius: 8px;
}

.share-target-icon {
    font-size: 32px;
}

.share-target-info h3 {
    font-size: 16px;
    margin: 0 0 4px 0;
    color: #f1f5f9;
}

.share-target-info p {
    font-size: 14px;
    margin: 0;
    color: #94a3b8;
}

/* ==============================================
   APP SHORTCUTS ICONS
   ============================================== */

.shortcuts-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.shortcut-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: #1e293b;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.shortcut-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.shortcut-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.shortcut-name {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

/* ==============================================
   RESPONSIVE ADJUSTMENTS
   ============================================== */

@media (max-width: 640px) {
    .pwa-update-notification {
        min-width: calc(100% - 32px);
        border-radius: 0 0 8px 8px;
    }
    
    .notification-content {
        flex-direction: column;
        text-align: center;
    }
    
    #pwa-update-button {
        width: 100%;
    }
}

/* ==============================================
   DARK MODE ADJUSTMENTS (if needed)
   ============================================== */

@media (prefers-color-scheme: light) {
    .offline-banner {
        background: #ef4444;
    }
    
    .pwa-update-notification {
        background: #059669;
    }
}

/* ==============================================
   ANIMATIONS
   ============================================== */

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

@keyframes slideInFromTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.animate-slide-in-top {
    animation: slideInFromTop 0.3s ease-out;
}

/* ==============================================
   UTILITY CLASSES
   ============================================== */

.browser-only {
    display: block;
}

.pwa-only {
    display: none;
}

@media (display-mode: standalone) {
    .browser-only {
        display: none;
    }
    
    .pwa-only {
        display: block;
    }
}