/* ================================================
   EDU SKILLS - PWA & Add to Home Screen Styles
   Supports Windows, Android, and iOS (iPhone/iPad)
   ================================================ */

/* --- Floating Fixed Install Button (Bottom Right) --- */
.pwa-floating-fab-container {
    position: fixed;
    bottom: 26px;
    right: 26px;
    z-index: 9998;
    display: flex;
    align-items: center;
    pointer-events: auto;
    animation: pwaFabEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s both;
}

[dir="rtl"] .pwa-floating-fab-container {
    right: 26px;
    left: auto;
}

[dir="ltr"] .pwa-floating-fab-container {
    right: 26px;
    left: auto;
}

@keyframes pwaFabEntrance {
    0% {
        opacity: 0;
        transform: translateY(60px) scale(0.7);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pwa-floating-fab-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem 0.65rem 0.75rem;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #4338CA 100%);
    background-size: 200% 200%;
    animation: pwaGradShift 6s ease infinite;
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 10px 30px -4px rgba(79, 70, 229, 0.55),
                0 0 0 1px rgba(255, 255, 255, 0.3) inset,
                0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    overflow: hidden;
}

[dir="rtl"] .pwa-floating-fab-btn {
    padding: 0.65rem 0.75rem 0.65rem 1.25rem;
}

@keyframes pwaGradShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Pulsing wave behind button */
.pwa-fab-pulse {
    position: absolute;
    inset: -6px;
    border-radius: 9999px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.45) 0%, rgba(79, 70, 229, 0) 70%);
    z-index: -1;
    animation: pwaPulseRing 2.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    pointer-events: none;
}

@keyframes pwaPulseRing {
    0% {
        transform: scale(0.92);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.15);
        opacity: 0;
    }
    100% {
        transform: scale(0.92);
        opacity: 0;
    }
}

/* Shimmer reflection */
.pwa-floating-fab-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -120%;
    width: 80%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    border-radius: 9999px;
    animation: pwaShimmer 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pwaShimmer {
    0%, 70% { left: -120%; }
    100% { left: 160%; }
}

/* Icon Box inside FAB */
.pwa-fab-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.3) inset;
    transition: transform 0.3s ease, background 0.3s ease;
}

.pwa-floating-fab-btn:hover .pwa-fab-icon {
    transform: scale(1.1) rotate(-5deg);
    background: rgba(255, 255, 255, 0.28);
}

/* Text Wrapper */
.pwa-fab-text-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    line-height: 1.2;
}

[dir="rtl"] .pwa-fab-text-wrapper {
    align-items: flex-start;
    text-align: right;
}

.pwa-fab-title {
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.pwa-fab-platforms {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pwa-mini-tag {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.18);
    padding: 0.05rem 0.4rem;
    border-radius: 9999px;
    letter-spacing: 0.01em;
}

/* Sparkle icon */
.pwa-fab-sparkle {
    color: #FDE047;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: 0.25rem;
    animation: pwaSparkleRotate 3s ease-in-out infinite;
}

@keyframes pwaSparkleRotate {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.9; }
    50% { transform: scale(1.25) rotate(15deg); opacity: 1; }
}

/* Hover state */
.pwa-floating-fab-btn:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 16px 40px -4px rgba(124, 58, 237, 0.65),
                0 0 0 1.5px rgba(255, 255, 255, 0.4) inset,
                0 4px 12px rgba(0, 0, 0, 0.2);
}

.pwa-floating-fab-btn:active {
    transform: translateY(-1px) scale(0.98);
}

/* Hide floating button in standalone mode */
@media all and (display-mode: standalone) {
    .pwa-floating-fab-container {
        display: none !important;
    }
}

body.pwa-is-standalone .pwa-floating-fab-container {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .pwa-floating-fab-container {
        bottom: 18px;
        right: 16px;
    }
    [dir="rtl"] .pwa-floating-fab-container {
        right: 16px;
    }
    .pwa-floating-fab-btn {
        padding: 0.55rem 0.9rem 0.55rem 0.65rem;
        gap: 0.6rem;
    }
    [dir="rtl"] .pwa-floating-fab-btn {
        padding: 0.55rem 0.65rem 0.55rem 0.9rem;
    }
    .pwa-fab-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    .pwa-fab-title {
        font-size: 0.88rem;
    }
    .pwa-mini-tag {
        font-size: 0.6rem;
        padding: 0.04rem 0.35rem;
    }
}


/* --- Modal Overlay & Dialog --- */
.pwa-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease;
}

.pwa-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.pwa-modal-dialog {
    background: #1E293B;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 1.5rem;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    color: #F8FAFC;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(129, 140, 248, 0.2);
    transform: scale(0.92) translateY(15px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.pwa-modal-overlay.active .pwa-modal-dialog {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.pwa-modal-header {
    padding: 1.5rem 1.75rem 1.25rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
}

.pwa-modal-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pwa-modal-app-icon {
    width: 54px;
    height: 54px;
    min-width: 54px;
    border-radius: 1rem;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.35rem;
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.pwa-modal-app-icon-img {
    width: 54px;
    height: 54px;
    min-width: 54px;
    border-radius: 1rem;
    object-fit: contain;
    background: #ffffff;
    padding: 3px;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.8);
    flex-shrink: 0;
}

.pwa-modal-titles {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pwa-modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
    line-height: 1.3;
}

.pwa-modal-subtitle {
    font-size: 0.85rem;
    color: #94A3B8;
    margin: 0;
}

.pwa-modal-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94A3B8;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.pwa-modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #F87171;
    transform: rotate(90deg);
}

/* Modal Body */
.pwa-modal-body {
    padding: 1.5rem 1.75rem;
}

/* OS Switcher Tabs */
.pwa-os-tabs {
    display: flex;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.875rem;
    padding: 0.35rem;
    gap: 0.35rem;
    margin-bottom: 1.5rem;
}

.pwa-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0.65rem;
    color: #94A3B8;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.pwa-tab-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.pwa-tab-btn.active {
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.pwa-tab-btn .detected-pill {
    position: absolute;
    top: -6px;
    inset-inline-end: 8px;
    background: #10B981;
    color: #ffffff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    letter-spacing: 0;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

/* Tab Panels */
.pwa-tab-panel {
    display: none;
    animation: pwaFadeIn 0.3s ease;
}

.pwa-tab-panel.active {
    display: block;
}

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

/* Steps List */
.pwa-steps-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.pwa-step-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 1rem;
    padding: 1rem 1.15rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.pwa-step-item:hover {
    border-color: rgba(129, 140, 248, 0.3);
    background: rgba(255, 255, 255, 0.06);
}

.pwa-step-num {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 9999px;
    background: rgba(79, 70, 229, 0.25);
    border: 1px solid rgba(129, 140, 248, 0.5);
    color: #A5B4FC;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-step-content {
    flex: 1;
}

.pwa-step-content strong {
    display: block;
    color: #ffffff;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.pwa-step-content p {
    color: #CBD5E1;
    font-size: 0.85rem;
    line-height: 1.45;
    margin: 0;
}

.pwa-inline-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(79, 70, 229, 0.3);
    border: 1px solid rgba(129, 140, 248, 0.4);
    color: #E0E7FF;
    padding: 0.15rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    vertical-align: middle;
}

.pwa-inline-badge.ios-share {
    background: rgba(14, 165, 233, 0.2);
    border-color: rgba(56, 189, 248, 0.4);
    color: #38BDF8;
}

/* Action Banner / Direct Trigger Button */
.pwa-action-box {
    margin-top: 1.25rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15) 0%, rgba(124, 58, 237, 0.1) 100%);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 1rem;
    padding: 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.pwa-action-box p {
    margin: 0;
    font-size: 0.85rem;
    color: #CBD5E1;
}

.pwa-direct-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    border: none;
    border-radius: 0.75rem;
    padding: 0.85rem 1.75rem;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    transition: all 0.25s ease;
    width: 100%;
    max-width: 320px;
}

.pwa-direct-install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.5);
    background: linear-gradient(135deg, #4338CA 0%, #6D28D9 100%);
}

/* Visual Demo Card for iOS */
.ios-visual-guide {
    background: #0F172A;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.875rem;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
}

.ios-visual-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94A3B8;
    font-size: 0.8rem;
}

.ios-visual-step.highlight {
    color: #38BDF8;
    font-weight: 700;
}

.ios-visual-arrow {
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.9rem;
}

/* Already Installed Banner */
.pwa-installed-banner {
    display: none;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    align-items: center;
    gap: 0.875rem;
    color: #D1FAE5;
}

.pwa-installed-banner.active {
    display: flex;
}

.pwa-installed-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 9999px;
    background: #10B981;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toast Message */
.pwa-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1E293B;
    border: 1px solid rgba(129, 140, 248, 0.3);
    color: #ffffff;
    padding: 0.875rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.pwa-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive Rules */
@media (max-width: 640px) {
    .pwa-modal-header {
        padding: 1.25rem 1rem 1rem;
    }
    .pwa-modal-body {
        padding: 1rem;
    }
    .pwa-os-tabs {
        flex-direction: row;
        gap: 0.2rem;
    }
    .pwa-tab-btn {
        padding: 0.55rem 0.35rem;
        font-size: 0.8rem;
    }
    .pwa-tab-btn svg {
        width: 14px;
        height: 14px;
    }
    .pwa-step-item {
        padding: 0.875rem 0.75rem;
        gap: 0.75rem;
    }
}
