/* ============================================================
   Monica AI — Theme v2 «Professional Cool»
   نئوترال‌های سرد (Slate) + آبی حرفه‌ای + فیروزه‌ای
   توکن‌محور (Design Tokens) · تم روشن · فونت وزیر
   ============================================================ */

@font-face { font-family: 'Vazirmatn'; src: url('/fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/fonts/Vazirmatn-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;

  /* Neutrals — cool slate scale */
  --paper: #f6f8fb;
  --card: #ffffff;
  --chip: #f1f5f9;
  --soft: #eef2f7;
  --rule: #e2e8f0;
  --ink: #0f172a;
  --ink2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  /* Brand — هویت بصری جهاد: آبی سرمه‌ای + فیروزه‌ای + زرد */
  --accent: #00427a;
  --accent-dark: #00335e;
  --accent-2: #009892;
  --grad: linear-gradient(135deg, #00427a 0%, #009892 100%);
  --accent-3: #ffce05;
  --accent-3-ink: #6b5200;
  --accent-soft: #e7f0f7;
  --accent-ink: #004e7c;
  --accent-line: #cfe2ee;
  --soft2: #f8fafc;
  --field-bg: #ffffff;
  --code-bg: #f8fafc;
  --code-inline-bg: #eef2f7;

  /* Semantic */
  --ok-bg: #ecfdf5; --ok-ink: #047857; --ok-border: #a7f3d0;
  --err-bg: #fef2f2; --err-ink: #b91c1c; --err-border: #fecaca;
  --warn-bg: #fff9db; --warn-ink: #6b5200;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, .09);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .14);

  /* Dark sidebar (admin) */
  --side-bg: #0b1220;
  --side-bg-2: #0f172a;
  --side-ink: #cbd5e1;
  --side-muted: #64748b;

  --radius: 8px;
  --mono: Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.5; margin: 0; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-dark); text-decoration: none; }
.mono { font-family: var(--mono); direction: ltr; unicode-bidi: embed; font-size: 12.5px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; }
.inline { display: inline; }

/* ---------- Brand mark ---------- */
.brand, .side-brand, .chat-brand, .auth-brand { font-weight: 700; }
.brand span, .side-brand span, .chat-brand span, .auth-brand span {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Public site ---------- */
.site-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 32px; border-bottom: 1px solid var(--rule);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 20px; color: var(--ink); }
.site-nav a { color: var(--ink2); margin-inline-start: 20px; font-size: 14px; }
.site-nav a:hover { color: var(--accent-dark); }
.site-main { max-width: 960px; margin: 0 auto; padding: 48px 24px; }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 28px; border-top: 1px solid var(--rule); }
.hero .kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; color: var(--accent); text-transform: uppercase; }
.hero h1 { font-size: 34px; margin: 12px 0 14px; font-weight: 700; }
.hero p { color: var(--ink2); max-width: 62ch; }
.checks { list-style: none; padding: 0; margin-top: 28px; border-top: 1px solid var(--rule); max-width: 660px; }
.checks li { padding: 11px 2px; border-bottom: 1px solid var(--rule); color: var(--ink2); }

/* ---------- Admin shell ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: linear-gradient(180deg, var(--side-bg-2) 0%, var(--side-bg) 100%);
  border-inline-end: 1px solid #1e293b;
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { font-size: 18px; padding: 6px 12px 16px; color: #f8fafc; }
.side-brand .side-phase {
  font-size: 10.5px; color: var(--side-muted); border: 1px solid #334155; border-radius: 6px;
  padding: 1px 8px; margin-inline-start: 8px; vertical-align: 2px; font-weight: 400;
}
.side nav { display: flex; flex-direction: column; gap: 3px; }
.side nav a { display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--side-ink); font-size: 14.5px; transition: background .15s, color .15s; }
.side nav a:hover { background: rgba(148, 163, 184, .12); color: #fff; }
.side nav a.on { background: rgba(0, 152, 146, .28); color: #fff; font-weight: 600; }
.side nav a.dis { color: #475569; opacity: .7; pointer-events: none; }
.side-foot { margin-top: auto; font-size: 12.5px; color: var(--side-muted); padding: 12px; }
.side-foot a { color: #93c5fd; }
.side-foot a:hover { color: #bfdbfe; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 28px; border-bottom: 1px solid var(--rule); background: var(--card);
  box-shadow: var(--shadow-sm);
}
.topbar .crumb { font-size: 13px; color: var(--muted); }
.topbar .crumb span { color: var(--ink2); }
.page { padding: 28px 32px 70px; max-width: 1200px; width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 25px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.actions { display: flex; gap: 8px; align-items: center; }
.sec-title { font-size: 18px; margin: 32px 0 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink2);
  padding: 8px 14px; border-radius: var(--radius); font-size: 14px; font-family: inherit;
  cursor: pointer; line-height: 1.7; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, filter .15s;
}
.btn:hover { border-color: var(--faint); color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 2px 10px rgba(0, 66, 122, .30); }
.btn.primary:hover { filter: brightness(1.07); color: #fff; }
.btn.danger { color: var(--err-ink); border-color: var(--err-border); }
.btn.danger:hover { border-color: var(--err-ink); color: var(--err-ink); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }

/* ---------- Tables ---------- */
.tablewrap { border: 1px solid var(--rule); border-radius: 12px; overflow: auto; background: var(--card); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; min-width: 620px; }
table.data th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: right; padding: 11px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--soft2); }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--soft); font-size: 13.8px; color: var(--ink2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td, table.data tr:hover td { background: var(--soft2); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 6px; border: 1px solid var(--rule); color: var(--muted); background: var(--chip); white-space: nowrap; }
.badge.ok { color: var(--ok-ink); background: var(--ok-bg); border-color: var(--ok-border); }
.badge.off { color: var(--muted); background: var(--chip); }
.badge.vendor { color: var(--accent-dark); background: var(--accent-soft); border-color: var(--accent-line); }

/* ---------- Forms ---------- */
.form-card { border: 1px solid var(--rule); border-radius: 12px; background: var(--card); padding: 22px 24px; max-width: 820px; margin: 0 0 24px; box-shadow: var(--shadow-sm); }
.card-title { font-size: 15.5px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13.5px; color: var(--ink2); font-weight: 600; }
.field input[type=text], .field input[type=password], .field input[type=number], .field select, .field textarea {
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--field-bg); padding: 8px 12px;
  font-size: 14px; font-family: inherit; color: var(--ink); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 66, 122, .18);
}
.field input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink2); font-weight: 400; }
.field-validation-error { color: var(--err-ink); font-size: 12.5px; }
.input-validation-error { border-color: #f87171 !important; }
.validation-summary-valid { display: none; }

/* ---------- Alerts ---------- */
.alert { border: 1px solid var(--rule); border-radius: 10px; padding: 10px 15px; font-size: 13.5px; margin-bottom: 18px; }
.alert.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-ink); }
.alert.err { background: var(--err-bg); border-color: var(--err-border); color: var(--err-ink); }
.alert ul { margin: 4px 0 0; padding-inline-start: 18px; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { border: 1px solid var(--rule); border-radius: 12px; background: var(--card); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
ul.clean { list-style: none; padding: 0; margin: 8px 0 0; }
ul.clean li { padding: 7px 0; border-bottom: 1px dashed var(--soft); color: var(--ink2); font-size: 14px; }
ul.clean li:last-child { border-bottom: none; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Chart ---------- */
.chart-card { border: 1px solid var(--rule); border-radius: 12px; background: var(--card); padding: 18px 20px 12px; box-shadow: var(--shadow-sm); margin-bottom: 8px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { width: 100%; max-width: 30px; border-radius: 4px 4px 2px 2px; background: var(--grad); min-height: 2px; }
.chart-bar.zero { background: var(--rule); }
.chart-col:hover .chart-bar { filter: brightness(1.15); }
.chart-labels { display: flex; gap: 4px; margin-top: 6px; }
.chart-label { flex: 1; text-align: center; font-size: 10px; color: var(--muted); direction: ltr; white-space: nowrap; }

/* ============================================================
   Dark theme — «Professional Cool · Night»
   فقط با data-theme="dark" روی <html> فعال می‌شود (theme.js)
   ============================================================ */
:root[data-theme="dark"] {
  color-scheme: dark;

  --paper: #0b1220;
  --card: #111c30;
  --chip: #1b2740;
  --soft: #1a2740;
  --soft2: #0e1729;
  --rule: #24324d;
  --ink: #e6edf7;
  --ink2: #c3cfdf;
  --muted: #8ea1b9;
  --faint: #64748b;

  --accent: #4ea8de;
  --accent-dark: #7cc0e8;
  --accent-2: #2fc7bb;
  --grad: linear-gradient(135deg, #3d7fb0 0%, #2fb3a8 100%);
  --accent-soft: #12293a;
  --accent-ink: #8fc9e8;
  --accent-line: #1d3a4c;

  --field-bg: #0e1729;
  --code-bg: #0e1729;
  --code-inline-bg: #1b2740;

  --ok-bg: #07271f; --ok-ink: #6ee7b7; --ok-border: #14532d;
  --err-bg: #2b1416; --err-ink: #fca5a5; --err-border: #7f1d1d;
  --warn-bg: #2a2210; --warn-ink: #fcd34d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);

  --side-bg: #050b16;
  --side-bg-2: #0a1120;
}

:root[data-theme="dark"] .site-topbar { background: rgba(11, 18, 32, .85); }
:root[data-theme="dark"] .brand { color: var(--ink); }
:root[data-theme="dark"] .side { border-inline-end-color: #1b2740; }
:root[data-theme="dark"] .composer textarea:focus { box-shadow: 0 0 0 3px rgba(78, 168, 222, .30); }
:root[data-theme="dark"] .field input:focus, :root[data-theme="dark"] .field select:focus, :root[data-theme="dark"] .field textarea:focus { box-shadow: 0 0 0 3px rgba(78, 168, 222, .30); }

/* ============================================================
   Craft pass — روح و حرکت (hover / انیمیشن / اسکرول‌بار)
   ============================================================ */
.btn { transition: transform .15s, box-shadow .15s, background .15s, border-color .15s, color .15s, filter .15s; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.stat, .feat, .chart-card { transition: transform .18s, box-shadow .18s, border-color .18s; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
::selection { background: var(--accent-soft); color: var(--accent-ink); }
* { scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
.msg { animation: msgIn .22s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Landing — صفحهٔ اصلی
   ============================================================ */
.hero-landing { padding: 18px 0 6px; }
.hero-badge { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--rule); background: var(--card); color: var(--ink2); border-radius: 999px; padding: 5px 13px; font-size: 12.5px; box-shadow: var(--shadow-sm); }
.hero-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grad); display: inline-block; box-shadow: 0 0 0 3px var(--accent-soft); }
.hero-landing h1 { font-size: 40px; margin: 18px 0 14px; font-weight: 800; }
.hero-landing h1 .g { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-landing .lead { color: var(--ink2); max-width: 64ch; font-size: 15.5px; }
.cta-row { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.btn.lg { padding: 11px 22px; font-size: 15px; border-radius: 10px; }
.feat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 40px; }
.feat { border: 1px solid var(--rule); background: var(--card); border-radius: 14px; padding: 20px 20px 18px; box-shadow: var(--shadow-sm); }
.feat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent-line); }
.feat .ic { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 19px; background: var(--accent-soft); border: 1px solid var(--accent-line); margin-bottom: 12px; }
.feat h3 { font-size: 16px; margin-bottom: 6px; }
.feat p { color: var(--muted); font-size: 13.5px; margin: 0; line-height: 1.9; }
.landing-strip { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px; }

/* ============================================================
   Chat — درخت پروژه‌ها/گفتگوها + چیپ‌های شروع
   ============================================================ */
.conv-group { margin-bottom: 2px; }
.group-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--ink2); font-size: 13px; font-weight: 600; user-select: none; }
.group-head:hover { background: var(--chip); }
.group-head .chev { font-size: 10px; color: var(--muted); transition: transform .18s; display: inline-block; }
.group-head.closed .chev { transform: rotate(-90deg); }
.group-head .gname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-head .gcount { font-size: 10.5px; color: var(--muted); background: var(--chip); border: 1px solid var(--rule); border-radius: 10px; padding: 0 7px; font-weight: 400; }
.group-head .gacts { display: none; gap: 2px; }
.group-head:hover .gacts { display: inline-flex; }
.group-body { display: flex; flex-direction: column; gap: 1px; padding-inline-start: 14px; }
.group-empty { font-size: 12px; color: var(--faint); padding: 3px 10px; }
.empty-hello { font-size: 26px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty-sub { color: var(--muted); font-size: 14.5px; margin-bottom: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; margin: 0 auto; }
.chip { border: 1px solid var(--rule); background: var(--card); color: var(--ink2); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-family: inherit; cursor: pointer; transition: transform .15s, border-color .15s, color .15s, box-shadow .15s; box-shadow: var(--shadow-sm); }
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ---------- API helpers — دکمهٔ کپی روی بلوک کد ---------- */
.copy-btn { position: absolute; top: 8px; left: 8px; z-index: 2; border: 1px solid rgba(148, 163, 184, .35); background: rgba(148, 163, 184, .14); color: #cbd5e1; border-radius: 6px; padding: 2px 10px; font-size: 11px; font-family: 'Vazirmatn', Tahoma, sans-serif; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.copy-btn:hover { background: rgba(148, 163, 184, .26); color: #f1f5f9; }
.copy-btn.copied { background: rgba(16, 185, 129, .25); color: #6ee7b7; border-color: rgba(16, 185, 129, .45); }
@media (max-width: 900px) { .feat-grid { grid-template-columns: 1fr; } .hero-landing h1 { font-size: 30px; } }

/* هویت جهاد — نوار سه‌رنگ بالای پوسته‌ها */
.site-topbar, .topbar { border-bottom: 3px solid transparent !important; border-image: linear-gradient(90deg, #00427a, #009892, #ffce05) 1; }
