@import url("https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v30.1.0/dist/font-face.css");

/* THEME */
:root {
    --bg: #0b1020;
    --panel: #0f1733;
    --muted: #9aa4b2;
    --text: #e9eef5;
    --primary: #3b82f6;
    --primary-2: #2563eb;
    --input: #0c142b;
    --ring: #93c5fd;
    --border: #16204a;

    --topbar-bg: rgba(11, 15, 32, 0.96);
    --topbar-border: #1f2937;
    --topbar-text: #e5e7eb;
}

:root[data-theme="light"] {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --muted: #667085;
    --text: #101828;
    --primary: #3b82f6;
    --primary-2: #2563eb;
    --input: #ffffff;
    --ring: #93c5fd;
    --border: #e5e7eb;

    --topbar-bg: rgba(255, 255, 255, 0.96);
    --topbar-border: #e5e7eb;
    --topbar-text: #111827;
}

/* GLOBAL */

*,
*::before,
*::after {
    box-sizing: border-box;
    font-family: "Vazirmatn", "Vazir", "Vazir FD", system-ui, -apple-system, Segoe UI, Roboto;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

/* TOPBAR */

.topbar {
    position: fixed;
    inset-inline: 0;
    inset-block-start: 0;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    z-index: 10;
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--topbar-border);
    color: var(--topbar-text);
}

/* برای صفحاتی مثل پروفایل/اشتراک که راست/چپ طبیعی می‌خوایم */
.topbar-simple {
    flex-direction: row;
}

.topbar-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 27px;
    font-weight: 600;
    color: var(--topbar-text);
    pointer-events: none;
    white-space: nowrap;
}

.topbar-left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.topbar-right {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.topbar-support {
    background: transparent;
    border: 1px solid transparent;
    color: var(--topbar-text);
    cursor: pointer;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 12px;
}

.topbar button {
    padding: 8px 10px;
    border-radius: 12px;
}

/* theme button */
button.ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--topbar-text);
    padding: 6px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
}

button.ghost:hover {
    border-color: var(--border);
    background: rgba(148, 163, 184, 0.18);
}

/* دکمه سفید مخصوص دیالوگ خروج (بلی) */
.white-btn {
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
}

/* hamburger button – always visible */
.topbar-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 10px;
    font-size: 16px;
    color: var(--topbar-text);
    cursor: pointer;
}

/* MAIN LAYOUT */

main {
    margin-top: 96px;
    height: calc(100vh - 96px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0 16px;
    padding-top: calc((100vh - 96px) * 0.15);
    overflow: hidden;
}

/* مخصوص صفحه لاگین (درخواست کد) */
body.login-page main {
    margin-top: 96px;
    height: auto;
    min-height: calc(100vh - 96px);
    padding-top: 24px;
    padding-bottom: 24px;
    overflow: auto;
    align-items: flex-start;
}

section {
    width: 100%;
    max-width: 440px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: grid;
    gap: 12px;
    margin: 0;
}

.card {
    width: 100%;
    max-width: 1400px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 26px;
    display: grid;
    gap: 20px;
    margin: 0;
}

h1 {
    margin: 0 0 6px 0;
    font-size: 16px;
    text-align: center;
    font-weight: 600;
}

/* LOGIN TYPE TABS */

.login-type-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px;
    border-radius: 999px;
    background: var(--input);
    border: 1px solid var(--border);
}

.login-tab {
    flex: 1;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    padding: 8px 10px;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.login-tab.login-tab-active {
    background: linear-gradient(180deg, var(--primary), var(--primary-2));
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

/* INPUTS */

input {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--input);
    border: 1px solid var(--border);
    color: var(--text);
    outline: none;
    text-align: center;
    font-size: 16px;
}

.ltr-input {
    direction: ltr;
}

input::placeholder {
    color: var(--muted);
}

input:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}

/* BUTTONS */

button {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #2563eb;
    background: linear-gradient(180deg, var(--primary), var(--primary-2));
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

button.danger {
    background: linear-gradient(180deg, #e95656, #cc4545);
    border-color: #a73c3c;
}

button:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.small {
    font-size: 12px;
    opacity: .8;
    text-align: center;
}

.row {
    display: grid;
    gap: 10px;
}

/* LOADING OVERLAY */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* DIALOG */

.dialog {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}

.dialog.hidden {
    display: none;
}

.dialog-content {
    background: var(--panel);
    border-radius: 16px;
    padding: 24px 26px;
    min-width: 260px;
    max-width: 360px;
    border: 1px solid var(--border);
    display: grid;
    gap: 18px;
}

.dialog-message {
    font-size: 14px;
    text-align: center;
}

.dialog-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
}

#confirmLogoutYes,
#confirmLogoutNo {
    min-width: 120px;
    padding-inline: 22px;
}

.dialog-close {
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
}

/* گزینه تیک‌دار ریست وضعیت در دیالوگ خروج */
.logout-clear-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text);
    text-align: right;
}

.logout-clear-wrap input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Support buttons */

.btn-support {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid #2563eb;
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    color: #fff;
    font-size: 13px;
    text-decoration: none;
}

.btn-instagram {
    border-color: #c13584;
    background: linear-gradient(180deg, #f56040, #c13584);
}

/* PACKS GRID */

.section-title {
    margin: 0;
    font-size: 16px;
    text-align: center;
}

.packs-grid {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    gap: 28px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 380px) {
    .packs-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 900px) {
    .packs-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}


/* --- PACK CARD (Final Size) --- */

.pack-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 22px;

    /* 🔥 اندازه اصلی و درست */
    padding: 26px 34px;
    min-height: 115px;

    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    text-align: center;
    cursor: pointer;
    transition: 0.15s ease;
}

/* سه رنگ */
.pack-card.pack-card-progress {
    /* 🔥 ضخامت دو برابر شده (قبلاً 2.5px بود) */
    border-width: 5px;
    border-style: solid;
    border-color: transparent;

    background: linear-gradient(var(--panel), var(--panel)) padding-box,
    conic-gradient(
        /* سبز ۲۰٪ تیره‌تر */ #1b9d4b 0deg calc(var(--ok-pct, 0) * 3.6deg),
                /* قرمز ۲۰٪ تیره‌تر */ #e21313 calc(var(--ok-pct, 0) * 3.6deg) calc((var(--ok-pct, 0) + var(--err-pct, 0)) * 3.6deg),
            var(--border) calc((var(--ok-pct, 0) + var(--err-pct, 0)) * 3.6deg) 360deg
    ) border-box;
}

.pack-card h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.pack-card small {
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
}

.pack-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
    border-color: var(--ring);
}

.pack-card:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .5);
    border-color: var(--ring);
}

.packs-empty {
    margin-top: 4px;
}

/* MOBILE DRAWER */

.topbar-drawer {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    z-index: 59;
}

.topbar-drawer.hidden {
    display: none;
}

.topbar-drawer-panel {
    margin-right: auto;
    margin-left: 0;
    width: 220px;
    max-width: 75%;
    background: var(--panel);
    border-left: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.drawer-theme-btn {
    align-self: center;
}

.drawer-menu-item {
    width: 100%;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
}

.drawer-menu-item:hover {
    background: rgba(148, 163, 184, 0.15);
}

/* two-line profile entry inside drawer */
.drawer-profile-name {
    font-size: 13px;
    font-weight: 600;
}

.drawer-profile-id {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

.drawer-logout-btn {
    align-self: center;
    min-width: 100px;
}

/* shared back button (text-only) */
.q-back-btn {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--topbar-text);
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s ease, box-shadow 0.12s ease;
}

.q-back-btn:hover {
    background: rgba(148, 163, 184, 0.15);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.22);
}

/* MOBILE */

@media (max-width: 640px) {
    .topbar {
        padding: 16px 12px;
    }

    .topbar-title {
        font-size: 22px;
    }

    .topbar-left {
        display: inline-flex;
    }

    /* دکمه تم در موبایل هم دیده شود */
    #themeToggle {
        display: inline-flex;
    }

    main {
        margin-top: 76px;
        height: calc(100vh - 76px);
        padding: 0 12px;
        padding-top: 32px;
    }

    body.login-page main {
        margin-top: 76px;
        min-height: calc(100vh - 76px);
        padding-top: 16px;
        padding-bottom: 24px;
    }

    section,
    .card {
        padding: 20px;
    }

    .dialog-content {
        max-width: 320px;
    }
}

/* OVERRIDE: Support dialog close button wider */
#azSupportDialog .dialog-close {
    width: 100%;
    max-width: 260px;  /* حدود ۳ برابر */
    padding: 12px 20px;
    font-size: 15px;
    margin: 0 auto;
    display: block;
}
