/* ============================================================
   DevTeca PWA — Install Banner & Mobile-Native Enhancements
   ============================================================ */

/* ---- PWA Install Banner ---- */
.pwa-install-banner {
    position: fixed;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 480px;
    z-index: 9999;
    transition: bottom 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.pwa-install-banner.show {
    bottom: 1rem;
    pointer-events: auto;
}

.pwa-install-card {
    background: linear-gradient(145deg, rgba(15, 22, 41, 0.97), rgba(20, 28, 52, 0.97));
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 20px;
    padding: 1.25rem 1.5rem;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(99, 102, 241, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pwa-install-icon {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.pwa-install-text {
    flex: 1;
    min-width: 0;
}

.pwa-install-text h4 {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: #f4f7fb;
    margin: 0 0 0.2rem 0;
    line-height: 1.3;
}

.pwa-install-text p {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    color: rgba(200, 214, 229, 0.65);
    margin: 0;
    line-height: 1.4;
}

.pwa-install-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: fit-content;
}

.pwa-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.pwa-install-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    background: linear-gradient(135deg, #818cf8, #6366f1);
}

.pwa-dismiss-btn {
    background: none;
    border: none;
    color: rgba(200, 214, 229, 0.4);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
    text-align: center;
}

.pwa-dismiss-btn:hover {
    color: rgba(200, 214, 229, 0.7);
}

/* ---- PWA iOS Install Instructions (Modal-like) ---- */
.pwa-ios-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    z-index: 10000;
    transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-ios-sheet.show {
    bottom: 0;
}

.pwa-ios-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 9999;
}

.pwa-ios-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.pwa-ios-content {
    background: #141c34;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 2rem 1.5rem;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.pwa-ios-handle {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    margin: 0 auto 1.5rem;
}

.pwa-ios-content h4 {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    color: #f4f7fb;
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

.pwa-ios-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
}

.pwa-ios-steps li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    color: rgba(200, 214, 229, 0.8);
}

.pwa-ios-steps li:last-child {
    border-bottom: none;
}

.pwa-ios-step-num {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.pwa-ios-close {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 12px;
    color: #818cf8;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-ios-close:hover {
    background: rgba(99, 102, 241, 0.25);
}

/* ---- PWA Standalone Mode Adjustments ---- */
@media all and (display-mode: standalone) {
    /* Remove browser-like elements, make it feel native */
    .navbar {
        padding-top: env(safe-area-inset-top, 0px) !important;
    }
    
    footer {
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }
    
    /* Hide the install banner when already installed */
    .pwa-install-banner {
        display: none !important;
    }
    
    body {
        -webkit-user-select: none;
        user-select: auto;
        -webkit-touch-callout: none;
        overscroll-behavior-y: contain;
    }
    
    /* Native-like selection for code blocks only */
    pre, code, .code-editor, textarea {
        -webkit-user-select: text !important;
        user-select: text !important;
        -webkit-touch-callout: default !important;
    }
}

/* ---- Mobile-First Touch Optimizations ---- */
@media (max-width: 768px) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        padding: 0.75rem 1rem !important;
    }
    
    .dropdown-item {
        padding: 0.75rem 1.25rem !important;
    }
    
    /* Smooth momentum scrolling */
    .user-sidebar,
    .snippet-content,
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Bottom safe area for iPhone notch */
    footer {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ---- PWA Update Available Toast ---- */
.pwa-update-toast {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 25px rgba(5, 150, 105, 0.3);
    z-index: 10001;
    transition: top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pwa-update-toast.show {
    top: 1rem;
}

.pwa-update-toast button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
