/* ══ قاب سامانه، به شکل تصویر مرجع ═════════════════════════════════════════
   «ui کل سامانه و نمایش ساید بارش دقیقا مثل اسکرین شات بشه، فقط رنگ ساید بار
   نمیخوام مشکی شه و همون حالت آیکون‌ها وقتی کلیک میشن روشن باشن با هاورش».

   آنچه از مرجع آمده:
     · منو یک ستون ساده در قاب است، با نشان شرکت در سرش؛
     · خودِ صفحه یک پنل بزرگ با گوشه‌های گرد است که کنار منو نشسته، و جست‌وجو و
       دکمه‌های اعلان و پروفایل در سرِ همین پنل‌اند؛
     · گزینه‌ی فعال منو زبانه‌ای است به رنگ پنل که با دو گوشه‌ی کاو در پنل جاری
       می‌شود — منو و صفحه یک تکه می‌شوند؛
     · کارت‌ها سفید و تخت روی پنل خاکستری، با گوشه‌های گرد و بی‌سایه.
   آنچه از خودِ کارینا ماند: رنگ منو (سفید، نه سیاه)، و آیکونِ گزینه‌ی فعال که
   در مربع بنفش روشن می‌شود و با هاور رنگ می‌گیرد.

   این فایل آخرین برگه‌ی سبک است و فقط قاب را می‌کشد. زیر ۹۰۰ پیکسل منو همان
   کشوی کناری است و قاب کنار می‌رود. */

:root {
    --frame: #ffffff;            /* رنگ منو و قاب دورِ پنل */
    --panel-bg: #f1f1f7;         /* خودِ پنل؛ کارت سفید رویش پیدا است */
    --frame-gap: 12px;
    --panel-r: 28px;
    --side-w: 250px;
    --tab-r: 18px;               /* گوشه‌ی زبانه و گوشه‌های کاوِ دو طرفش */
}

@media (min-width: 901px) {
    body:not(.no-chrome) { background: var(--frame); }

    .layout { display: flex; align-items: stretch; min-height: 100vh; }

    /* ── منو ── */
    .sidebar {
        width: var(--side-w);
        position: sticky;
        top: 0;
        height: 100vh;
        height: 100dvh;
        background: var(--frame);
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
    }
    .side-brand {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        /* little under the logo: the list below keeps the room its first
           tab's curve needs instead */
        padding: 1.15rem 1.25rem 0.25rem;
        flex-shrink: 0;
    }
    .side-brand .brand { gap: 0.6rem; }
    .side-brand .brand-tile .brand-mark { height: 28px; filter: brightness(0) invert(1); }
    .side-brand .workspace-name { font-size: 0.85rem; padding-inline-start: 0.65rem; }
    /* ستون گزینه‌ها تا لبه‌ی پنل می‌رود، تا زبانه‌ی فعال به آن برسد */
    .side-nav {
        flex: 1;
        height: auto;
        min-height: 0;
        /* «وقتی روی داشبورد می‌زنم قسمت بالای فیلد مثل پایینش کرو نیست»: the
           list scrolls inside itself, so whatever lies outside its box is cut
           off. The active tab reaches 5px past its row and its curve 18px past
           that; 24px at each end of the list leaves the first row's upper
           curve and the last row's lower one whole, at every density
           side-fit.js picks.
           At the foot more: «وقتی روی دستیار کلیک میکنم فاصله هست». The page
           panel's edge stops being straight 40px above the window (12px margin
           + 28px corner), and a tab beside that corner can only stand apart.
           66px of room after the last row (5 + 18 for the tab and its curve,
           40 for the corner, 3 to spare) lets the opening page lift the menu
           so that even the last row's tab sits on the straight edge, merged
           (base.html, karinaActiveInView). */
        padding-block-start: 24px !important;
        padding-block-end: 66px !important;
        /* side-fit.js may tighten the list on a short screen; whatever it does,
           the far side stays at 0 so the active tab still reaches the panel.
           Written as right/left, not start/end: the list box itself runs
           left-to-right (see below, for its scrollbar) and «start» would turn
           to the panel's side. */
        padding-right: 0.85rem !important;
        padding-left: 0 !important;
    }
    .side-link {
        position: relative;
        padding-inline-end: 0.85rem;
        /* «وقتی هاور روی نوشته‌های منو میاد لبه‌های گرد باشه، مستطیلی نباشه» */
        border-radius: 14px;
    }
    /* زبانه‌ی فعال: هم‌رنگ پنل، گرد از سمت منو، صاف از سمت پنل */
    /* «عرض فیلدی که دور نوشته هست رو یکم بیشتر کن»: the tab reaches 5px past
       the row above and below and 6px past the icon, so the purple tile sits
       inside it with room; negative margins keep every other row in place. */
    .side-link.active {
        background: var(--panel-bg);
        margin-block: -5px;
        padding-block: calc(0.4rem + 5px);
        margin-inline-start: -6px;
        padding-inline-start: calc(0.5rem + 6px);
        border-start-start-radius: var(--tab-r);
        border-end-start-radius: var(--tab-r);
        border-start-end-radius: 0;
        border-end-end-radius: 0;
    }
    /* دو گوشه‌ی کاو، بالا و پایین زبانه، کنار پنل: سفیدیِ منو با گردی تمام می‌شود
       و رنگ پنل از زیرش بیرون می‌زند. صفحه راست‌به‌چپ است، پس پنل سمت چپ است. */
    .side-link.active::before,
    .side-link.active::after {
        content: "";
        position: absolute;
        left: 0;
        width: var(--tab-r);
        height: var(--tab-r);
        pointer-events: none;
    }
    .side-link.active::before {
        top: calc(-1 * var(--tab-r));
        background: radial-gradient(circle at 100% 0, transparent calc(var(--tab-r) - 0.5px), var(--panel-bg) var(--tab-r));
    }
    .side-link.active::after {
        bottom: calc(-1 * var(--tab-r));
        background: radial-gradient(circle at 100% 100%, transparent calc(var(--tab-r) - 0.5px), var(--panel-bg) var(--tab-r));
    }
    /* آیکون فعال همان مربع بنفشِ روشن می‌ماند؛ هاور همان رنگِ کم‌جان */
    .side-link.active .side-icon {
        background: var(--accent);
        color: #ffffff;
        box-shadow: 0 6px 14px rgba(79, 70, 229, 0.3);
    }
    /* «در منو آخرین بخش … فرم فیلد بهم میریزه» and «یک تیکه صفحه سفید روش
       میاد»: the page panel's edge is straight except at its rounded corners —
       at the foot of a page scrolled to its end, its last 40px (12px margin +
       28px radius). A tab that merged into the panel there ran its curves into
       the corner. So beside a corner the tab stands alone, a rounded pill
       clear of the panel, and merges again as soon as it is beside the
       straight edge (side-fit.js marks it «is-loose»). The menu itself runs
       to the window's edge — no white band over it. */
    .side-nav.is-settled .side-link.active {
        transition: border-radius 0.18s ease, margin 0.18s ease;
    }
    .side-nav.is-settled .side-link.active::before,
    .side-nav.is-settled .side-link.active::after { transition: opacity 0.18s ease; }
    .side-link.active.is-loose {
        border-radius: var(--tab-r);
        margin-inline-end: 10px;
    }
    .side-link.active.is-loose::before,
    .side-link.active.is-loose::after { opacity: 0; }
    .side-compact .side-link.active { padding-block: calc(0.3rem + 5px); }
    .side-tight .side-link.active { padding-block: calc(0.18rem + 4px); margin-block: -4px; }
    /* the tab is the page itself: hovering it must not tint it away from the
       panel its curved corners flow into (the ids only outweigh the shared
       hover palette in interactions.css) */
    .sidebar .side-link.active:not(#kc-a):not(#kc-b):hover {
        background-color: var(--panel-bg) !important;
        border-color: transparent !important;
        box-shadow: none !important;
    }
    .sidebar .side-link.active:not(#kc-a):not(#kc-b):hover .side-icon {
        background-color: var(--accent) !important;
        color: #ffffff !important;
    }

    /* خط کنار منو جای خودش را به لبه‌ی پنل داده است.
       دکمه‌ی جمع کردن: «فقط نوک پیکان، کوچک ولی ضخیم، وسط ساید بار، داخل
       زمینه‌ی سفید و بیرون نزند، بی دایره». خودِ فلش است و بس، روی سفیدیِ منو
       کنار لبه‌ی پنل، نیمه‌ی ارتفاع صفحه؛ منو چسبان است، پس با اسکرول همان‌جا
       می‌ماند. جای کلیک بلندتر از خودِ فلش است تا راحت زده شود، و باریک، تا
       در منوی جمع‌شده هم به آیکون‌ها نرسد. */
    .side-rail { display: none; }
    .side-fold-btn {
        z-index: 6;
        top: calc(50% - 20px);
        inset-inline-end: 4px;
        width: 16px;
        height: 40px;
        border-radius: 8px;
        background: transparent;
        color: var(--accent);
        box-shadow: none;
    }
    .side-fold-btn .icn { width: 16px; height: 16px; stroke-width: 3.2; }
    .side-fold-btn:hover { background: transparent; color: var(--accent-deep); box-shadow: none; }
    body.side-folded .side-nav { padding-right: 0.75rem !important; }
    /* folded, the arrow keeps a lane of its own beside the panel: icons and
       logo centre in what is left, so the arrow never touches an icon */
    body.side-folded .side-link { padding-inline: 0 20px; justify-content: center; }
    body.side-folded .side-link.active { margin-inline-start: 0; padding-inline-start: 0; }
    body.side-folded .side-brand { justify-content: center; padding-inline: 0.75rem 20px; }
    body.side-folded .side-brand .brand-name,
    body.side-folded .side-brand .workspace-name { display: none; }

    /* ── پنل ── */
    .app-frame {
        flex: 1;
        min-width: 0;
        margin: var(--frame-gap);
        margin-inline-start: 0;
        background: var(--panel-bg);
        border-radius: var(--panel-r);
        min-height: calc(100vh - 2 * var(--frame-gap));
        display: flex;
        flex-direction: column;
    }
    /* نوار بالای پنل: جست‌وجوی سفیدِ پهن، و سه دکمه‌ی گرد در انتها */
    .topbar {
        background: var(--panel-bg);
        border-bottom: 0;
        border-radius: var(--panel-r) var(--panel-r) 0 0;
        padding: 0 1.5rem;
        gap: 1rem;
    }
    .topbar.is-scrolled {
        border-radius: 0 0 var(--tab-r) var(--tab-r);
        box-shadow: 0 10px 22px -14px rgba(28, 25, 60, 0.28);
    }
    .brand-phone { display: none !important; }
    .topbar-search { justify-content: flex-start; }
    .topbar .search-wrap { max-width: 640px; }
    .topbar form.topbar-search input[type="search"] {
        background: var(--surface);
        border: 1px solid transparent;
        border-radius: 999px;
        height: 40px;
    }
    .topbar form.topbar-search input[type="search"]:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
    }
    .topbar-actions { gap: 0.6rem; }
    .topbar-item { gap: 0; }
    .topbar-cap {
        position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
    }
    /* «۳ آیکون بالای سامانه کوچکتر و متناسب با سامانه»: the size of a menu
       icon tile, not bigger than the search beside them */
    .topbar-disc, .topbar-avatar { width: 36px; height: 36px; }
    .topbar-disc .icn { width: 17px; height: 17px; }
    .topbar-disc { background: var(--surface); }
    .topbar-item:hover .topbar-disc { background: var(--surface); color: var(--accent-ink); box-shadow: 0 0 0 2px var(--accent-soft); }
    .topbar-avatar { box-shadow: 0 0 0 2px var(--panel-bg), 0 0 0 3.5px var(--accent); font-size: 0.8rem; }
    .bell-count { box-shadow: 0 0 0 2px var(--surface); }

    .content { padding: 0.5rem 1.5rem 1.75rem; }
}

/* ── کارت‌ها: سفید و تخت روی پنل، گرد و بی‌سایه، مثل مرجع ── */
.panel, .card, .stat {
    border-radius: 20px;
    box-shadow: none;
    border: 0;
}
.panel-head { border-bottom-color: var(--panel-bg); }
.card:is(a,[data-href],[onclick],[role="button"],.is-clickable):hover { box-shadow: 0 10px 26px -12px rgba(28, 25, 60, 0.18); }
.stat:is(a,[data-href],[onclick],[role="button"],.is-clickable):hover { box-shadow: 0 10px 26px -12px rgba(28, 25, 60, 0.18); }

/* ── جدول‌ها: سرستون آرام، خط‌های نازک میان ردیف‌ها ── */
.table th { font-weight: 600; }
.table td { border-bottom-color: var(--panel-bg); }

/* ── موبایل: همان کشوی کناری؛ نشان در نوار بالا ── */
@media (max-width: 900px) {
    .side-brand { display: none; }
    /* نوار بالا دوباره سراسری است و صفحه زیرش؛ منو کشوی ثابت کنار است */
    .layout { display: block; }
    .app-frame { display: contents; }
}

@media (prefers-reduced-motion: reduce) {
    .side-fold-btn { transition: none; }
    .side-nav.is-settled .side-link.active,
    .side-nav.is-settled .side-link.active::before,
    .side-nav.is-settled .side-link.active::after { transition: none; }
}

/* ── «هر جایی که قابل کلیک کردن هست، هاور دار باشه و آیکون دست بیاد روش» ──
   Everything that does something when clicked shows the hand; what is
   switched off shows that it is. Rows and cards that open by script carry
   data-href or role="button"/"link" and are covered here too. */
:is(a[href], button, summary, select, label[for], [role="button"], [role="link"], [role="tab"],
    [role="menuitem"], [role="option"], [data-href], [onclick], tr.rowhover,
    input:is([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="reset"],
             [type="file"], [type="color"], [type="range"], [type="image"]),
    label:has(> input:is([type="checkbox"], [type="radio"], [type="file"]))) {
    cursor: pointer;
}
:is(button, select, input, [role="button"], a):is(:disabled, [aria-disabled="true"], .is-soon, .disabled) {
    cursor: not-allowed;
}

/* ── «هر جایی که کلمه‌ای هست که لینک داره و باید دکمه بشه، فرم دکمه رو براش
   بذار» ── action words (ویرایش، حذف، بررسی، مشاهده، انصراف، همه …) are the
   portal's small action button, .act-btn; names and titles stay links. */
summary.act-btn { list-style: none; width: max-content; }
summary.act-btn::-webkit-details-marker { display: none; }
summary.act-btn::marker { content: ""; }
.panel-head .act-btn.head-link { margin-inline-start: auto; font-weight: 600; flex-shrink: 0; }
.panel-head .act-btn.head-link:hover { text-decoration: none; }
:is(td, p, li, div) > .act-btn + :is(.act-btn, form.inline-form),
td > form + .act-btn { margin-inline-start: 6px; }
.table td .act-btn { vertical-align: middle; }
.picker-tools { gap: 6px; }
@media (max-width: 700px) {
    .act-btn { min-height: 40px; }
}


/* ── نوار اسکرول منو سمت راست ──
   «نوار کشویی رو سمت راست منو قرار بده»: a right-to-left box draws its
   scrollbar on the left — here, between the menu and the page. The list box
   alone runs left-to-right, which puts the bar on the right, at the window's
   edge; every row inside it is right-to-left as before. A thin bar in the
   border's colour, so it is there when needed and quiet when not. */
.side-nav {
    direction: ltr;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.side-nav > * { direction: rtl; }
