/* ===================================
   PWA Install Button - Desktop Header
   =================================== */
#pwa-install-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    height: 46px;
    padding: 0 14px;
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    border: none;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

#pwa-install-btn:hover {
    background: rgba(37, 99, 235, 0.18);
    color: #1d4ed8;
    transform: translateY(-2px);
}

#pwa-install-btn:active {
    transform: translateY(0);
}

#pwa-install-btn i {
    font-size: 14px;
}

#pwa-install-btn span {
    display: none;
}

@media (min-width: 1200px) {
    #pwa-install-btn span {
        display: inline;
    }
}

@keyframes pwa-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ===================================
   PWA Install Button - Mobile Bottom Nav
   =================================== */
#pwa-install-btn-mobile {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
    background: rgba(37, 99, 235, 0.08);
    border: 0;
    padding: 4px 6px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
}

#pwa-install-btn-mobile i {
    font-size: 18px;
}

#pwa-install-btn-mobile:hover,
#pwa-install-btn-mobile:focus {
    color: #1d4ed8;
    background: rgba(37, 99, 235, 0.15);
}

/* ===================================
   iOS Install Modal
   =================================== */
.pwa-ios-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pwa-ios-modal-visible {
    opacity: 1;
}

.pwa-ios-modal-content {
    background: #ffffff;
    border-radius: 24px;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 25px 80px rgba(15, 23, 42, 0.25);
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-ios-modal-visible .pwa-ios-modal-content {
    transform: scale(1) translateY(0);
}

.pwa-ios-modal-header {
    text-align: center;
    padding: 28px 24px 20px;
    position: relative;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.05) 0%, transparent 100%);
}

.pwa-ios-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 16px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.pwa-ios-modal-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
}

.pwa-ios-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.08);
    color: #64748b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-ios-close:hover {
    background: rgba(15, 23, 42, 0.15);
    color: #0f172a;
}

.pwa-ios-modal-body {
    padding: 0 24px 24px;
}

.pwa-ios-modal-body p {
    color: #64748b;
    margin-bottom: 16px;
    font-size: 15px;
}

.pwa-ios-modal-body ol {
    margin: 0;
    padding-left: 20px;
    color: #334155;
}

.pwa-ios-modal-body li {
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 15px;
}

.pwa-ios-modal-body strong {
    color: #0f172a;
}

.pwa-ios-icon {
    font-size: 18px;
}

.pwa-ios-modal-footer {
    padding: 16px 24px 24px;
    text-align: center;
}

.pwa-ios-got-it {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-ios-got-it:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-2px);
}

/* ===================================
   PWA Update Banner
   =================================== */
.pwa-update-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-update-visible {
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 991px) {
    .pwa-update-banner {
        bottom: calc(92px + env(safe-area-inset-bottom) + 10px);
    }
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    padding: 14px 20px;
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(15, 23, 42, 0.35);
}

.pwa-update-content i {
    font-size: 18px;
    color: #60a5fa;
    animation: pwa-spin 2s linear infinite;
}

@keyframes pwa-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.pwa-update-content span {
    font-size: 14px;
    font-weight: 500;
}

.pwa-update-btn {
    background: #2563eb;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-update-btn:hover {
    background: #1d4ed8;
}

.pwa-update-dismiss {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

.pwa-update-dismiss:hover {
    color: #ffffff;
}

/* ===================================
   PWA Toast Notifications
   =================================== */
.pwa-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #0f172a;
    color: #ffffff;
    padding: 14px 24px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10001;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.35);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-toast-visible {
    transform: translateX(-50%) translateY(0);
}

.pwa-toast-success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.pwa-toast-error {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.pwa-toast-info {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

@media (max-width: 991px) {
    .pwa-toast {
        bottom: calc(92px + env(safe-area-inset-bottom) + 10px);
    }
}

/* ===================================
   Standalone Mode Enhancements
   =================================== */
@media (display-mode: standalone) {

    /* Hide install buttons when running as installed PWA */
    #pwa-install-btn,
    #pwa-install-btn-mobile {
        display: none !important;
    }

    /* Add extra padding for iOS safe areas */
    body {
        padding-top: env(safe-area-inset-top);
    }

    .main_menu {
        padding-top: env(safe-area-inset-top);
    }
}

/* ===================================
   Dark Mode Support
   =================================== */
@media (prefers-color-scheme: dark) {
    .pwa-ios-modal-content {
        background: #1e293b;
    }

    .pwa-ios-modal-header {
        background: linear-gradient(180deg, rgba(37, 99, 235, 0.15) 0%, transparent 100%);
    }

    .pwa-ios-modal-header h3 {
        color: #f1f5f9;
    }

    .pwa-ios-close {
        background: rgba(255, 255, 255, 0.1);
        color: #94a3b8;
    }

    .pwa-ios-close:hover {
        background: rgba(255, 255, 255, 0.2);
        color: #f1f5f9;
    }

    .pwa-ios-modal-body p {
        color: #94a3b8;
    }

    .pwa-ios-modal-body ol {
        color: #cbd5e1;
    }

    .pwa-ios-modal-body strong {
        color: #f1f5f9;
    }
}

/* ===================================
   Reduced Motion
   =================================== */
@media (prefers-reduced-motion: reduce) {

    #pwa-install-btn i,
    .pwa-update-content i {
        animation: none;
    }

    .pwa-toast,
    .pwa-update-banner,
    .pwa-ios-modal,
    .pwa-ios-modal-content {
        transition: none;
    }
}