/* ویس‌تایپ — توکن‌های طراحی
   رنگ‌ها: کاشی فیروزه‌ای و لاجوردی روی گچ سفید؛ زعفرانی فقط برای حالت ضبط زنده */

@font-face {
    font-family: "Vazirmatn";
    src: url("/fonts/Vazirmatn-Variable.woff2") format("woff2-variations"),
         url("/fonts/Vazirmatn-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --plaster: #F3F5F4;      /* پس‌زمینه */
    --surface: #FFFFFF;      /* سطح پنل‌ها */
    --ink: #1C2433;          /* متن اصلی */
    --ink-soft: #5B6577;     /* متن فرعی */
    --lapis: #253A75;        /* لاجوردی: لینک‌ها و تاکید */
    --turquoise: #0E8C8A;    /* فیروزه‌ای: رنگ برند و دکمه اصلی */
    --turquoise-deep: #0A6F6D;
    --saffron: #E2A027;      /* فقط حالت ضبط */
    --line: #DCE2E0;
    --danger: #B4373A;

    --radius-lg: 18px;
    --radius-sm: 10px;
    --font: "Vazirmatn", Tahoma, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --plaster: #12171F;
        --surface: #1A212C;
        --ink: #E8ECEF;
        --ink-soft: #9AA4B2;
        --lapis: #9DB1EA;
        --turquoise: #2BB3AF;
        --turquoise-deep: #23928F;
        --line: #2A3340;
    }
}

html, body {
    background: var(--plaster);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.75;
}

body {
    min-height: 100dvh;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

a { color: var(--lapis); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 3px solid var(--lapis);
    outline-offset: 2px;
}

.app-shell {
    max-width: 560px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- نوار بالا ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 6px;
}

.brand {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.brand:hover { text-decoration: none; }

.minutes-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.9rem;
}
.minutes-chip strong { font-weight: 800; font-size: 1.05rem; }
.minutes-chip.low { border-color: var(--danger); color: var(--danger); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--ink-soft);
    background: transparent;
    border: 0;
}
.icon-btn:hover { background: var(--surface); text-decoration: none; }

/* ---------- دکمه ضبط: ستاره هشت‌پر (خاتم) ---------- */

.recorder {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 0 8px;
}

.khatam {
    --size: 188px;
    --level: 0;
    position: relative;
    width: var(--size);
    height: var(--size);
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.khatam::before,
.khatam .khatam-face {
    position: absolute;
    inset: 0;
    /* خاتم دقیق: دو مربع روی هم با زاویه ۴۵ درجه */
    clip-path: polygon(50% 0%, 64.64% 14.64%, 85.36% 14.64%, 85.36% 35.36%, 100% 50%, 85.36% 64.64%, 85.36% 85.36%, 64.64% 85.36%, 50% 100%, 35.36% 85.36%, 14.64% 85.36%, 14.64% 64.64%, 0% 50%, 14.64% 35.36%, 14.64% 14.64%, 35.36% 14.64%);
}

/* هاله: با بلندی صدا بزرگ می‌شود */
.khatam::before {
    content: "";
    background: var(--turquoise);
    opacity: 0.18;
    transform: scale(calc(1 + var(--level) * 0.28));
    transition: transform 90ms linear;
}

.khatam .khatam-face {
    inset: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--turquoise);
    color: #fff;
    transition: background 200ms ease, transform 200ms ease;
}

.khatam:hover .khatam-face { background: var(--turquoise-deep); }
.khatam:active .khatam-face { transform: scale(0.96); }

.khatam.is-recording::before { background: var(--saffron); opacity: 0.3; }
.khatam.is-recording .khatam-face { background: var(--saffron); transform: rotate(22.5deg); }
.khatam.is-recording .khatam-face svg { transform: rotate(-22.5deg); }

.khatam[disabled] { cursor: progress; }
.khatam[disabled] .khatam-face { background: var(--ink-soft); }

.khatam.is-busy .khatam-face { animation: khatam-turn 2.4s linear infinite; }
.khatam.is-busy .khatam-face svg { animation: khatam-turn 2.4s linear infinite reverse; }

@keyframes khatam-turn { to { transform: rotate(360deg); } }

.recorder-status {
    margin-top: 14px;
    min-height: 2em;
    font-size: 1.05rem;
    color: var(--ink-soft);
    text-align: center;
}
.recorder-status .timer {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

/* کنترل سطح کیفیت */
.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    margin-top: 12px;
}
.segmented button {
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    padding: 4px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-family: var(--font);
}
.segmented button[aria-pressed="true"] {
    background: var(--ink);
    color: var(--surface);
}

.file-pick {
    margin-top: 14px;
    font-size: 0.95rem;
    color: var(--lapis);
    background: none;
    border: 0;
    font-family: var(--font);
}
.file-pick:hover { text-decoration: underline; }

/* ---------- نتیجه ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-top: 18px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.panel-head h2, .panel-head h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}
.panel-meta { font-size: 0.85rem; color: var(--ink-soft); }

.transcript {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 1.1rem;
    line-height: 2;
    user-select: text;
    max-width: 70ch;
}
.transcript[dir="ltr"] { text-align: left; }

.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    background: var(--turquoise);
    color: #fff;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}
.btn-copy:hover { background: var(--turquoise-deep); }
.btn-copy.done { background: var(--lapis); }

.modes {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 8px;
    margin-top: 6px;
    scrollbar-width: none;
}
.modes::-webkit-scrollbar { display: none; }

.mode-btn {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    border-radius: 999px;
    padding: 5px 14px;
    font-family: var(--font);
    font-size: 0.92rem;
}
.mode-btn:hover { border-color: var(--turquoise); }
.mode-btn.has-output { border-color: var(--turquoise); color: var(--turquoise-deep); }
.mode-btn[disabled] { opacity: 0.5; }

.output-panel { border-inline-start: 4px solid var(--turquoise); }

/* ---------- پیام‌ها ---------- */

.notice {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 14px;
    font-size: 0.95rem;
    background: var(--surface);
    border: 1px solid var(--line);
}
.notice.error { border-color: var(--danger); color: var(--danger); }
.notice.success { border-color: var(--turquoise); color: var(--turquoise-deep); }

.toast-float {
    position: fixed;
    inset-inline: 16px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    max-width: 528px;
    margin: 0 auto;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--surface);
    text-align: center;
    z-index: 50;
}

/* ---------- ناوبری پایین ---------- */

.bottom-nav {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 40;
}
.bottom-nav a {
    flex: 1;
    max-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 0.8rem;
}
.bottom-nav a:hover { text-decoration: none; background: var(--plaster); }
.bottom-nav a[aria-current="page"] { color: var(--turquoise-deep); font-weight: 700; }

/* ---------- فرم‌ها و صفحات ساده ---------- */

.page-title {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 18px 0 4px;
}
.page-lead { color: var(--ink-soft); margin-bottom: 16px; }

.form-control, .form-select {
    font-family: var(--font);
    border-radius: var(--radius-sm);
    border-color: var(--line);
    background-color: var(--surface);
    color: var(--ink);
}
.form-control:focus {
    border-color: var(--turquoise);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--turquoise) 25%, transparent);
    background-color: var(--surface);
    color: var(--ink);
}
.form-control.ltr { direction: ltr; text-align: left; letter-spacing: 0.12em; }

.btn-primary-gooyanegar {
    display: block;
    width: 100%;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    background: var(--turquoise);
    color: #fff;
    font-family: var(--font);
    font-weight: 700;
    font-size: 1rem;
}
.btn-primary-gooyanegar:hover { background: var(--turquoise-deep); }

.btn-quiet {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    font-family: var(--font);
}

/* کیف پول */
.wallet-hero {
    padding: 22px 0 6px;
}
.wallet-hero .big {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
}
.wallet-hero .unit { font-size: 1.1rem; font-weight: 600; color: var(--ink-soft); }

.package-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.package {
    width: 100%;
    text-align: start;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 14px;
    font-family: var(--font);
    color: var(--ink);
}
.package:hover { border-color: var(--turquoise); }
.package.popular { border: 2px solid var(--turquoise); }
.package .pay { font-weight: 800; font-size: 1.15rem; }
.package .credit { font-size: 0.85rem; color: var(--ink-soft); }
.package .tag { font-size: 0.75rem; color: var(--turquoise-deep); font-weight: 700; }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}
.list-plain li:last-child { border-bottom: 0; }
.amount-plus { color: var(--turquoise-deep); font-weight: 700; }
.amount-minus { color: var(--ink-soft); }

/* تاریخچه */
.history-item {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    color: var(--ink);
}
.history-item:hover { border-color: var(--turquoise); text-decoration: none; }
.history-item .snippet {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
    .khatam::before, .khatam .khatam-face { transition: none; }
    .khatam.is-busy .khatam-face, .khatam.is-busy .khatam-face svg { animation: none; }
}

[x-cloak] { display: none !important; }
