/* ========================================================================= */
/* پایه‌ی مشترک ظاهر دکتر آپشن: فونت، جدول رنگ و چند قاعده‌ی عمومی            */
/* همه‌ی صفحه‌هایی که از base.html ارث می‌برند این فایل را بار می‌کنند.        */
/* ========================================================================= */

/* فونت متن: وزیرمتن (همراه خود سایت). size-adjust اندازه‌ی ظاهری را نزدیک فونت قبلی
   نگه می‌دارد تا چیدمان صفحه‌های فعلی به هم نریزد. */
@font-face {
    font-family: 'DrText';
    src: url('/static/fonts/Vazirmatn-wght.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
    size-adjust: 86%;
}
/* نام فونت قبلی در کدها و نمودارهای فعلی زیاد به کار رفته؛ به همان فونت جدید وصل می‌شود. */
@font-face {
    font-family: 'B Nazanin';
    src: url('/static/fonts/Vazirmatn-wght.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
    size-adjust: 86%;
}
/* فونت عدد: هم‌عرض، برای جدول‌ها و مقدارها */
@font-face {
    font-family: 'DrNum';
    src: url('/static/fonts/JetBrainsMono-400.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'DrNum';
    src: url('/static/fonts/JetBrainsMono-500.woff2') format('woff2');
    font-weight: 500 700;
    font-display: swap;
}

/* ==================== جدول رنگ: تم شب ==================== */
:root {
    color-scheme: dark;
    --font-text: 'DrText', Tahoma, 'Segoe UI', Arial, sans-serif;
    --font-num: 'DrNum', 'Cascadia Mono', Consolas, monospace;
    /* برای خانه‌های جدول: عدد و حروف لاتین هم‌عرض، نوشته‌ی فارسی با فونت متن */
    --font-data: 'DrNum', 'DrText', Tahoma, sans-serif;
    --radius: 6px;

    --bg-main: #0b0e13;
    --bg-card: #10141b;
    --bg-raised: #161b24;
    --border-color: #252d3a;
    --border-strong: #364152;
    --text-strong: #ffffff;
    --text-light: #dfe3e9;
    --text-muted: #8d97a5;

    /* یک رنگ تأکید؛ دو نام قدیمی هر دو به همان وصل‌اند */
    --accent-blue: #7db4ff;
    --accent-cyan: #7db4ff;
    --on-accent: #06101f;

    /* رنگ‌های معنایی */
    --c-green: #4cc38a;
    --c-green-bright: #4cc38a;
    --c-red: #f0736a;
    --c-red-bright: #f0736a;
    --c-amber: #d9a441;
    --c-yellow: #d9a441;
    --c-orange: #d9a441;
    --c-purple: #b9a2f5;
}

/* ==================== جدول رنگ: تم روز ==================== */
:root:has(body.light-mode) { color-scheme: light; }
body.light-mode {
    --bg-main: #f6f7f9;
    --bg-card: #ffffff;
    --bg-raised: #eef1f5;
    --border-color: #dde2ea;
    --border-strong: #b9c2cf;
    --text-strong: #12171f;
    --text-light: #1c232d;
    --text-muted: #5b6675;

    --accent-blue: #0b5cad;
    --accent-cyan: #0b5cad;
    --on-accent: #ffffff;

    --c-green: #177a4c;
    --c-green-bright: #177a4c;
    --c-red: #c0352b;
    --c-red-bright: #c0352b;
    --c-amber: #8a5a00;
    --c-yellow: #8a5a00;
    --c-orange: #8a5a00;
    --c-purple: #6f4bd8;
}

/* ==================== قاعده‌های عمومی ==================== */
/* نوار پیمایش هم‌رنگ تم (به‌جای نوار سفید پیش‌فرض) */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ستون‌های عددی زیر هم بایستند */
table { font-variant-numeric: tabular-nums; }

/* عدد با فونت هم‌عرض */
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* نوشته‌ی روی دکمه‌هایی که با رنگ تأکید پر شده‌اند (تا بازطراحی صفحه‌به‌صفحه) */
button[style*="background: var(--accent-blue)"] { color: var(--on-accent) !important; }

/* آیکون خطی مشترک */
.ui-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.copy-sym-btn { display: inline-flex; align-items: center; justify-content: center; }
.copy-sym-btn .ui-icon { width: 14px; height: 14px; }

/* ==================== اجزای مشترک صفحه‌ها ==================== */
/* سربرگ صفحه: عنوان در یک طرف، وضعیت در طرف دیگر */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2, .page-head h1 { font-size: 23px; font-weight: 700; color: var(--text-strong); margin: 0; }
.page-head .page-sub { font-size: 15px; color: var(--text-muted); margin-top: 2px; }
.page-status { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); display: inline-block; flex: none; transition: background-color 0.3s; }

/* دکمه‌ها: ساده، پررنگ (فقط یکی در هر صفحه)، آرام، خطر */
.ui-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: transparent; color: var(--text-light); font-family: inherit; font-size: 16px; font-weight: 500;
    white-space: nowrap; cursor: pointer; text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.ui-btn:hover { background: var(--bg-raised); }
.ui-btn:focus-visible, .ui-input:focus-visible, .ui-seg button:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.ui-btn .ui-icon { width: 17px; height: 17px; }
.ui-btn.primary { background: var(--accent-blue); border-color: var(--accent-blue); color: var(--on-accent); }
.ui-btn.primary:hover { filter: brightness(1.08); }
.ui-btn.quiet { border-color: transparent; color: var(--text-muted); }
.ui-btn.quiet:hover { color: var(--text-light); }
.ui-btn.danger { color: var(--c-red); border-color: var(--c-red); }
.ui-btn.active { border-color: var(--accent-blue); color: var(--accent-blue); }
.ui-btn.sm { height: 30px; padding: 0 10px; font-size: 15px; }
.ui-btn.icon-only { width: 36px; padding: 0; }
.ui-btn.icon-only.sm { width: 30px; }

/* کادر ورودی و فهرست انتخاب */
.ui-input {
    height: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--bg-main); color: var(--text-light); font-family: inherit; font-size: 16px; outline: none;
}
.ui-input:focus { border-color: var(--accent-blue); }
.ui-input::placeholder { color: var(--text-muted); }
select.ui-input { cursor: pointer; padding: 0 8px; }

/* انتخاب چندحالته */
.ui-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.ui-seg button { height: 34px; padding: 0 14px; border: 0; background: transparent; color: var(--text-muted); font-family: inherit; font-size: 16px; cursor: pointer; white-space: nowrap; }
.ui-seg button + button { border-right: 1px solid var(--border-strong); }
.ui-seg button:hover { color: var(--text-light); }
.ui-seg button.active { background: var(--bg-raised); color: var(--text-strong); font-weight: 500; }

/* تیک‌زدنی */
.ui-check { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text-light); cursor: pointer; user-select: none; }
.ui-check input { accent-color: var(--accent-blue); width: 15px; height: 15px; }

/* جعبه‌ی محتوا */
.ui-panel { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); }

/* نشان فاصله تا سقف موقعیت باز (سبز: فاصله دارد، قرمز: نزدیک سقف) */
.cap-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c-green); margin: 0 4px; cursor: help; vertical-align: middle; }
.cap-dot.near { background: var(--c-red); }

/* ==================== زنگ هشدار فیلتر در نوار بالا ==================== */
.alert-bell { position: relative; }
.alert-bell[hidden], .alert-badge[hidden], .alert-panel[hidden] { display: none; }
.alert-bell .icon-btn { position: relative; }
.alert-bell .icon-btn.muted { opacity: 0.5; }
.alert-badge {
    position: absolute; top: -6px; left: -6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: var(--c-red); color: var(--bg-card); font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.alert-panel {
    position: absolute; top: 44px; left: 0; width: 340px; max-height: min(560px, calc(100vh - 80px)); overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: var(--radius);
    padding: 14px; display: flex; flex-direction: column; gap: 10px; z-index: 1200;
    font-size: 15px; color: var(--text-light); cursor: default;
}
.alert-panel > * { flex: none; }
.alert-panel-head { display: flex; align-items: center; gap: 14px; }
.alert-panel-head b { margin-left: auto; font-size: 16px; color: var(--text-strong); }
.alert-panel-head .ui-check { font-size: 14px; gap: 6px; }
.alert-panel-title { font-size: 13px; color: var(--text-muted); border-top: 1px solid var(--border-color); padding-top: 10px; }
.alert-panel-note { font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.alert-panel-list { display: flex; flex-direction: column; gap: 6px; }
.alert-item, .alert-watch a { display: flex; flex-direction: column; gap: 2px; color: var(--text-light); text-decoration: none; min-width: 0; }
.alert-item { padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius); }
.alert-item:hover { background: var(--bg-raised); }
.alert-item.unread { border-color: var(--accent-blue); }
.alert-item-top { display: flex; justify-content: space-between; gap: 10px; }
.alert-item-top .num, .alert-item-sub { font-size: 13px; color: var(--text-muted); }
.alert-item-symbols { font-size: 13px; line-height: 1.7; }
.alert-watch { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.alert-watch a { flex: 1; }
.alert-watch a:hover b { color: var(--accent-blue); }
