/* Nik Pouyeh — Admin console */
:root {
  --navy-950: #061433; --navy-900: #0a1f4d; --navy-800: #0b2a6f; --navy-700: #12398f; --navy-600: #1d4fb8; --navy-100: #e6ecf8; --navy-50: #f3f6fc;
  --gold-600: #b8861f; --gold-500: #d4a537; --gold-400: #e5bf5c; --gold-100: #faf1db;
  --ink-900: #0f172a; --ink-700: #334155; --ink-500: #64748b; --ink-300: #cbd5e1; --ink-200: #e2e8f0; --ink-100: #f1f5f9;
  --bg: #f5f7fb; --white: #fff;
  --gold-gradient: linear-gradient(135deg, #f3d488 0%, #d4a537 45%, #a8741a 100%);
  --radius: 14px; --shadow: 0 1px 2px rgba(10,31,77,.05), 0 8px 24px -12px rgba(10,31,77,.18);
  --font: "Plus Jakarta Sans", "Vazirmatn", system-ui, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; font-family: var(--font); color: var(--ink-900); background: var(--bg); font-size: 15px; -webkit-font-smoothing: antialiased; }
h1, h2 { margin: 0; color: var(--navy-900); letter-spacing: -.02em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.02rem; }
a { color: var(--navy-700); text-decoration: none; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: var(--navy-50); color: var(--navy-800); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--ink-500); margin: 4px 0 0; }
.tiny { font-size: .78rem; color: var(--ink-500); margin: 8px 0 12px; }
.fa { font-family: "Vazirmatn", sans-serif; direction: rtl; }
.material-symbols-outlined { font-size: 20px; vertical-align: middle; line-height: 1; }
.mt { margin-top: 10px; }
.right { text-align: right; }
.narrow { max-width: 520px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: linear-gradient(180deg, var(--navy-900), var(--navy-950)); color: #b6c3de; padding: 20px 14px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 8px 10px 22px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.sidebar-brand img { width: 52px; background: var(--white); border-radius: 12px; padding: 4px; }
.sidebar-brand strong { display: block; color: var(--white); font-size: 1rem; }
.sidebar-brand small { color: var(--gold-400); font-weight: 600; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.side-nav { display: grid; gap: 4px; flex: 1; align-content: start; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: #b6c3de; font-weight: 600; transition: background .15s, color .15s; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: var(--white); }
.side-nav a.active { background: rgba(212,165,55,.14); color: var(--white); box-shadow: inset 3px 0 0 var(--gold-500); }
.side-nav a.active .material-symbols-outlined { color: var(--gold-400); }
.sidebar-foot { display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-gradient); color: var(--navy-950); font-weight: 800; font-size: .85rem; flex: none; }
.who { flex: 1; min-width: 0; }
.who strong { display: block; color: var(--white); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: #8ea0c6; font-size: .75rem; }
.sidebar .icon-btn { color: #b6c3de; }
.sidebar .icon-btn:hover { background: rgba(255,255,255,.08); color: var(--white); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 28px; background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--ink-200); }
.topbar-title { flex: 1; color: var(--gold-600); font-weight: 600; }
.topbar-title:lang(en) { font-family: "Vazirmatn", sans-serif; }
.menu-btn { display: none; }
.content { padding: 28px; max-width: 1400px; width: 100%; }
.scrim { display: none; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 700; font-size: .88rem; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy-800); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }
.btn-ghost { background: var(--white); border-color: var(--ink-200); color: var(--navy-800); }
.btn-ghost:hover:not(:disabled) { border-color: var(--navy-600); }
.btn-block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: .8rem; }
.icon-btn { background: none; border: 0; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--ink-500); }
.icon-btn:hover { background: var(--ink-100); color: var(--navy-800); }
.input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--ink-200); border-radius: 10px; font: inherit; font-size: .9rem; background: var(--white); color: var(--ink-900); }
.input:focus { outline: 0; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(29,79,184,.12); }
textarea.input { resize: vertical; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; font-size: .82rem; color: var(--ink-700); margin-bottom: 6px; }
.validation-message { color: #c5221f; font-size: .78rem; margin-top: 4px; }
.input.invalid { border-color: #c5221f; }
.input-icon { position: relative; }
.input-icon .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-icon .lead { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-500); }
.input.with-lead { padding-left: 40px; }
.row-2 { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }

/* ---------- Page structure ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.head-tags { display: flex; gap: 8px; margin-bottom: 10px; }
.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .88rem; margin-bottom: 14px; }
.panel { background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.grid-main { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.grid-detail { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { display: flex; align-items: center; gap: 14px; background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.kpi small { color: var(--ink-500); font-weight: 600; font-size: .8rem; }
.kpi strong { display: block; font-size: 1.7rem; color: var(--navy-900); letter-spacing: -.02em; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--navy-50); color: var(--navy-700); }
.kpi-icon.gold { background: var(--gold-100); color: var(--gold-600); }

/* ---------- Chart ---------- */
.legend { font-size: .8rem; color: var(--ink-500); display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.sw.import, .bar.import { background: var(--navy-700); }
.sw.export, .bar.export { background: var(--gold-500); }
.chart { display: grid; grid-template-columns: repeat(14, 1fr); gap: 8px; height: 220px; align-items: end; }
.chart-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart-stack { flex: 1; width: 100%; max-width: 28px; display: flex; flex-direction: column; justify-content: flex-end; background: var(--ink-100); border-radius: 6px; overflow: hidden; }
.bar { width: 100%; transition: height .4s ease; }
.chart-col small { font-size: .72rem; color: var(--ink-500); }
.status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.status-list li { display: grid; grid-template-columns: 110px 1fr 36px; gap: 10px; align-items: center; }
.status-list strong { text-align: right; }
.meter { height: 8px; border-radius: 6px; background: var(--ink-100); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--gold-gradient); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.split div { background: var(--navy-50); border-radius: 10px; padding: 12px; }
.split small { color: var(--ink-500); font-weight: 600; }
.split strong { display: block; font-size: 1.3rem; color: var(--navy-900); }

/* ---------- Tables ---------- */
.filters { display: grid; grid-template-columns: 1fr 160px 180px; gap: 10px; margin-bottom: 16px; }
.table-meta { font-size: .82rem; color: var(--ink-500); margin-bottom: 8px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); padding: 10px 12px; border-bottom: 1px solid var(--ink-200); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--ink-100); vertical-align: top; }
.table td small { display: block; color: var(--ink-500); font-size: .78rem; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--navy-50); }
.ellipsis { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; font-size: .85rem; color: var(--ink-500); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; background: var(--navy-50); color: var(--navy-800); }
.badge-submitted { background: #eef2ff; color: #3730a3; }
.badge-underreview { background: var(--navy-50); color: var(--navy-700); }
.badge-quoted { background: var(--gold-100); color: #7a560c; }
.badge-approved { background: #e0f2fe; color: #075985; }
.badge-inprogress { background: #f3e8ff; color: #6b21a8; }
.badge-completed { background: #e7f6ee; color: #0b5d34; }
.badge-rejected, .badge-cancelled { background: #fdecea; color: #8a1c13; }
.dir { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: .8rem; }
.dir .material-symbols-outlined { font-size: 16px; }
.dir-import { color: var(--navy-700); }
.dir-export { color: var(--gold-600); }

/* ---------- Detail ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--ink-500); font-weight: 600; }
.dl dd { margin: 0; }
.pre { white-space: pre-wrap; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--ink-200); display: grid; gap: 16px; }
.timeline li { position: relative; padding-left: 14px; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--white); border: 3px solid var(--navy-700); }
.timeline li:first-child::before { border-color: var(--gold-500); }
.timeline small { display: block; color: var(--ink-500); margin-top: 4px; font-size: .78rem; }
.timeline p { margin: 6px 0 0; font-size: .85rem; color: var(--ink-700); }

/* ---------- Transcript ---------- */
.transcript { display: flex; flex-direction: column; gap: 12px; background: var(--navy-50); }
.bubble { max-width: 75%; padding: 12px 14px; border-radius: 14px; }
.bubble.user { align-self: flex-end; background: var(--navy-800); color: var(--white); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--white); border: 1px solid var(--ink-200); border-bottom-left-radius: 4px; }
.bubble-meta { font-size: .72rem; opacity: .7; margin-bottom: 4px; }
.bubble-text { white-space: pre-wrap; line-height: 1.55; }

/* ---------- Alerts / states ---------- */
.alert { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .88rem; }
.alert-error { background: #fdecea; color: #8a1c13; }
.alert-success { background: #e7f6ee; color: #0b5d34; }
.alert-info { background: var(--navy-50); color: var(--navy-800); }
.empty { text-align: center; color: var(--ink-500); padding: 40px 10px; }
.empty .material-symbols-outlined { font-size: 40px; color: var(--ink-300); }
.loading { display: grid; place-items: center; padding: 40px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ink-200); border-top-color: var(--gold-500); animation: spin .8s linear infinite; display: inline-block; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255,255,255,.3); border-top-color: var(--white); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.skeleton-grid div { height: 86px; border-radius: var(--radius); background: linear-gradient(90deg, var(--ink-100), #fff, var(--ink-100)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.boot { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 18px; }
.boot img { width: 140px; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art { background: radial-gradient(600px 300px at 100% 0%, rgba(212,165,55,.25), transparent 60%), linear-gradient(160deg, var(--navy-800), var(--navy-950)); color: #c3cfe6; padding: 64px; display: flex; flex-direction: column; justify-content: center; }
.login-art img { width: 220px; background: var(--white); border-radius: 22px; padding: 16px; margin-bottom: 28px; }
.login-art h2 { color: var(--white); font-size: 1.8rem; }
.login-art .tagline { color: var(--gold-400); margin: 8px 0 28px; }
.login-art ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.login-art li { display: flex; gap: 10px; align-items: center; }
.login-art li .material-symbols-outlined { color: var(--gold-400); }
.login-form-wrap { display: grid; place-items: center; padding: 32px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { font-size: 1.8rem; }
.login-card .muted { margin-bottom: 24px; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; background: #fdecea; color: #8a1c13; padding: 12px 20px; }
#blazor-error-ui .reload { margin-left: 8px; font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis, .skeleton-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-main, .grid-detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; z-index: 30; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(6,20,51,.45); z-index: 20; }
  .menu-btn { display: grid; }
  .content { padding: 18px; }
  .topbar { padding: 0 16px; }
  .filters { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 10px; }
}

/* =========================================================================
   Language switch + Right-to-left (Persian)
   ========================================================================= */
.lang-switch { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--ink-200); background: var(--white); color: var(--navy-800); font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
.lang-switch:hover { border-color: var(--gold-500); color: var(--gold-600); }
.lang-switch:lang(fa) { font-family: "Vazirmatn", sans-serif; }
.login-form-wrap { position: relative; }
.login-lang { position: absolute; top: 24px; inset-inline-end: 24px; }
.end { text-align: end; }
.ltr-value { unicode-bidi: plaintext; }
.arrow { display: inline-block; color: var(--ink-500); }

[dir="rtl"] body { font-family: "Vazirmatn", "Plus Jakarta Sans", system-ui, sans-serif; }
[dir="rtl"] h1, [dir="rtl"] h2 { letter-spacing: 0; line-height: 1.5; }
[dir="rtl"] .kpi strong { letter-spacing: 0; }
[dir="rtl"] .sidebar-brand small, [dir="rtl"] .table th { letter-spacing: 0; text-transform: none; }
[dir="rtl"] .flip-rtl { display: inline-block; transform: scaleX(-1); }
[dir="rtl"] .side-nav a.active { box-shadow: inset -3px 0 0 var(--gold-500); }
[dir="rtl"] .table th { text-align: right; }
[dir="rtl"] .input-icon .icon-btn { right: auto; left: 4px; }
[dir="rtl"] .input-icon .lead { left: auto; right: 12px; }
[dir="rtl"] .input.with-lead { padding-left: 12px; padding-right: 40px; }
[dir="rtl"] .timeline { padding: 0 14px 0 0; border-left: 0; border-right: 2px solid var(--ink-200); }
[dir="rtl"] .timeline li { padding-left: 0; padding-right: 14px; }
[dir="rtl"] .timeline li::before { left: auto; right: -22px; }
[dir="rtl"] .status-list strong { text-align: left; }
[dir="rtl"] .bubble.user { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
[dir="rtl"] .bubble.bot { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
[dir="rtl"] .input, [dir="rtl"] .btn { font-family: "Vazirmatn", sans-serif; }
[dir="rtl"] input[dir="ltr"] { text-align: right; }
[dir="rtl"] .pager { justify-content: flex-start; }
[dir="rtl"] .chart { direction: ltr; } /* time flows left to right on charts in both languages */

@media (max-width: 860px) {
  .hide-sm { display: none; }
  [dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(100%); }
  [dir="rtl"] .nav-open .sidebar { transform: none; }
}
