/* =========================================================
   هویت بصری پلتفرم — تم تیره + لهجه‌ی Volt
   ========================================================= */
:root {
    --volt: #C9F248;
    --ink: #0B0D10;
}

* { -webkit-tap-highlight-color: transparent; }
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;   /* جلوگیری از بزرگ‌شدن خودکار متن در موبایل */
    text-size-adjust: 100%;
    touch-action: manipulation;       /* جلوگیری از زوم با دابل‌تپ */
    overflow-x: clip;                 /* کلیدواژه‌ی clip کانتینر اسکرول ساده را تصمیم کاربری حل کرده */
}
body { overflow-x: clip; }
/* اسکرول عمودی طبیعی صفحه حفظ می‌شود؛ محتوای بلند داخل عناصر خودشان اسکرول می‌خورند */
main { min-height: 0; }

body::selection { background: rgba(201, 242, 72, .3); }

/* ---------- سایدبار (همیشه RTL) ---------- */
.app-sidebar.is-open { transform: translateX(0) !important; }

/* =========================================================
   انیمیشن باز/بسته شدن منوی موبایل
   ========================================================= */
/* حرکت نرم‌تر و طبیعی‌تر پنل (بیرون‌پرش ملایم) */
#sidebar { transition: transform .42s cubic-bezier(.33, 1, .35, 1); will-change: transform; }

/* پرده‌ی پشت منو: محو تدریجی به‌جای ظاهرشدن ناگهانی */
#sidebarBackdrop {
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    opacity: 0; transition: opacity .35s ease;
}
#sidebarBackdrop.is-visible { opacity: 1; }

/* ورود پلکانی آیتم‌های منو هنگام باز شدن */
@keyframes navItemIn {
    from { opacity: 0; transform: translateX(26px); }
    to   { opacity: 1; transform: translateX(0); }
}
@media (max-width: 1023px) {
    #sidebar.menu-animating nav > a { animation: navItemIn .45s cubic-bezier(.22, 1, .36, 1) both; }
    #sidebar.menu-animating nav > a:nth-child(1) { animation-delay: .05s; }
    #sidebar.menu-animating nav > a:nth-child(2) { animation-delay: .10s; }
    #sidebar.menu-animating nav > a:nth-child(3) { animation-delay: .15s; }
    #sidebar.menu-animating nav > a:nth-child(4) { animation-delay: .20s; }
    #sidebar.menu-animating nav > a:nth-child(5) { animation-delay: .25s; }
    #sidebar.menu-animating nav > a:nth-child(6) { animation-delay: .30s; }
    /* بخش پایینی (زبان و پروفایل) کمی بعد از آیتم‌ها */
    #sidebar.menu-animating > div:last-child,
    #sidebar.menu-animating > div:nth-last-child(2) {
        animation: navItemIn .45s cubic-bezier(.22, 1, .36, 1) both; animation-delay: .32s;
    }
}

/* فشرده‌شدن ظریف دکمه‌ی همبرگر هنگام لمس */
#sidebarToggle { transition: transform .2s ease; }
#sidebarToggle:active { transform: scale(.9); }

@media (prefers-reduced-motion: reduce) {
    #sidebar { transition: none; }
    #sidebarBackdrop { transition: none; }
    #sidebar.menu-animating nav > a,
    #sidebar.menu-animating > div:last-child,
    #sidebar.menu-animating > div:nth-last-child(2) { animation: none !important; }
}

/* دکمه‌ی زبان */
.lang-btn {
    flex: 1; text-align: center; font-size: .7rem; font-weight: 800;
    padding: .45rem .3rem; border-radius: .6rem; color: #a1a1aa; transition: all .2s;
}
.lang-btn:hover { color: #fff; background: rgba(255,255,255,.05); }
.lang-btn-active { background: rgba(201,242,72,.14); color: var(--volt); }

/* پس‌زمینه‌ی محیطی ظریف */
.bg-aurora {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(600px 400px at 90% -10%, rgba(201,242,72,.06), transparent 60%),
        radial-gradient(700px 500px at 0% 110%, rgba(56,189,248,.05), transparent 60%),
        var(--ink);
}

/* شیشه‌ای */
.glass {
    background: rgba(19, 22, 27, .78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

/* کارت‌ها */
.card {
    background: rgba(255,255,255,.035);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 1.25rem;
    padding: 1.25rem;
    transition: border-color .25s, transform .25s, box-shadow .25s;
}
.card:hover { border-color: rgba(255,255,255,.13); }
.student-card:hover { transform: translateY(-3px); box-shadow: 0 20px 40px -20px rgba(0,0,0,.7); }

.section-title {
    display: flex; align-items: center; gap: .5rem;
    font-weight: 800; font-size: .95rem; color: #fff; margin-bottom: 1rem;
}

/* دکمه‌ها */
.btn-primary {
    display: inline-flex; align-items: center; gap: .45rem;
    background: var(--volt); color: var(--ink);
    font-weight: 800; font-size: .85rem;
    padding: .65rem 1.15rem; border-radius: .9rem;
    transition: transform .15s, box-shadow .25s, filter .2s;
    box-shadow: 0 8px 24px -10px rgba(201,242,72,.5);
    cursor: pointer;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn-primary:active { transform: translateY(0) scale(.98); }

.btn-ghost {
    display: inline-flex; align-items: center; gap: .4rem;
    border: 1px solid rgba(255,255,255,.1); color: #d4d4d8;
    font-weight: 700; font-size: .8rem;
    padding: .6rem 1rem; border-radius: .85rem;
    transition: all .2s; cursor: pointer; background: rgba(255,255,255,.02);
}
.btn-ghost:hover { border-color: rgba(201,242,72,.4); color: var(--volt); }

.btn-danger {
    display: inline-flex; align-items: center; gap: .4rem;
    border: 1px solid rgba(248,113,113,.3); color: #f87171;
    font-weight: 700; font-size: .8rem;
    padding: .6rem 1rem; border-radius: .85rem; cursor: pointer;
    transition: all .2s; background: rgba(248,113,113,.06);
}
.btn-danger:hover { background: rgba(248,113,113,.14); }

.icon-btn {
    display: grid; place-items: center;
    width: 2.4rem; height: 2.4rem; border-radius: .8rem;
    border: 1px solid rgba(255,255,255,.1); color: #a1a1aa;
    background: rgba(255,255,255,.03); cursor: pointer; transition: all .2s;
}
.icon-btn:hover { color: var(--volt); border-color: rgba(201,242,72,.4); }

/* فرم‌ها */
.input {
    width: 100%; max-width: 100%; background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: .85rem; padding: .65rem .9rem;
    font-size: .85rem; color: #fff; outline: none;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
/* موبایل: اندازه‌ی ۱۶px از زوم خودکار iOS هنگام فوکوس جلوگیری می‌کند */
@media (max-width: 767px) {
    .input, input, select, textarea { font-size: 16px !important; }
}
.input::placeholder { color: #52525b; }
.input:focus {
    border-color: rgba(201,242,72,.55);
    box-shadow: 0 0 0 3px rgba(201,242,72,.12);
    background: rgba(255,255,255,.06);
}
.label { display:block; font-size: .72rem; font-weight: 700; color: #a1a1aa; margin-bottom: .4rem; }
select.input option { background: #13161B; color: #fff; }
input[type="datetime-local"].input, input[type="date"].input { color-scheme: dark; }

/* پیل‌ها */
.pill {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .65rem; font-weight: 700;
    padding: .28rem .6rem; border-radius: 999px;
    border: 1px solid transparent; white-space: nowrap;
}
.pill-volt  { background: rgba(201,242,72,.1);  color: var(--volt); border-color: rgba(201,242,72,.25); }
.pill-live  { background: rgba(52,211,153,.12); color: #34d399;    border-color: rgba(52,211,153,.3); }
.pill-muted { background: rgba(255,255,255,.05); color: #a1a1aa;   border-color: rgba(255,255,255,.09); }

/* ناوبری */
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .68rem .9rem; border-radius: .9rem;
    font-size: .85rem; font-weight: 700; color: #a1a1aa;
    transition: all .2s; position: relative;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.04); }
.nav-item-active {
    color: var(--volt) !important;
    background: rgba(201,242,72,.09);
}
.nav-item-active::before {
    content: ''; position: absolute; right: -14px; top: 50%; translate: 0 -50%;
    width: 3px; height: 60%; border-radius: 99px; background: var(--volt);
}

/* آواتار گرادیانی از روی نام */
.avatar {
    --h: 200;
    width: 2.75rem; height: 2.75rem; border-radius: 1rem;
    display: grid; place-items: center; flex-shrink: 0;
    font-weight: 800; font-size: .95rem; color: #fff;
    background: linear-gradient(135deg, hsl(var(--h), 60%, 45%), hsl(calc(var(--h) + 40), 65%, 32%));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.avatar-sm { width: 2.25rem; height: 2.25rem; font-size: .75rem; border-radius: .75rem; }
.avatar-lg { width: 3.5rem;  height: 3.5rem;  font-size: 1.15rem; }
.avatar-xl { width: 4.5rem;  height: 4.5rem;  font-size: 1.5rem; border-radius: 1.4rem; }

/* آواتار دارای عکس پروفایل — کشش کامل تصویر داخل فریم */
.avatar-has-img { overflow: hidden; display: block; }
.avatar-has-img > img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ردیف‌ها */
.row-item {
    display: flex; align-items: center; gap: .8rem;
    border: 1px solid rgba(255,255,255,.07); border-radius: 1rem;
    padding: .8rem .9rem; transition: all .2s; background: rgba(255,255,255,.015);
}
.row-item:hover { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.03); }

.file-tile {
    display: flex; align-items: center; gap: .75rem;
    border: 1px solid rgba(255,255,255,.07); border-radius: 1rem;
    padding: .85rem; transition: all .25s;
}
.file-tile:hover { border-color: rgba(201,242,72,.3); transform: translateY(-2px); }

/* =========================================================
   دراپ‌داون سفارشی (جایگزین select سیستم)
   ========================================================= */
.ddown { position: relative; display: inline-block; }
.ddown-btn {
    display: inline-flex; align-items: center; gap: .5rem;
    font-size: .72rem; font-weight: 800; color: #d4d4d8;
    padding: .55rem .85rem; border-radius: .8rem;
    border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.04);
    cursor: pointer; transition: all .2s; white-space: nowrap; min-width: 9.5rem;
}
.ddown-btn:hover { border-color: rgba(201,242,72,.4); color: #fff; }
.ddown.is-open .ddown-btn {
    border-color: rgba(201,242,72,.55); color: var(--volt);
    box-shadow: 0 0 0 3px rgba(201,242,72,.1);
}
.ddown-btn .ddown-caret { margin-right: auto; transition: transform .25s cubic-bezier(.22,1,.36,1); }
.ddown.is-open .ddown-btn .ddown-caret { transform: rotate(180deg); }

.ddown-menu {
    position: absolute; top: calc(100% + .45rem); left: 0; z-index: 60;
    min-width: 100%; width: max-content; max-width: 16rem;
    padding: .35rem; border-radius: 1rem;
    border: 1px solid rgba(255,255,255,.1);
    background: rgba(19,22,27,.97);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 24px 56px -20px rgba(0,0,0,.9);
    opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.97);
    transform-origin: top left;
    transition: opacity .2s ease, transform .22s cubic-bezier(.22,1,.36,1), visibility 0s .22s;
}
.ddown.is-open .ddown-menu {
    opacity: 1; visibility: visible; transform: translateY(0) scale(1);
    transition: opacity .2s ease, transform .22s cubic-bezier(.22,1,.36,1), visibility 0s 0s;
}
.ddown-item {
    display: flex; align-items: center; gap: .55rem; width: 100%;
    text-align: right; font-size: .72rem; font-weight: 700; color: #a1a1aa;
    padding: .55rem .7rem; border-radius: .65rem; cursor: pointer;
    transition: background .18s, color .18s; background: transparent; border: 0;
}
.ddown-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.ddown-item .ddown-check { opacity: 0; color: var(--volt); margin-right: auto; transition: opacity .18s; }
.ddown-item[aria-selected="true"] { color: var(--volt); background: rgba(201,242,72,.08); }
.ddown-item[aria-selected="true"] .ddown-check { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .ddown-menu, .ddown-btn .ddown-caret { transition: none !important; }
}

/* selectهای فرم که به دراپ‌داون سفارشی تبدیل می‌شوند */
.select-native-hidden {
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    opacity: 0 !important; pointer-events: none !important;
    overflow: hidden !important; clip: rect(0 0 0 0) !important;
}
.custom-select { display: block; width: 100%; }
.custom-select .ddown-btn {
    width: 100%; min-width: 0; min-height: 2.65rem;
    justify-content: flex-start;
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.1);
    font-size: .82rem; font-weight: 600;
}
.custom-select .ddown-label {
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
    text-align: right; white-space: nowrap;
}
.custom-select .ddown-menu {
    right: 0; left: auto; width: 100%;
    min-width: min(15rem, calc(100vw - 2rem)); max-width: min(22rem, calc(100vw - 2rem));
    max-height: 18rem; overflow-y: auto;
    transform-origin: top right;
}
.custom-select .ddown-item { min-height: 2.35rem; }
.custom-select .ddown-item:focus-visible {
    outline: 2px solid rgba(201,242,72,.5); outline-offset: -2px;
}
.custom-select.is-disabled { opacity: .5; pointer-events: none; }
.custom-select.is-open { z-index: 70; }

/* =========================================================
   کارت‌های اطلاعیه — شیشه‌ای و تمام‌رنگی
   ========================================================= */
.ann-glass {
    position: relative; overflow: hidden;
    border-radius: 1.15rem;
    border: 1px solid transparent;
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    transition: transform .25s cubic-bezier(.22,1,.36,1), border-color .25s, box-shadow .25s;
}
.ann-glass:hover { transform: translateY(-2px); }

/* تیچ رنگی محیطی + لبه‌ی رنگی */
.ann-glass-info {
    background: linear-gradient(135deg, rgba(56,189,248,.12), rgba(56,189,248,.05) 45%, rgba(19,22,27,.55));
    border-color: rgba(56,189,248,.28);
}
.ann-glass-info:hover { box-shadow: 0 18px 44px -18px rgba(56,189,248,.35); border-color: rgba(56,189,248,.45); }

.ann-glass-success {
    background: linear-gradient(135deg, rgba(52,211,153,.12), rgba(52,211,153,.05) 45%, rgba(19,22,27,.55));
    border-color: rgba(52,211,153,.28);
}
.ann-glass-success:hover { box-shadow: 0 18px 44px -18px rgba(52,211,153,.35); border-color: rgba(52,211,153,.45); }

.ann-glass-warning {
    background: linear-gradient(135deg, rgba(251,191,36,.13), rgba(251,191,36,.05) 45%, rgba(19,22,27,.55));
    border-color: rgba(251,191,36,.3);
}
.ann-glass-warning:hover { box-shadow: 0 18px 44px -18px rgba(251,191,36,.35); border-color: rgba(251,191,36,.5); }

.ann-glass-danger {
    background: linear-gradient(135deg, rgba(244,63,94,.13), rgba(244,63,94,.05) 45%, rgba(19,22,27,.55));
    border-color: rgba(244,63,94,.3);
}
.ann-glass-danger:hover { box-shadow: 0 18px 44px -18px rgba(244,63,94,.4); border-color: rgba(244,63,94,.5); }

/* درخشش ظریف بالا-راست کارت */
.ann-glass::before {
    content: ''; position: absolute; top: -40%; right: -12%;
    width: 65%; height: 90%; border-radius: 999px;
    pointer-events: none; filter: blur(46px); opacity: .35;
    background: currentColor;
}
.ann-glass-info::before    { color: rgba(56,189,248,.5); }
.ann-glass-success::before { color: rgba(52,211,153,.5); }
.ann-glass-warning::before { color: rgba(251,191,36,.5); }
.ann-glass-danger::before  { color: rgba(244,63,94,.5); }

/* چیپ آیکون رنگی شیشه‌ای */
.ann-chip {
    width: 2.75rem; height: 2.75rem; border-radius: 1rem; flex-shrink: 0;
    display: grid; place-items: center;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 8px 20px -10px rgba(0,0,0,.6);
}

/* برچسب «جدید» با نبض ظریف */
@keyframes annNewPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201,242,72,.35); }
    50%      { box-shadow: 0 0 0 5px rgba(201,242,72,0); }
}
.ann-badge-new {
    font-size: .62rem; font-weight: 900; padding: .28rem .65rem; border-radius: 999px;
    color: var(--volt); background: rgba(201,242,72,.12); border: 1px solid rgba(201,242,72,.35);
    animation: annNewPulse 1.8s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .ann-badge-new { animation: none; } }

/* تب‌های فیلتر دسته‌بندی شاگردان */
.plan-tab {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .72rem; font-weight: 800; color: #a1a1aa;
    padding: .5rem .85rem; border-radius: 999px;
    border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.03);
    transition: all .2s; white-space: nowrap;
}
.plan-tab:hover { color: #fff; border-color: rgba(255,255,255,.2); }
.plan-tab-active {
    color: var(--volt) !important; border-color: rgba(201,242,72,.45) !important;
    background: rgba(201,242,72,.1) !important;
}
.plan-tab-count {
    font-size: .62rem; font-weight: 900; padding: .05rem .4rem;
    border-radius: 999px; background: rgba(255,255,255,.08); color: inherit; min-width: 1.1rem; text-align: center;
}

/* کارت انتخاب پلن در فرم شاگرد */
.plan-card input:focus-visible + div { outline: 2px solid rgba(201,242,72,.5); outline-offset: 2px; }

/* حالت خالی */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .55rem; padding: 2.5rem 1rem; color: #52525b; text-align: center;
    font-size: .8rem;
}

/* دراپ‌زون */
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: .5rem;
    border: 1.5px dashed rgba(255,255,255,.18); border-radius: 1rem;
    padding: 1.6rem 1rem; cursor: pointer; text-align: center;
    transition: all .25s; background: rgba(255,255,255,.015);
}
.dropzone:hover, .dropzone-hot { border-color: rgba(201,242,72,.5); background: rgba(201,242,72,.05); }

/* انیمیشن ورود */
@keyframes fadeup { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
.animate-fadeup { animation: fadeup .45s cubic-bezier(.22,1,.36,1) both; }

/* توست */
.toast {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .85rem 1rem; border-radius: 1rem; font-size: .8rem; font-weight: 600;
    border: 1px solid; backdrop-filter: blur(10px);
    animation: fadeup .35s ease both; box-shadow: 0 16px 40px -16px rgba(0,0,0,.8);
}
.toast-success { background: rgba(20,40,20,.9); border-color: rgba(52,211,153,.35); color: #a7f3d0; }
.toast-error   { background: rgba(45,18,18,.9); border-color: rgba(248,113,113,.35); color: #fecaca; }
.toast-info    { background: rgba(18,26,40,.9); border-color: rgba(96,165,250,.35);  color: #bfdbfe; }

/* حباب‌های چت */
.msg { display: flex; max-width: 82%; animation: fadeup .25s ease both; }
.msg-mine { margin-right: auto; flex-direction: row-reverse; }
.msg-bubble {
    padding: .6rem .9rem; border-radius: 1.1rem; font-size: .85rem; line-height: 1.8;
    position: relative; word-break: break-word;
}
.msg:not(.msg-mine) .msg-bubble {
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
    border-bottom-right-radius: .3rem; color: #e4e4e7;
}
.msg-mine .msg-bubble {
    background: linear-gradient(135deg, rgba(201,242,72,.16), rgba(201,242,72,.07));
    border: 1px solid rgba(201,242,72,.25); color: #fff;
    border-bottom-left-radius: .3rem;
}
.msg-meta { display: flex; align-items: center; gap: .3rem; font-size: .6rem; color: #71717a; margin-top: .3rem; }
.msg-mine .msg-meta { justify-content: flex-end; }

/* دیت‌پیکر شمسی */
#jalaliPicker .glass { box-shadow: 0 20px 60px -20px rgba(0,0,0,.8); }
#jalaliPicker button[data-jp-day] { cursor: pointer; }
#jpYearSelect::-webkit-scrollbar { width: 4px; }
#jpYearSelect::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 9px; }

/* منوی عملیات پیام */
.msg-context-menu {
    min-width: 150px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    animation: fadeup .15s ease both;
}
.msg:hover .msg-bubble { filter: brightness(1.03); }
.msg .msg-bubble {
    cursor: pointer;
    transition: filter .2s;
    /* جلوگیری از سلکت شدن متن توسط سیستم‌عامل هنگام نگه داشتن */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* جلوگیری از باز شدن منوی پیش‌فرض در برخی مرورگرهای موبایل */
    -webkit-touch-callout: none;
}

/* نقل‌قول reply */
.reply-quote {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    background: rgba(255,255,255,.04);
    border-radius: .6rem;
    padding: .4rem .65rem;
    margin-bottom: .4rem;
    border-right: 2.5px solid var(--volt);
    transition: background .2s;
    max-width: 100%;
    overflow: hidden;
}
.reply-quote:hover { background: rgba(201,242,72,.06); }
.reply-quote-name {
    font-size: .6rem;
    font-weight: 800;
    color: var(--volt);
    line-height: 1;
}
.reply-quote-body {
    font-size: .68rem;
    color: #a1a1aa;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}
.msg-mine .reply-quote { border-right: none; border-left: 2.5px solid var(--volt); }

/* =========================================================
   پیام صوتی (ویس) — پخش‌کننده و ضبط
   ========================================================= */
.voice-msg {
    display: flex; align-items: center; gap: .55rem;
    min-width: 178px; max-width: 240px; margin-bottom: .3rem;
    direction: ltr; /* کنترل‌های پخش همیشه چپ‌به‌راست */
    -webkit-user-select: none; user-select: none;
}
.voice-play {
    width: 2.15rem; height: 2.15rem; border-radius: 999px; flex-shrink: 0;
    display: grid; place-items: center; cursor: pointer;
    background: rgba(255,255,255,.09); color: #fff;
    border: 1px solid rgba(255,255,255,.16);
    transition: background .2s, transform .15s, color .2s;
}
.voice-play:hover { background: rgba(255,255,255,.16); }
.voice-play:active { transform: scale(.9); }
.msg-mine .voice-play {
    background: rgba(201,242,72,.18); color: var(--volt);
    border-color: rgba(201,242,72,.35);
}
.msg-mine .voice-play:hover { background: rgba(201,242,72,.3); }
.voice-track { position: relative; flex: 1; height: 20px; cursor: pointer; }
.voice-track::before {
    content: ''; position: absolute; left: 0; right: 0; top: 50%;
    height: 4px; transform: translateY(-50%);
    background: rgba(255,255,255,.14); border-radius: 99px;
}
.msg-mine .voice-track::before { background: rgba(201,242,72,.18); }
.voice-track-fill {
    position: absolute; left: 0; top: 50%; height: 4px;
    transform: translateY(-50%); width: 0;
    background: currentColor; border-radius: 99px;
    color: #e4e4e7;
}
.msg-mine .voice-track-fill { color: var(--volt); }
.voice-dur {
    font-size: .66rem; color: #a1a1aa; min-width: 32px;
    text-align: center; font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.msg-mine .voice-dur { color: rgba(255,255,255,.78); }
.voice-msg audio { display: none; }

/* نقطه‌ی ضبط چشمک‌زن */
.voice-rec-dot { animation: recPulse 1.1s ease-out infinite; }
@keyframes recPulse {
    0%   { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
    100% { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
}
#btnVoice.is-recording { color: #f87171; }

/* =========================================================
   کامپوزر ضبط ویس (جایگزین چیدمان هنگام ضبط)
   ========================================================= */
.voice-hide { display: none !important; }
/* لمس طولانی روی میکروفون نباید صفحه را اسکرول کند (ژست «بالا کشیدن») */
#btnVoice { touch-action: none; -webkit-user-select: none; user-select: none; }
.voice-recorder[hidden],
.voice-recorder.hidden { display: none !important; }
.voice-recorder {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem .65rem;
    background: linear-gradient(180deg, rgba(201,242,72,.07), transparent);
}
.voice-rec-cancel { color: #f87171; }
.voice-rec-cancel:hover { background: rgba(239,68,68,.14); color: #f87171; }
.voice-rec-timer {
    font-size: .78rem; font-weight: 700; color: #f87171;
    font-variant-numeric: tabular-nums; min-width: 38px;
    direction: ltr; text-align: center;
}
.voice-rec-wave {
    flex: 1; min-width: 40px; height: 38px;
    display: flex; align-items: center; gap: 2px;
    overflow: hidden; direction: ltr;
}
.voice-rec-wave i {
    display: block; width: 3px; min-height: 3px; flex-shrink: 0;
    border-radius: 99px;
    background: linear-gradient(180deg, var(--volt), rgba(201,242,72,.3));
}
.voice-rec-hint {
    font-size: .62rem; color: #a1a1aa; white-space: nowrap;
    max-width: 190px; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 640px) {
    .voice-rec-hint { display: none; }
    .voice-recorder { gap: .45rem; padding: .55rem .5rem; }
}
/* حباب ویس: در موبایل کمی بازتر تا کنترل‌ها لمس‌پذیر بمانند */
.voice-msg { min-width: 168px; }
@media (max-width: 480px) { .voice-msg { min-width: 152px; max-width: 210px; } }
.voice-msg .voice-track:active .voice-track-fill { filter: brightness(1.4); }

/* دکمه‌های تماس */
.call-btn {
    width: 3.4rem; height: 3.4rem; border-radius: 1.2rem;
    display: grid; place-items: center; color: #fff;
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14);
    backdrop-filter: blur(12px); cursor: pointer; transition: all .2s;
}
.call-btn:hover { background: rgba(255,255,255,.18); transform: translateY(-2px); }
.call-btn:active { transform: scale(.94); }
.call-btn-off { background: #fff !important; color: #111 !important; }

/* دکمه‌ی کوچک تعویض لنز — چسبیده به دکمه‌ی دوربین و متمایز */
.cam-group { display: inline-flex; }
.cam-flip-btn {
    position: absolute; top: -6px; left: -6px; z-index: 5;
    width: 1.75rem; height: 1.75rem; border-radius: 999px;
    display: grid; place-items: center;
    background: var(--volt); color: var(--ink);
    border: 2px solid #0B0D10;
    box-shadow: 0 6px 18px -6px rgba(201,242,72,.75);
    cursor: pointer; transition: transform .2s ease, filter .2s ease;
}
.cam-flip-btn:hover  { filter: brightness(1.08); transform: scale(1.1); }
.cam-flip-btn:active { transform: scale(.9); }
.cam-flip-btn.is-busy { opacity: .55; pointer-events: none; }
/* چرخش هنگام تعویض */
@keyframes camFlipSpin { to { transform: rotate(360deg); } }
.cam-flip-btn.is-busy i { animation: camFlipSpin .7s linear infinite; }

@media (max-width: 767px) {
    .cam-flip-btn { width: 1.6rem; height: 1.6rem; top: -5px; left: -5px; }
}
@media (prefers-reduced-motion: reduce) {
    .cam-flip-btn, .cam-flip-btn.is-busy i { transition: none; animation: none; }
}
.call-btn-end {
    width: 4rem; height: 3.4rem; border-radius: 1.2rem;
    background: #ef4444; border-color: #ef4444;
    box-shadow: 0 10px 30px -8px rgba(239,68,68,.6);
}
.call-btn-end:hover { background: #dc2626; }

/* کاشی ویدیو گروهی */
.peer-tile {
    position: relative; border-radius: 1.1rem; overflow: hidden;
    background: #181b21; border: 1px solid rgba(255,255,255,.1);
    min-height: 140px;
}
.peer-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.peer-name {
    position: absolute; bottom: .5rem; right: .5rem; z-index: 2;
    font-size: .65rem; font-weight: 700; color: #fff;
    background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
    padding: .25rem .55rem; border-radius: .55rem;
    display: flex; align-items: center; gap: .3rem;
}
.peer-off-avatar {
    position: absolute; inset: 0; display: grid; place-items: center; background: #181b21;
}
.peer-speaking { outline: 2px solid var(--volt); outline-offset: -2px; }

.safe-top { padding-top: max(.75rem, env(safe-area-inset-top)); }

/* اسکرول‌بار */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* چیدمان واکنش‌گرای شبکه‌ی تماس */
#remoteGrid { grid-template-columns: 1fr; grid-auto-rows: 1fr; }
@media (min-width: 640px) {
    #remoteGrid.grid-2 { grid-template-columns: repeat(2, 1fr); }
    #remoteGrid.grid-3 { grid-template-columns: repeat(2, 1fr); }
    #remoteGrid.grid-4 { grid-template-columns: repeat(2, 1fr); }
    #remoteGrid.grid-many { grid-template-columns: repeat(3, 1fr); }
}
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* دکمه‌های کوچک پنل تایمر */
.tbtn {
    border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.03);
    color: #d4d4d8; font-size: .7rem; font-weight: 700;
    border-radius: .7rem; padding: .5rem .4rem; cursor: pointer;
    transition: all .2s;
}
.tbtn:hover { border-color: rgba(201,242,72,.4); color: var(--volt); }
.tbtn-active { background: rgba(201,242,72,.14) !important; color: var(--volt) !important; border-color: rgba(201,242,72,.4) !important; }
.call-btn-dim { opacity: .35; }

#timerChip.timer-done { border-color: rgba(248,113,113,.6); }
#timerChip.timer-done #timerValue { color: #f87171; }

/* بازه‌ی زمانی کمتر از یک دقیقه → نمایش SS.SS به‌جای MM:SS */
#timerChip[data-subminute] #timerValue { letter-spacing: .08em; font-variant-numeric: tabular-nums; }

/* پیش‌شمارش ۳…۲…۱ پیش از شروع تایمر */
@keyframes timerLeadPulse {
    0%   { transform: translateX(-50%) scale(1);    }
    35%  { transform: translateX(-50%) scale(1.14); }
    100% { transform: translateX(-50%) scale(1);    }
}
#timerChip.timer-lead {
    border-color: rgba(201,242,72,.65);
    box-shadow: 0 0 34px -8px rgba(201,242,72,.5);
    animation: timerLeadPulse .9s ease-in-out infinite;
}
#timerChip.timer-lead #timerValue { color: var(--volt); font-size: 2.1rem; letter-spacing: .05em; }
#timerChip.timer-lead #timerModeLbl { display: none; }

/* هشدار ثانیه‌های پایانی تایمر معکوس */
@keyframes timerWarnBlink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
#timerChip.timer-warn { border-color: rgba(251,191,36,.6); box-shadow: 0 0 26px -10px rgba(251,191,36,.55); }
#timerChip.timer-warn #timerValue { color: #fbbf24; animation: timerWarnBlink 1s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
    #timerChip.timer-lead, #timerChip.timer-warn #timerValue { animation: none !important; }
}

/* سایزهای تایمر */
#timerChip.timer-md { padding: .7rem 1.2rem; }
#timerChip.timer-md #timerValue { font-size: 1.5rem; }

#timerChip.timer-lg { padding: 1.2rem 2rem; border-radius: 2rem; }
#timerChip.timer-lg #timerValue { font-size: 3rem; letter-spacing: .15em; }
#timerChip.timer-lg #timerModeLbl { font-size: .7rem; }
#timerChip.timer-lg i { width: 1.5rem; height: 1.5rem; }

#timerChip { cursor: move; touch-action: none; }

/* صفحه‌ی PDF */
.pdf-page-canvas {
    width: 100%; height: auto; border-radius: .75rem;
    box-shadow: 0 20px 50px -20px rgba(0,0,0,.9);
    border: 1px solid rgba(255,255,255,.08);
    background: #fff;
}

/* =========================================================
   بهینه‌سازی موبایل
   ========================================================= */
@media (max-width: 767px) {
    .card { padding: 1rem; border-radius: 1rem; }
    .section-title { font-size: .88rem; }
    .btn-primary, .btn-ghost, .btn-danger { padding: .6rem .9rem; font-size: .8rem; }
    .avatar-xl { width: 3.5rem; height: 3.5rem; font-size: 1.15rem; border-radius: 1.1rem; }
    .row-item { padding: .7rem; gap: .6rem; border-radius: .85rem; }
    .empty-state { padding: 1.75rem .75rem; }

    /* دکمه‌های تماس در موبایل جمع‌وجورتر */
    .call-btn { width: 3rem; height: 3rem; border-radius: 1rem; }
    .call-btn-end { width: 3.6rem; height: 3rem; }

    /* جدول/شبکه‌ها سرریز نکنند */
    table { display: block; overflow-x: auto; }
    pre, code { white-space: pre-wrap; word-break: break-word; }
}

/* اهداف لمسی حداقل ۴۰px برای دسترسی‌پذیری */
@media (hover: none) and (pointer: coarse) {
    .icon-btn { min-width: 2.5rem; min-height: 2.5rem; }
    a, button { touch-action: manipulation; }
}

/* جلوگیری از سرریز افقی عناصر طولانی (ایمیل/لینک/نام فایل) */
.break-anywhere { overflow-wrap: anywhere; word-break: break-word; }

/* ارتفاع پویا برای مرورگر موبایل (نوار آدرس) */
.h-dvh { height: 100dvh; }

/* =========================================================
   Safe Area — فقط در حالت نصب‌شده (standalone / PWA)
   نوچ بالا و نوار هوم پایین آیفون رعایت می‌شود
   ========================================================= */
@media (display-mode: standalone) {
    /*
       iOS standalone safe-area — ساده و تمیز:
       فقط padding-top و padding-bottom به containerها اضافه می‌شود.
       ارتفاع هیچ عنصری تغییر نمی‌کند.
    */

    /* بالای صفحه: هدر فقط padding-top برای نوچ */
    .app-header {
        padding-top: env(safe-area-inset-top, 0px);
        /* ارتفاع کمی بیشتر تا دکمه‌ها زیر نوچ قرار بگیرند */
        min-height: calc(64px + env(safe-area-inset-top, 0px));
    }
    .app-sidebar { padding-top: env(safe-area-inset-top, 0px); }

    /* پایین صفحه: فوتر و سایدبار فقط padding-bottom برای home-indicator */
    .app-footer { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
    .app-sidebar { padding-bottom: env(safe-area-inset-bottom, 0px); }

    /* صفحه ورود */
    .auth-safe {
        padding-top: calc(2rem + env(safe-area-inset-top, 0px));
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    }

    /* چت تمام‌صفحه موبایل:
       از inset-0 استفاده می‌کند، پس safe-area باید روی خود container اعمال شود */
    .chat-fullscreen {
        top: env(safe-area-inset-top, 0px) !important;
        bottom: env(safe-area-inset-bottom, 0px) !important;
    }
    .chat-fullscreen .chat-composer {
        /* فرم ارسال داخل safe-area قرار دارد — padding اضافه نیاز نیست */
        padding-bottom: .75rem;
    }

    /* نمایشگر PDF */
    .viewer-header { padding-top: env(safe-area-inset-top, 0px); }
    .viewer-footer { padding-bottom: env(safe-area-inset-bottom, 0px); }

    /* توست‌ها */
    #toasts { bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); }
}

/* اتاق تماس — همیشه safe-area رعایت شود (حتی در مرورگر) */
#callRoot .call-controls { padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)); }
#callRoot .call-topbar { padding-top: max(.75rem, env(safe-area-inset-top, 0px)); }
.call-chat-panel .chat-composer { padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)); }
.call-chat-panel { padding-top: env(safe-area-inset-top, 0px); }

/* پنل چت داخل تماس — آف‌اسکرین از چپ و تصویر در بالای اتاق */
/* پنل چت داخل تماس — در صورت وجود دورهٔ تغییرات، عالی است. و ارتفاع دقیق */
#classChatPanel.call-chat-panel { height: 100dvh; transform: translateX(-100%); }
html body #callRoot #classChatPanel { height: 100dvh; }

/* رفع مشکل زوم دوباره تپ کردن روی آیتم‌های صفحه */
@media (hover: none) {
    body, .card, .row-item, .nav-item, .call-btn { cursor: default; }
}
.call-chat-panel.is-open { transform: translateX(0) !important; }
.call-chat-panel.is-open { -webkit-transform: translateX(0) !important; }

/* اتاق تماس: ارتفاع پویا و جلوگیری از انتخاب ناخواسته */
#callRoot { height: 100dvh; }

/* =========================================================
   اتاق تماس — نمایش ویدیو (بدون تغییر در منطق اتصال)
   ========================================================= */
/* فریم اصلی: تمام‌صفحه و مرکزینگ — زوم/کراپ هرگز اتفاق نمی‌افتد */
#remoteFull {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: #07080a;
}
/* عرض/ارتفاع توسط JS بر اساس نسبت واقعی استریم کمپوت می‌شود */
#remoteVideoFull { max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; }

/* PiP — لمسی تمیز و قابل جابه‌جایی (بدون متن راهنما) */
#selfPip {
    touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
    transition: box-shadow .25s, opacity .3s ease, transform .3s cubic-bezier(.22,1,.36,1), visibility 0s 0s;
}
#selfPip:active { cursor: grabbing; }
#selfPip.dragging { box-shadow: 0 24px 60px -18px rgba(0,0,0,.9); transition: none !important; border-color: rgba(201,242,72,.45); }

/* دوربین خاموش → PiP کاملاً ناپدید می‌شود (مثل واتس‌اپ) */
#selfPip.pip-hidden {
    opacity: 0; transform: scale(.85); pointer-events: none; visibility: hidden;
    transition: opacity .28s ease, transform .28s cubic-bezier(.22,1,.36,1), visibility 0s .28s;
}

/* درگ روی فریم PiP هم جواب دهد (فقط در حالت لمسی، فیلد ویدیو ممکن است زمه را بگیرد) */
#selfPip video { pointer-events: none; }  /* اشاره‌گرها به فریم می‌رسند */

/* =========================================================
   HUD اتاق تماس — پنهان/نمایان با کلیک وسط صفحه
   ========================================================= */
.call-hud { transition: opacity .32s ease, transform .32s cubic-bezier(.22,1,.36,1), visibility 0s 0s; }
#callRoot.hud-hidden .call-hud {
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .28s ease, transform .28s cubic-bezier(.22,1,.36,1), visibility 0s .28s;
}
#callRoot.hud-hidden .call-hud-top    { transform: translateY(-14px); }
#callRoot.hud-hidden .call-hud-bottom { transform: translateY(16px); }
#callRoot.hud-hidden #selfPip {
    opacity: 0; transform: scale(.9); pointer-events: none; visibility: hidden;
    transition: opacity .28s ease, transform .28s cubic-bezier(.22,1,.36,1), visibility 0s .28s;
}

@media (prefers-reduced-motion: reduce) {
    .call-hud, #selfPip { transition: none !important; }
}
