/* ═══════════════════════════════════════════════════
   مودال بروزرسانی اپلیکیشن (APK)
   ═══════════════════════════════════════════════════ */

.app-update-modal {
    position: fixed;
    inset: 0;
    z-index: 999998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    direction: rtl;
    font-family: var(--font-ui, inherit);
}

.app-update-modal.is-visible {
    display: flex;
    animation: appUpdateFadeIn 0.3s ease;
}

.app-update-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 23, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.app-update-modal__card {
    position: relative;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbfa 100%);
    border-radius: 26px;
    max-width: 420px;
    width: 100%;
    overflow: hidden;
    box-shadow:
        0 30px 70px -20px rgba(0, 0, 0, 0.45),
        0 10px 30px -10px rgba(21, 94, 89, 0.25);
    animation: appUpdateSlideUp 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
    text-align: center;
}

/* ─── هدر با گرادیان ─── */
.app-update-modal__hero {
    background: linear-gradient(135deg, #155E59 0%, #0D4141 100%);
    padding: 28px 24px 22px;
    position: relative;
    overflow: hidden;
}

.app-update-modal__hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.08) 1px, transparent 0);
    background-size: 24px 24px;
    opacity: 0.6;
}

.app-update-modal__hero::after {
    content: '';
    position: absolute;
    top: -40%;
    left: -30%;
    width: 180%;
    height: 180%;
    background: radial-gradient(circle, rgba(201, 154, 61, 0.15), transparent 50%);
    pointer-events: none;
}

.app-update-modal__icon {
    width: 82px;
    height: 82px;
    margin: 0 auto 14px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(8px);
}

.app-update-modal__icon svg {
    width: 42px;
    height: 42px;
    color: #C99A3D;
    animation: appUpdateBounce 2s ease-in-out infinite;
}

.app-update-modal__badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(201, 154, 61, 0.22);
    color: #C99A3D;
    font-size: .74rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 100px;
    border: 1px solid rgba(201, 154, 61, 0.35);
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.app-update-modal__title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 6px;
    line-height: 1.4;
    position: relative;
    z-index: 1;
}

.app-update-modal__subtitle {
    font-size: .85rem;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

/* ─── بدنه ─── */
.app-update-modal__body {
    padding: 22px 22px 8px;
}

/* نسخه‌ها */
.app-update-modal__versions {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.app-update-modal__version {
    padding: 12px 10px;
    background: #F5F8F7;
    border-radius: 14px;
    border: 1px solid #E5EFEC;
}

.app-update-modal__version--new {
    background: linear-gradient(135deg, #E8F2EF 0%, #F5FBF9 100%);
    border-color: #C7DDD9;
}

.app-update-modal__version-label {
    display: block;
    font-size: .7rem;
    color: #747B7B;
    font-weight: 600;
    margin-bottom: 4px;
}

.app-update-modal__version-num {
    font-family: monospace;
    font-size: 1.05rem;
    font-weight: 800;
    color: #202B2B;
    direction: ltr;
}

.app-update-modal__version--new .app-update-modal__version-num {
    color: #155E59;
}

.app-update-modal__arrow {
    color: #C99A3D;
    font-size: 1.4rem;
    font-weight: 700;
}

/* تغییرات */
.app-update-modal__changelog {
    background: #F9FAFB;
    border: 1px dashed #D1D8D6;
    border-radius: 14px;
    padding: 14px 16px;
    text-align: right;
    margin-bottom: 20px;
}

.app-update-modal__changelog-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    font-weight: 700;
    color: #202B2B;
    margin: 0 0 8px;
}

.app-update-modal__changelog-title svg {
    color: #155E59;
    flex-shrink: 0;
}

.app-update-modal__changelog-text {
    font-size: .84rem;
    line-height: 1.85;
    color: #4B5563;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* ─── فوتر ─── */
.app-update-modal__footer {
    padding: 0 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.app-update-modal__download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 22px;
    background: linear-gradient(135deg, #155E59 0%, #0D4141 100%);
    color: #ffffff;
    border: none;
    border-radius: 15px;
    font-family: inherit;
    font-size: .98rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 8px 20px -8px rgba(21, 94, 89, 0.55);
    -webkit-tap-highlight-color: transparent;
}

.app-update-modal__download:hover {
    box-shadow: 0 10px 26px -8px rgba(21, 94, 89, 0.7);
}

.app-update-modal__download:active {
    transform: scale(0.98);
}

.app-update-modal__download svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.app-update-modal__later {
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: #747B7B;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    transition: background 0.15s, color 0.15s;
}

.app-update-modal__later:hover {
    background: #F5F8F7;
    color: #202B2B;
}

/* ─── Dark mode ─── */
@media (prefers-color-scheme: dark) {
    .app-update-modal__card {
        background: linear-gradient(180deg, #17201D 0%, #1E2927 100%);
    }
    .app-update-modal__version {
        background: #253230;
        border-color: #2F403D;
    }
    .app-update-modal__version--new {
        background: linear-gradient(135deg, #1E3533 0%, #253230 100%);
        border-color: #2F4A47;
    }
    .app-update-modal__version-label {
        color: #9AA6A3;
    }
    .app-update-modal__version-num {
        color: #EDEFEC;
    }
    .app-update-modal__version--new .app-update-modal__version-num {
        color: #4AC9C0;
    }
    .app-update-modal__changelog {
        background: #1E2927;
        border-color: #2F403D;
    }
    .app-update-modal__changelog-title {
        color: #EDEFEC;
    }
    .app-update-modal__changelog-text {
        color: #9AA6A3;
    }
    .app-update-modal__later {
        color: #9AA6A3;
    }
    .app-update-modal__later:hover {
        background: #253230;
        color: #EDEFEC;
    }
}

/* ─── انیمیشن‌ها ─── */
@keyframes appUpdateFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes appUpdateSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.92); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes appUpdateBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

/* ─── موبایل ─── */
@media (max-width: 480px) {
    .app-update-modal__card {
        border-radius: 22px;
    }
    .app-update-modal__hero {
        padding: 24px 18px 20px;
    }
    .app-update-modal__icon {
        width: 72px;
        height: 72px;
        margin-bottom: 12px;
    }
    .app-update-modal__icon svg {
        width: 36px;
        height: 36px;
    }
    .app-update-modal__title {
        font-size: 1.1rem;
    }
    .app-update-modal__body {
        padding: 18px 18px 6px;
    }
    .app-update-modal__footer {
        padding: 0 18px 18px;
    }
}

/* Safe area */
@supports (padding: env(safe-area-inset-top)) {
    .app-update-modal {
        padding-top: calc(20px + env(safe-area-inset-top));
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}