/* =========================================================
   KnowledgeBase — لایه اختصاصی دانش‌نامه (بسته 2 نسخه قالب‌محور)
   مسیر: /Content/kb/kb.css
   این فایل «بعد از» style-rtl.css لود می‌شود و فقط مواردی را
   اضافه/تنظیم می‌کند که در کلاس‌های قالب نیست:
   درخت انواع، تگ دسته‌بندی، نوار متحرک جستجو، Suggest، TreeList، ترتیب ستون‌ها
   پالت = پالت قالب Disilab: #2d86eb آبی اصلی | #0d233e سرمه‌ای | #f9b851 طلایی
   ========================================================= */

:root {
    --kb-blue:   #2d86eb;   /* آبی اصلی قالب */
    --kb-blue-d: #2479d8;   /* هاور آبی */
    --kb-navy:   #0d233e;   /* سرمه‌ای عنوان‌ها */
    --kb-gray:   #6c727c;   /* متن ثانویه */
    --kb-border: rgba(128, 137, 150, 0.2);
    --kb-gold:   #f9b851;   /* تاکیدی قالب */
}

body.kb-body {
    font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
}

/* ============================ لوگوی متنی هدر (بدون فایل تصویر) ============================ */
.kb-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--kb-navy);
    line-height: 1.4;
}
.kb-logo i { color: var(--kb-blue); font-size: 1.7rem; }
.kb-logo small { font-size: .72rem; color: var(--kb-gray); font-weight: 500; display: block; }
.kb-logo.logo-white, .kb-logo.logo-white small { color: #fff; }

/* ============================ Hero (گرادیان به‌جای تصویر قالب) ============================ */
.hero-area.hero-bg-1 {
    background: #2d86eb;
    background: linear-gradient(135deg, #2479d8 0%, #2d86eb 55%, #39A1F2 100%);
}
.hero-area .overlay { background-color: rgba(13, 35, 62, 0.18); }
.hero-area .stroke-shape { background-color: rgba(255, 255, 255, 0.55); opacity: .35; }

/* ============================ فاز جستجو — Hero و Dropdown زنده ============================ */
/* (فهرست آمار Hero حذف شد — آمار در ویجت سایدبار است) */

/* ---- جستجوی بزرگ Hero ---- */
.kb-search-wrap { max-width: 760px; margin: 0 auto; }
#kbHeroQ { height: 56px; font-size: 1rem; padding-left: 52px; padding-right: 20px; }
.kb-hero-form .form-btn { font-size: 22px; color: var(--kb-blue); }

/* ---- مودهای جستجو — چیپ‌باکس (توافق کارفرما: دو گزینه اول تیک‌خورده) ---- */
.kb-mode-chips { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.kb-chip {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.45);
    color: #fff; border-radius: 30px;
    padding: 7px 16px; font-size: .88rem; cursor: pointer;
    user-select: none; transition: all .15s ease;
}
.kb-chip:hover { border-color: #fff; }
.kb-chip input { display: none; }
.kb-chip-box {
    width: 18px; height: 18px; border-radius: 6px;
    border: 1.5px solid rgba(255,255,255,.7);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; line-height: 1; color: transparent; transition: all .15s ease;
}
.kb-chip input:checked + .kb-chip-box { background: #fff; border-color: #fff; color: var(--kb-blue); }
.kb-chip:has(input:checked) { background: #fff; color: var(--kb-blue); border-color: #fff; font-weight: 500; }
.kb-chip:has(input:checked) .kb-chip-box { border-color: var(--kb-blue); }
.kb-chip-ai { opacity: .85; }
.kb-chip-soon { opacity: .55; cursor: not-allowed; }
.kb-chip-soon:hover { border-color: rgba(255,255,255,.45); }
.kb-chip-badge {
    font-size: .68rem; background: rgba(255,255,255,.28); color: #fff;
    border-radius: 20px; padding: 2px 8px;
}

/* ---- Dropdown زنده جستجو ---- */
.kb-live {
    display: none; position: absolute; top: 100%; right: 0; left: 0; z-index: 70;
    background: #fff; border-radius: 10px; margin-top: 8px;
    box-shadow: 0 10px 30px rgba(13, 35, 62, .18);
    max-height: 430px; overflow: auto; text-align: right;
}
.kb-live-head {
    display: flex; align-items: center; gap: 6px;
    font-size: .78rem; font-weight: 600; color: var(--kb-gray);
    padding: 10px 16px 6px; border-bottom: 1px solid rgba(128,137,150,.08);
}
.kb-live-head i { font-size: .85rem; }
.kb-live-head-ai { color: #7c3aed; }
.kb-live-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 16px; color: var(--kb-navy);
    border-bottom: 1px solid rgba(128,137,150,.08);
}
.kb-live-item:hover, .kb-live-item.kb-active { background: #f2f7fd; }
.kb-live-item > i { font-size: 1rem; margin-top: 3px; flex: 0 0 auto; }
.kb-live-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.kb-live-title { font-size: .9rem; font-weight: 500; }
.kb-live-meta { font-size: .75rem; color: var(--kb-gray); }
.kb-live-snip {
    font-size: .78rem; color: #6b7684; line-height: 1.8;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kb-live mark { background: #fff3bf; color: inherit; padding: 0 1px; border-radius: 3px; }
.kb-live-item-ai .kb-live-title { color: #4c1d95; }
.kb-live-pct {
    flex: 0 0 auto; font-size: .72rem; font-weight: 700; color: #7c3aed;
    background: rgba(124,58,237,.1); border-radius: 20px; padding: 4px 8px; margin-top: 2px;
}
.kb-live-empty { padding: 22px 16px; text-align: center; color: var(--kb-gray); font-size: .85rem; }
.kb-live-empty i { display: block; font-size: 1.6rem; margin-bottom: 6px; opacity: .5; }
.kb-live-err { color: #b42318; }
.kb-live-err i { opacity: 1; }
.kb-live-all {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 16px; font-size: .85rem; font-weight: 600;
    color: var(--kb-blue); background: #f7f9fc;
    border-radius: 0 0 10px 10px;
}
.kb-live-all:hover { background: #eef4fb; color: var(--kb-blue); }

/* ---- آیکون سه‌حالته جستجو + حاشیه هوش مصنوعی (Task 38 v3 — طرح اختصاصی کارفرما) ---- */
/* آیکون la-search قالب داخل دکمه فرم‌های دانش‌نامه، هنگام لود با مارک‌آپ اختصاصی
   (لنز + دسته + کاغذ پشت لنز + جرقه‌ها) که JS تزریق می‌کند جایگزین می‌شود.
   ماشین حالت (کلاس‌ها را JS روی خودِ آیکون می‌گذارد — setLiveBusy/syncSearchIcon):
   ۱) بدون درخواست در جریان (حتی با تیک AI) → search-icon              (ثابت)
   ۲) درخواست در جریان و AI خاموش          → search-icon animated      (کاغذ پشت ذره‌بین موج می‌زند)
   ۳) درخواست در جریان و تیک AI            → search-icon ai-animated   (ذره‌بین ↔ جرقه‌ها)
   هر دو حالت انیمیشنی فقط بین «ارسال درخواست» و «رسیدن پاسخ/خطا» زندگی می‌کنند
   (اصلاح Task 38 v3 — بستن به چرخه حیات request، نه به تیک چیپ).
   حاشیه گرادیان (kb-ai-border) مستقل از آیکون، نشانگر «حالت هوشمند روشن است». */

/* ========================================
   DarooCenter Search Icon
   Pure CSS | No external dependencies
   ======================================== */

.search-icon {
    --search-color: #17B1C6;
    --search-size: 32px;

    position: relative;
    display: inline-block;
    flex: 0 0 var(--search-size);
    width: var(--search-size);
    height: var(--search-size);
    vertical-align: middle;
    color: var(--search-color);
    isolation: isolate;
}

/* Magnifier lens */
.search-icon::before {
    content: "";
    position: absolute;
    z-index: 2;
    width: 15px;
    height: 15px;
    left: 5px;
    top: 5px;
    border: 2.5px solid currentColor;
    border-radius: 50%;
    box-sizing: border-box;
    transform-origin: center;
}

/* Magnifier handle */
.search-icon::after {
    content: "";
    position: absolute;
    z-index: 2;
    width: 10px;
    height: 2.5px;
    left: 17px;
    top: 19px;
    border-radius: 3px;
    background: currentColor;
    transform: rotate(45deg) !important;
    transform-origin: left center;
}

/* Paper behind the magnifier */
.search-icon .search-paper {
    position: absolute;
    z-index: 1;
    left: 7px;
    top: 3px;
    width: 17px;
    height: 22px;
    box-sizing: border-box;
    border: 1px solid currentColor;
    border-radius: 3px;
    background:
        linear-gradient(
            currentColor, currentColor
        ) 4px 7px / 8px 1px no-repeat,
        linear-gradient(
            currentColor, currentColor
        ) 4px 11px / 6px 1px no-repeat,
        linear-gradient(
            currentColor, currentColor
        ) 4px 15px / 8px 1px no-repeat,
        rgba(23, 177, 198, .10);
    opacity: 0;
    pointer-events: none;
}

/* AI sparkles */
.search-icon .search-sparkles {
    position: absolute;
    z-index: 3;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transform: scale(.65) rotate(-12deg);
}

.search-icon .search-sparkles::before {
    content: "✦";
    position: absolute;
    top: -4px;
    right: -2px;
    font-size: 17px;
    line-height: 1;
    color: #17B1C6;
    text-shadow: 0 0 8px rgba(23, 177, 198, .45);
}

.search-icon .search-sparkles::after {
    content: "✧";
    position: absolute;
    top: 3px;
    right: 12px;
    font-size: 11px;
    line-height: 1;
    color: #7B83FF;
}

/* Tiny extra sparkle */
.search-icon .search-sparkles i {
    position: absolute;
    top: 17px;
    right: -3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #7B83FF;
    box-shadow: 0 0 7px rgba(123, 131, 255, .6);
}

/* ========================================
   Animated mode
   Usage: .search-icon.animated
   ======================================== */

.search-icon.animated .search-paper,
.search-icon.ai-animated .search-paper {
    animation: search-paper 2.8s ease-in-out infinite;
}

.search-icon.animated::before,
.search-icon.animated::after {
    animation: search-float 2.8s ease-in-out infinite;
}

@keyframes search-paper {
    0%, 100% {
        opacity: 0;
        transform: translate(-4px, 3px) rotate(-13deg);
    }
    18%, 65% {
        opacity: .65;
        transform: translate(0, -1px) rotate(-5deg);
    }
    82% {
        opacity: .15;
        transform: translate(3px, -3px) rotate(3deg);
    }
}

@keyframes search-float {
    0%, 100% {
        transform: translate(0, 0);
    }
    45% {
        transform: translate(1px, -1.5px);
    }
}

/* ========================================
   AI mode
   Usage: .search-icon.ai-animated
   ======================================== */

.search-icon.ai-animated::before,
.search-icon.ai-animated::after {
    animation: search-to-ai 3.2s ease-in-out infinite;
}

.search-icon.ai-animated .search-sparkles {
    animation: ai-to-search 3.2s ease-in-out infinite;
}

@keyframes search-to-ai {
    0%, 10% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
    30%, 70% {
        opacity: 0;
        transform: scale(.45) rotate(-25deg);
    }
    90%, 100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

@keyframes ai-to-search {
    0%, 10% {
        opacity: 0;
        transform: scale(.65) rotate(-12deg);
    }
    30%, 70% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
    90%, 100% {
        opacity: 0;
        transform: scale(.65) rotate(12deg);
    }
}

/* حاشیه متحرک هوش مصنوعی — وقتی چیپ «جستجوی هوشمند AI» تیک دارد، کلاس kb-ai-border
   را JS روی فرم می‌گذارد — حاشیه SearchInput گرادیان متحرک آبی/بنفش/صورتی می‌گیرد
   (همان بنفش بج‌های «پیشنهادهای هوشمند») تا حس هوش مصنوعی منتقل شود.
   ترفند دو لایه پس‌زمینه: لایه سفید padding-box روی گرادیان border-box —
   گرادیان فقط در ناحیه حاشیه (شفاف‌شده) دیده می‌شود و radius خود input حفظ می‌شود. */
@keyframes kbAiFlow {
    0%   { background-position: 0% 50%, 0% 50%; }
    100% { background-position: 0% 50%, 200% 50%; }
}
.kb-ai-border .form--control,
.kb-ai-border .form--control:focus {
    border-width: 2px;
    border-color: transparent;
    background-image:
        linear-gradient(#fff, #fff),
        linear-gradient(90deg, #2d86eb, #7c3aed, #d946ef, #2d86eb);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    background-size: 100% 100%, 200% 100%;
    animation: kbAiFlow 2.8s linear infinite;
}

/* احترام به تنظیم «کاهش انیمیشن» مرورگر کاربر (آیکون + حاشیه AI) */
@media (prefers-reduced-motion: reduce) {
    .search-icon.animated *,
    .search-icon.animated::before,
    .search-icon.animated::after,
    .search-icon.ai-animated *,
    .search-icon.ai-animated::before,
    .search-icon.ai-animated::after {
        animation: none !important;
    }

    .search-icon.animated .search-paper {
        opacity: .35;
    }

    .search-icon.ai-animated .search-sparkles {
        opacity: 0;
    }

    .kb-ai-border .form--control,
    .kb-ai-border .form--control:focus { animation: none; }
}

/* ============================ ستون‌ها — ترتیب RTL ============================ */
/* موبایل: فید → ویجت‌ها → درخت */
.kb-col-feed    { order: 1; }
.kb-col-widgets { order: 2; }
.kb-col-tree    { order: 3; }
@media (min-width: 992px) {
    /* دسکتاپ RTL: راست ویجت‌ها، وسط فید، چپ درخت (آینه قالب اصلی) */
    .kb-col-widgets { order: 3; }
    .kb-col-feed    { order: 2; }
    .kb-col-tree    { order: 1; }
}

/* ============================ درخت انواع (سایدبار چپ) ============================ */
.kb-tree-sidebar { top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.kb-tree-search { position: relative; margin-bottom: 14px; }
.kb-tree-search i {
    position: absolute; top: 50%; transform: translateY(-50%);
    right: 12px; color: var(--kb-gray); font-size: .9rem; pointer-events: none;
}
#kbTreeSearch { padding-right: 32px; }

.kb-tree-group { margin-bottom: 10px; }
.kb-tree-toggle {
    width: 100%; display: flex; align-items: center; gap: 6px;
    background: none; border: 0; padding: 6px 14px;
    color: var(--kb-navy); cursor: pointer; text-align: right;
    font-family: inherit;
}
.kb-tree-toggle:hover { color: var(--kb-blue); }
.kb-tree-toggle > .kb-chevron { margin-right: auto; transition: transform .15s ease; color: var(--kb-gray); font-size: .8rem; }
.kb-tree-group.closed > .kb-tree-toggle .kb-chevron { transform: rotate(-90deg); }
.kb-tree-group.closed > .kb-tree-list { display: none; }
.kb-tree-list { margin-bottom: 0; }

.kb-tree-item { display: flex; align-items: center; gap: 6px; }
.kb-tree-item .kb-tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-tree-item .kb-count {
    margin-right: auto;              /* RTL: می‌چسبد به انتهای سطر */
    background: rgba(128, 137, 150, 0.12);
    color: var(--kb-gray);
    border-radius: 20px; padding: 0 8px;
    font-size: .72rem; line-height: 20px; flex: 0 0 auto;
}
.kb-tree-item.active .kb-count { background: rgba(45, 134, 235, 0.15); color: var(--kb-blue); }
.kb-tree-item.kb-hit { background: rgba(249, 184, 81, 0.15); border-radius: 6px; }

/* ============================ نوار تگ دسته‌بندی قوانین ============================ */
.kb-tag-strip { display: none; flex-wrap: wrap; gap: 8px; align-items: center; }
.kb-tag-strip.show { display: flex; }
.kb-tag-strip-label { font-size: .85rem; font-weight: 600; color: var(--kb-navy); }
.kb-tag-chip {
    border: 1px solid var(--kb-border);
    background: #fff; border-radius: 6px;
    padding: 3px 10px; font-size: .8rem; color: var(--kb-gray);
    cursor: pointer; transition: all .12s ease; font-family: inherit;
}
.kb-tag-chip span { color: rgba(128,137,150,.8); font-size: .72rem; margin-right: 4px; }
.kb-tag-chip:hover { color: var(--kb-blue); border-color: var(--kb-blue); }
.kb-tag-chip.active { background: var(--kb-blue); border-color: var(--kb-blue); color: #fff; }
.kb-tag-chip.active span { color: rgba(255,255,255,.85); }

/* ============================ فید — TreeList ============================ */
/* آیکن‌های بلوک امتیاز قالب → آیکن‌های مفهومی دانش‌نامه (با <i class="la ..."> در JS) */
.kb-feed .vote-icon, .kb-feed .answer-icon { background-image: none; }
.kb-feed .vote-icon i, .kb-feed .answer-icon i { color: #77808e; font-size: .95rem; }

.kb-feed .media--card .media-body h5 a { color: var(--kb-navy); line-height: 1.9; word-break: break-word; }
.kb-feed .media--card .media-body h5 a:hover { color: var(--kb-blue); }
.kb-feed .media--card .media-body .meta .author { color: var(--kb-blue); font-weight: 500; }

/* دکمه باز کردن زیرمجموعه */
.kb-expand {
    border: 1px solid var(--kb-border); background: rgba(128, 137, 150, 0.06);
    color: var(--kb-blue); border-radius: 6px;
    width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
    font-size: .8rem; cursor: pointer; transition: all .12s ease; flex: 0 0 26px;
}
.kb-expand:hover { background: var(--kb-blue); color: #fff; }
.kb-expand[disabled] { opacity: .5; cursor: wait; }

/* ظرف فرزندان — باز شدن تنبل بازگشتی
   (.media در بوت‌استرپ flex است؛ فرزند سوم باید تمام عرض شود) */
.kb-feed .media--card,
.kb-children .media--card-2 { flex-wrap: wrap; }
.kb-children { flex: 0 0 100%; padding: 2px 18px 0 0; margin-top: 8px; }
.kb-children .media--card { padding: 6px 10px; }
.kb-children .kb-children { padding-right: 16px; }

/* --- دکمه «+» دقیقا کنار عنوان (جدای لینک عنوان — درخواست کارفرما)
       اندازه کوچک‌تر از .kb-expand پایه تا در جریان متن h5 بنشیند و
       با margin-inline-start فاصله استاندارد با عنوان داشته باشد --- */
.kb-title-plus {
    width: 22px; height: 22px; flex: 0 0 22px;
    margin-inline-start: 8px;
    font-size: .72rem; vertical-align: middle; position: relative; top: -2px;
}
.kb-title-plus i { line-height: 1; }

/* --- خلاصه ~100 کاراکتری کمرنگ زیر عنوان (Excerpt سمت سرور ساخته می‌شود) --- */
.kb-item-excerpt {
    color: #8b97a8; font-size: .82rem; line-height: 1.9;
    margin: 2px 0 0; word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}

/* --- برچسب متنی شمارنده‌ها: «زیرمجموعه» / «اسناد مرتبط» (درخواست کارفرما) --- */
.kb-feed .votes { width: 150px; }
.kb-feed .votes .vote-counts {
    flex-grow: 0; min-width: 20px; text-align: center;
    color: var(--kb-navy); font-weight: 600;
}
.kb-vote-cap { font-size: 11px; line-height: 1.6; color: #77808e; white-space: nowrap; }

/* --- کاور لودینگ نیمه‌شفاف روی فید (درخواست کارفرما):
       محتوای قبلی کمرنگ می‌ماند، اسپینر وسط نشسته می‌شود و
       کاور کلیک‌های میانی را هم می‌بلعد --- */
#kbFeed { position: relative; }
#kbFeed.kb-is-loading { min-height: 190px; cursor: progress; }
#kbFeed.kb-is-loading > *:not(.kb-list-cover) { opacity: .35; }
.kb-list-cover {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    background: rgba(252, 253, 255, 0.5);
}
.kb-list-cover-box {
    display: flex; align-items: center; gap: 8px;
    background: #fff; border: 1px solid var(--kb-border); border-radius: 8px;
    padding: 10px 18px; color: var(--kb-gray); font-size: .85rem;
    box-shadow: 0 6px 24px rgba(13, 35, 62, 0.08);
}

@media (max-width: 575.98px) {
    .kb-feed .votes { width: 122px; }
    .kb-vote-cap { font-size: 10px; }
}

/* ============================ صفحه‌بندی ============================ */
.kb-page-dots {
    display: flex; align-items: center; padding: 0 4px;
    color: var(--kb-gray); margin-right: 3px;
}

/* ============================ ویجت‌ها ============================ */
.kb-wg-row { display: flex; align-items: center; gap: 8px; color: var(--kb-navy); }
.kb-wg-row:hover { color: var(--kb-blue); }
.kb-wg-row .kb-wg-count { margin-right: auto; color: var(--kb-gray); font-weight: 600; }
.kb-widget .icon-box span { font-family: inherit; }

/* ============================ حالت‌ها ============================ */
.kb-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px 0; color: var(--kb-gray); font-size: .88rem; }
.kb-empty { text-align: center; padding: 46px 16px; color: var(--kb-gray); }
.kb-empty i { font-size: 2.6rem; opacity: .5; }
.kb-empty p { margin: 8px 0 0; font-size: .9rem; }
.kb-alert {
    background: #fdf2f2; border: 1px solid #f2c7c7; color: #b91c1c;
    border-radius: 8px; padding: 12px 16px; font-size: .88rem; margin-bottom: 12px;
}
.kb-alert i { margin-left: 6px; }
.kb-muted-sm { color: var(--kb-gray); font-size: .85rem; }

/* ============================ دکمه بازگشت به بالا (جایگزین svg قالب) ============================ */
#back-to-top {
    display: flex; align-items: center; justify-content: center;
}
#back-to-top i { font-size: 1.2rem; }

/* ============================ ریسپانسیو ============================ */
@media (max-width: 991.98px) {
    .kb-tree-sidebar { position: static !important; max-height: 480px; }
}
@media (max-width: 767.98px) {
    .kb-mode-chips { justify-content: flex-start; }
    .kb-chip { padding: 6px 12px; font-size: .82rem; }
    #kbHeroQ { padding-left: 20px; }
    .kb-hero-form .form-btn { position: static; transform: none; margin-top: 8px; }
}

/* =========================================================
   Search-2 — صفحه جستجوی پیشرفته (KB/Search.aspx + kb-search.js)
   چیدمان دو ستونه: سایدبار فیلترها + نتایج | چک‌باکس چندانتخابی (توافق)
   ========================================================= */

/* ---- ترتیب ستون‌ها: دسکتاپ RTL = فیلترها راست (ترتیب DOM)، موبایل = نتایج اول ---- */
.kb-col-results { order: 1; }
.kb-col-filters { order: 2; }

.kb-filter-sidebar { top: 16px; max-height: calc(100vh - 32px); overflow: auto; }

/* ---- چیپ مودها روی زمینه روشن (کارت سفید — همان رفتار چیپ هیرو) ---- */
.kb-mode-chips-light { justify-content: flex-start; margin-top: 14px; }
.kb-mode-chips-light .kb-chip {
    background: #fff;
    border-color: var(--kb-border);
    color: var(--kb-navy);
}
.kb-mode-chips-light .kb-chip:hover { border-color: var(--kb-blue); }
.kb-mode-chips-light .kb-chip-box { border-color: rgba(128, 137, 150, 0.55); }
.kb-mode-chips-light .kb-chip input:checked + .kb-chip-box {
    background: var(--kb-blue); border-color: var(--kb-blue); color: #fff;
}
.kb-mode-chips-light .kb-chip:has(input:checked) {
    background: rgba(45, 134, 235, 0.06);
    border-color: var(--kb-blue);
    color: var(--kb-blue);
    font-weight: 500;
}
.kb-mode-chips-light .kb-chip:has(input:checked) .kb-chip-box { border-color: var(--kb-blue); }
.kb-mode-chips-light .kb-chip-soon:hover { border-color: var(--kb-border); }
.kb-mode-chips-light .kb-chip-badge { background: rgba(128, 137, 150, 0.15); color: var(--kb-gray); }

/* ---- جعبه جستجوی صفحه ---- */
#kbSearchQ { height: 52px; font-size: .95rem; padding-left: 50px; padding-right: 18px; }
.kb-page-search .form-btn { font-size: 20px; color: var(--kb-blue); }

/* ---- چک‌لیست فیلترها (چندانتخابی — توافق کارفرما) ---- */
.kb-check-group { margin-bottom: 12px; }
.kb-check-group:last-child { margin-bottom: 0; }
.kb-check-group-title {
    display: flex; align-items: center; gap: 6px;
    font-size: .85rem; font-weight: 600; color: var(--kb-navy);
    padding: 4px 0 2px;
}
.kb-check-row {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 2px; margin: 1px 0;
    cursor: pointer; border-radius: 6px; transition: background .12s ease;
}
.kb-check-row:hover { background: #f4f8fd; }
.kb-check-row input[type="checkbox"] {
    accent-color: var(--kb-blue);
    width: 15px; height: 15px; flex: 0 0 auto; cursor: pointer; margin: 0;
}
.kb-check-label {
    font-size: .82rem; color: #3d4753; line-height: 1.9;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-check-row:hover .kb-check-label { color: var(--kb-blue); }
.kb-check-row .kb-count {
    margin-right: auto;
    background: rgba(128, 137, 150, 0.12);
    color: var(--kb-gray);
    border-radius: 20px; padding: 0 8px;
    font-size: .72rem; line-height: 20px; flex: 0 0 auto;
}
.kb-check-row:has(input:checked) .kb-count {
    background: rgba(45, 134, 235, 0.15); color: var(--kb-blue);
}

/* ---- سربرگ نتایج ---- */
.kb-head-q { color: var(--kb-blue); }
.kb-head-filters {
    font-weight: 500; font-size: .78rem; color: var(--kb-gray);
    background: rgba(45, 134, 235, 0.07);
    border-radius: 20px; padding: 3px 10px;
}
.kb-sort-box { min-width: 155px; }
.kb-sort-box + .kb-sort-box { margin-right: 8px; }

/* ---- کاور لودینگ روی نتایج (همان الگوی فید) ---- */
.kb-search-results { position: relative; }
.kb-search-results.kb-is-loading { min-height: 190px; cursor: progress; }
.kb-search-results.kb-is-loading > *:not(.kb-list-cover) { opacity: .35; }

/* تگ والد روی کارت نتیجه — فقط نمایشی (برخلاف فید، کلیک فیلتر ندارد) */
.kb-search-results .kb-parent-tag { cursor: default; }
.kb-search-results .media--card .media-body h5 a { color: var(--kb-navy); line-height: 1.9; word-break: break-word; }
.kb-search-results .media--card .media-body h5 a:hover { color: var(--kb-blue); }
.kb-search-results .media--card .media-body .meta .author { color: var(--kb-blue); font-weight: 500; }
.kb-search-results .vote-icon i, .kb-search-results .answer-icon i { color: #77808e; font-size: .95rem; }
.kb-search-results .votes { width: 150px; }
.kb-search-results .votes .vote-counts {
    flex-grow: 0; min-width: 20px; text-align: center;
    color: var(--kb-navy); font-weight: 600;
}
.kb-search-results mark { background: #fff3bf; color: inherit; padding: 0 1px; border-radius: 3px; }

/* ---- ریسپانسیو Search-2 ---- */
@media (max-width: 767.98px) {
    .kb-page-search .form-btn { position: static; transform: none; margin-top: 8px; }
    .kb-sort-box { min-width: 0; flex: 1 1 45%; }
}
@media (max-width: 575.98px) {
    .kb-search-results .votes { width: 122px; }
}

/* =========================================================
   بسته 3 — صفحه نمایش محتوا (KB/Content.aspx + kb-content.js)
   توافق کارفرما: دو ستونه + درخت راست | رندر سمت سرور | قبلی/بعدی |
   لاگ بازدید روزانه | مرتبط از روابط | HTML پاکسازی‌شده |
   سئو کامل + JSON-LD | کپی/چاپ/تلگرام/واتساپ
   ========================================================= */

/* ---- بردکرامب ---- */
.kb-breadcrumb-area { padding-top: 24px; }
.kb-breadcrumb {
    background: #fff; border: 1px solid var(--kb-border); border-radius: 10px;
    padding: 10px 16px; font-size: .85rem; margin-bottom: 0;
}
.kb-breadcrumb li + li::before { content: "\2039"; padding: 0 6px; color: rgba(128,137,150,.6); }
.kb-breadcrumb a { color: var(--kb-gray); text-decoration: none; }
.kb-breadcrumb a:hover { color: var(--kb-blue); }
.kb-breadcrumb .active { color: var(--kb-navy); font-weight: 600; }

/* ---- ترتیب ستون‌ها: سایدبار درخت اول (راست RTL)، سپس مقاله — هماهنگ با نسخه کارفرما ---- */
.kb-col-article   { order: 2; }
.kb-col-docsidebar { order: 1; }

.kb-doc-sidebar { top: 16px; max-height: calc(100vh - 32px); overflow: auto; }

/* ---- سربرگ سند ---- */
.kb-doc-type {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(45, 134, 235, 0.08); color: var(--kb-blue);
    border-radius: 20px; padding: 4px 12px;
    font-size: .78rem; font-weight: 600; margin-bottom: 10px;
}
.kb-doc-title {
    font-size: 1.3rem; font-weight: 800; color: var(--kb-navy);
    line-height: 2; margin-bottom: 10px; word-break: break-word;
}
.kb-doc-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.kb-meta-item {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--kb-gray); font-size: .8rem;
}
.kb-meta-item i { font-size: .9rem; color: #9aa4b1; }

/* ---- نوار اشتراک‌گذاری ---- */
.kb-share-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-top: 14px; padding-top: 12px;
    border-top: 1px dashed var(--kb-border);
}
.kb-share-label { font-size: .8rem; color: var(--kb-gray); }
.kb-share-btn {
    width: 34px; height: 34px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #f4f7fb; border: 1px solid var(--kb-border);
    color: var(--kb-navy); font-size: 1rem; text-decoration: none;
    transition: all .12s ease; cursor: pointer; font-family: inherit; padding: 0;
}
.kb-share-btn:hover { background: var(--kb-blue); border-color: var(--kb-blue); color: #fff; }
#kbShareTelegram:hover { background: #229ED9; border-color: #229ED9; }
#kbShareWhatsapp:hover { background: #25D366; border-color: #25D366; }

/* ---- توست ---- */
#kbToast {
    position: fixed; bottom: 24px; right: 50%; transform: translateX(50%) translateY(20px);
    background: var(--kb-navy); color: #fff; border-radius: 8px;
    padding: 10px 20px; font-size: .85rem; z-index: 999;
    opacity: 0; pointer-events: none; transition: all .25s ease;
    box-shadow: 0 8px 24px rgba(13, 35, 62, .25);
}
#kbToast.show { opacity: 1; transform: translateX(50%) translateY(0); }

/* ---- درخت سند (سایدبار) ---- */
.kb-tree-doc-title { line-height: 1.9; }
.kb-doc-tree-tools { display: flex; gap: 8px; margin: 10px 0 4px; }
.kb-doc-tree-tools .theme-btn-xs { font-size: .75rem; padding: 3px 10px; }
.kb-doc-tree, .kb-doc-ul { list-style: none; padding-right: 0; margin: 0; }
.kb-doc-ul { padding-right: 14px; }
.kb-doc-ul.closed { display: none; }
.kb-doc-li { margin: 1px 0; }
.kb-doc-node {
    display: flex; align-items: center; gap: 4px;
    border-radius: 6px; padding: 3px 6px; transition: background .12s ease;
}
.kb-doc-node:hover { background: #f4f8fd; }
.kb-doc-node a {
    color: #3d4753; text-decoration: none; font-size: .8rem; line-height: 1.9;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: inline-block; min-width: 0; flex: 1 1 auto;
}
.kb-doc-node a:hover { color: var(--kb-blue); }
.kb-doc-node.active { background: rgba(45, 134, 235, 0.1); }
.kb-doc-node.active a { color: var(--kb-blue); font-weight: 700; }
.kb-doc-caret {
    flex: 0 0 18px; width: 18px; height: 18px; cursor: pointer;
    position: relative; transition: transform .15s ease;
}
.kb-doc-caret::before {
    content: "\203A"; font-size: .9rem; color: var(--kb-gray);
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.kb-doc-caret:hover::before { color: var(--kb-blue); }
.kb-doc-caret.open { transform: rotate(90deg); }
.kb-doc-dot {
    flex: 0 0 18px; width: 18px; display: inline-flex;
    align-items: center; justify-content: center;
}
.kb-doc-dot::before {
    content: ""; width: 5px; height: 5px; border-radius: 50%;
    background: rgba(128, 137, 150, 0.45);
}

/* ---- لیست سایدبار (مدارک مشابه) ---- */
.kb-side-list li a {
    color: #3d4753; font-size: .82rem; line-height: 2.1; text-decoration: none;
}
.kb-side-list li a:hover { color: var(--kb-blue); }

/* ---- تایپوگرافی بدنه مقاله (قانون‌محور) ---- */
.kb-article {
    font-size: .95rem; color: #2a3441; line-height: 2.15;
    word-break: break-word; overflow-wrap: break-word;
}
.kb-article p { margin: 0 0 12px; }
.kb-article h1, .kb-article h2, .kb-article h3,
.kb-article h4, .kb-article h5, .kb-article h6 {
    color: var(--kb-navy); font-weight: 700; line-height: 1.9;
    margin: 22px 0 10px;
}
.kb-article h1 { font-size: 1.2rem; }
.kb-article h2 {
    font-size: 1.1rem; padding-bottom: 8px;
    border-bottom: 2px solid rgba(45, 134, 235, 0.15);
}
.kb-article h3 { font-size: 1rem; }
.kb-article h4, .kb-article h5, .kb-article h6 { font-size: .95rem; }
.kb-article ul, .kb-article ol { padding-right: 24px; padding-left: 0; margin: 0 0 12px; }
.kb-article li { margin-bottom: 6px; }
.kb-article blockquote {
    border-right: 3px solid var(--kb-blue); background: #f7f9fc;
    padding: 10px 16px; border-radius: 0 8px 8px 0; margin: 14px 0;
    color: var(--kb-gray);
}
.kb-article table {
    width: 100%; max-width: 100%; margin: 14px 0;
    border: 1px solid var(--kb-border); border-collapse: collapse;
    font-size: .85rem;
}
.kb-article th, .kb-article td {
    border: 1px solid var(--kb-border); padding: 8px 10px;
    text-align: right; vertical-align: top;
}
.kb-article th { background: #f4f7fb; font-weight: 700; color: var(--kb-navy); }
.kb-article tr:nth-child(even) td { background: #fbfcfe; }
.kb-article pre, .kb-article code { font-family: inherit; }
.kb-article pre {
    background: #f4f7fb; border: 1px solid var(--kb-border); border-radius: 8px;
    padding: 12px 16px; white-space: pre-wrap; margin: 12px 0;
}
.kb-article mark { background: #fff3bf; color: inherit; padding: 0 1px; border-radius: 3px; }
.kb-article hr { border-color: var(--kb-border); margin: 18px 0; }
.kb-article-abs { color: var(--kb-gray); font-size: .95rem; }

/* لینک‌های خنثی‌شده (تگ a کراول حذف و متنش مانده) — قابل تشخیص اما غیرکلیک */
.kb-a-off { color: var(--kb-gray); }

/* ---- پیوست و منبع ---- */
.kb-attachment {
    display: flex; align-items: center; gap: 8px;
    background: #f4f7fb; border: 1px solid var(--kb-border); border-radius: 8px;
    padding: 10px 14px; margin-top: 16px; font-size: .85rem;
}
.kb-attachment i { color: var(--kb-blue); }
.kb-attachment a { color: var(--kb-blue); text-decoration: none; font-weight: 600; }
.kb-reference {
    background: #fdf8ee; border: 1px solid #f0e2c4; border-radius: 8px;
    padding: 10px 14px; margin-top: 12px; font-size: .85rem;
}
.kb-ref-cap { color: var(--kb-navy); }
.kb-reference a { color: var(--kb-blue); text-decoration: none; }

/* ---- قبلی/بعدی ---- */
.kb-prevnext { display: flex; gap: 12px; margin-top: 18px; }
.kb-pn {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; gap: 4px;
    background: #fff; border: 1px solid var(--kb-border); border-radius: 10px;
    padding: 12px 16px; text-decoration: none; transition: all .12s ease;
}
.kb-pn:hover { border-color: var(--kb-blue); box-shadow: 0 4px 16px rgba(45, 134, 235, .1); }
.kb-pn-next { text-align: left; }
.kb-pn-cap { font-size: .75rem; color: var(--kb-blue); font-weight: 700; }
.kb-pn-title {
    font-size: .85rem; color: var(--kb-navy); font-weight: 600; line-height: 1.9;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-pn:hover .kb-pn-title { color: var(--kb-blue); }

/* ---- اسناد مرتبط: دکمه سربرگ + پنل Off-Canvas (بازطراحی Task 27) ---- */
.kb-meta-relbtn {
    cursor: pointer; font-family: inherit; font-size: .75rem; line-height: 1.6;
    border: 1px solid var(--kb-border); border-radius: 30px; background: #f8fafc;
    color: var(--kb-blue); font-weight: 700; padding: 3px 12px; transition: all .12s ease;
}
.kb-meta-relbtn:hover { border-color: var(--kb-blue); background: rgba(45, 134, 235, .08); color: var(--kb-blue); }
.kb-meta-relbtn i { margin-left: 2px; }

.kb-oc-overlay {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(15, 23, 42, .55);
    z-index: 1049; opacity: 0; visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}
.kb-oc-overlay.is-show { opacity: 1; visibility: visible; }

.kb-offcanvas {
    position: fixed; top: 0; bottom: 0; left: 0; width: 420px; max-width: 92vw;
    background: #fff; z-index: 1050; display: flex; flex-direction: column;
    transform: translateX(-102%); transition: transform .28s ease;
    box-shadow: 0 0 40px rgba(2, 6, 23, .25);
}
.kb-offcanvas.is-open { transform: translateX(0); }
body.kb-oc-lock { overflow: hidden; }

.kb-oc-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 14px 18px; border-bottom: 1px solid var(--kb-border); background: #f8fafc;
}
.kb-oc-title { font-size: 1rem; font-weight: 700; color: var(--kb-navy); margin: 0; }
.kb-oc-count {
    display: inline-block; min-width: 26px; text-align: center;
    background: var(--kb-blue); color: #fff; border-radius: 30px;
    font-size: .72rem; padding: 1px 8px; vertical-align: 2px;
}
.kb-oc-close {
    border: 0; background: none; cursor: pointer; color: #64748b;
    font-size: 1.25rem; line-height: 1; padding: 4px; border-radius: 6px;
}
.kb-oc-close:hover { color: #ef4444; background: #f1f5f9; }

.kb-oc-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 18px 26px; -webkit-overflow-scrolling: touch; }
.kb-oc-group { margin-bottom: 20px; }
.kb-oc-group:last-child { margin-bottom: 0; }
.kb-oc-grouphd {
    font-size: .82rem; font-weight: 700; color: var(--kb-navy);
    background: #f1f5f9; border-right: 3px solid var(--kb-blue); border-radius: 6px;
    padding: 7px 12px; margin-bottom: 4px;
}
.kb-oc-gn { color: #64748b; font-weight: 400; }
.kb-oc-list { list-style: none; margin: 0; padding: 0; }
.kb-oc-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 4px; border-bottom: 1px dashed var(--kb-border);
}
.kb-oc-list li:last-child { border-bottom: 0; }
.kb-oc-list a {
    flex: 1 1 auto; min-width: 0; color: #1e293b; font-size: .82rem; line-height: 1.9;
    word-break: break-word;
}
.kb-oc-list a:hover { color: var(--kb-blue); }
.kb-oc-rel {
    flex: 0 0 auto; font-size: .68rem; color: var(--kb-blue); background: rgba(45, 134, 235, .08);
    border-radius: 30px; padding: 2px 9px; white-space: nowrap;
}

/* ---- لیست زیرمجموعه‌ها در بدنه محتوا (اصلاح Task 28) ----
   وقتی سند متن و چکیده ندارد ولی فصل/ماده دارد، به‌جای صفحهٔ خالی
   کارت‌های لینک‌دار زیرمجموعه‌ها رندر می‌شود */
.kb-childlist { margin-top: 6px; }
.kb-childlist-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin: 4px 0 14px; padding-bottom: 10px; border-bottom: 2px solid #eef2f7;
}
.kb-childlist .kb-childlist-title {
    display: inline-flex; align-items: center; gap: 6px;
    margin: 0; padding: 0; border: 0;
    font-size: 1.02rem; font-weight: 800; color: var(--kb-navy); line-height: 1.8;
}
.kb-childlist .kb-childlist-title i { color: var(--kb-blue); font-size: 1rem; }
.kb-childlist-count {
    flex: 0 0 auto; background: rgba(45, 134, 235, .08); color: var(--kb-blue);
    border-radius: 30px; padding: 2px 12px; font-size: .74rem; font-weight: 700;
}
.kb-childlist .kb-childlist-ul {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px;
}
.kb-childlist .kb-childlist-ul li { margin: 0; }
.kb-childlist .kb-childlink {
    display: flex; align-items: center; gap: 10px; height: 100%;
    background: #fff; border: 1px solid var(--kb-border); border-radius: 10px;
    padding: 10px 12px; text-decoration: none; transition: all .12s ease;
}
.kb-childlist .kb-childlink:hover {
    border-color: var(--kb-blue); background: #f8fbff;
    box-shadow: 0 4px 16px rgba(45, 134, 235, .1);
}
.kb-childlist .kb-child-num {
    flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(45, 134, 235, .1); color: var(--kb-blue);
    font-size: .76rem; font-weight: 800;
}
.kb-childlist .kb-child-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.kb-childlist .kb-child-title {
    color: var(--kb-navy); font-size: .84rem; font-weight: 600;
    line-height: 1.9; word-break: break-word;
}
.kb-childlist .kb-childlink:hover .kb-child-title { color: var(--kb-blue); }
.kb-childlist .kb-child-type { color: #98a2b3; font-size: .7rem; }
.kb-childlist .kb-child-sub { flex: 0 0 auto; color: var(--kb-blue); font-size: .82rem; opacity: .75; }
.kb-childlist .kb-child-sub-leaf { color: #cbd5e1; }
.kb-childlist .kb-child-go { flex: 0 0 auto; color: #b6c2d4; font-size: .8rem; transition: transform .12s ease; }
.kb-childlist .kb-childlink:hover .kb-child-go { transform: translateX(-3px); color: var(--kb-blue); }

/* ---- ریسپانسیو بسته 3 ---- */
@media (max-width: 991.98px) {
    .kb-doc-sidebar { position: static !important; max-height: 480px; }
}
@media (max-width: 575.98px) {
    .kb-doc-title { font-size: 1.1rem; }
    .kb-doc-meta { gap: 4px 12px; }
    .kb-prevnext { flex-direction: column; }
    .kb-pn-next { text-align: right; }
    .kb-offcanvas { width: 100vw; max-width: 100vw; }
}

/* ---- چاپ: فقط سربرگ مقاله و بدنه چاپ می‌شود ---- */
@media print {
    .header-area, .footer-area, #preloader, #back-to-top,
    .kb-breadcrumb-area, .kb-col-docsidebar, .kb-share-bar,
    .kb-prevnext, .kb-meta-relbtn, .kb-offcanvas, .kb-oc-overlay, #kbToast { display: none !important; }
    .kb-col-article { width: 100% !important; max-width: 100% !important; flex: 0 0 100% !important; }
    body.kb-body { background: #fff; }
    .card, .card-item { box-shadow: none !important; border: 0 !important; }
    .kb-article-card .card-body { padding: 0 !important; }
    .kb-article { font-size: 11pt; color: #000; }
    .kb-article h2 { border-color: #ccc; }
    a[href]::after { content: ""; } /* لینک‌ها آدرس پشتشان چاپ نشود */
}
