/* ===== Theme: calm sage & sand — quiet colors suited to a counselling space ===== */
:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #f9faf7;
  --line: #e2e7e0;
  --ink: #1f2d2b;
  --ink-2: #44524f;
  --muted: #7a8784;
  --primary: #2f6f68;
  --primary-ink: #ffffff;
  --primary-soft: #e4f0ec;
  --primary-deep: #1f4b47;
  --accent: #c48a5c;
  --accent-soft: #f6ebe1;
  --ok: #3d8a63;
  --ok-soft: #e3f2e9;
  --warn: #b7862f;
  --warn-soft: #fbf1dc;
  --danger: #b4524a;
  --danger-soft: #f8e5e3;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(31, 45, 43, .05), 0 6px 20px rgba(31, 45, 43, .06);
  --sidebar-w: 268px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.8;
  direction: rtl;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-deep); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.5; font-weight: 700; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.icon { flex: none; vertical-align: middle; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-deep), #23524d 60%, #2a5e58);
  color: #e6f0ed;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; right: 0;
  z-index: 40;
  transition: transform .25s ease;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 22px 18px;
  color: #fff; font-weight: 800; font-size: 1.1rem;
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: rgba(255,255,255,.12);
  display: grid; place-items: center; color: #cfe6df;
}
.brand small { display: block; font-weight: 400; font-size: .75rem; color: #a9c6bf; margin-top: -4px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 3px;
  color: #d4e4df; border-radius: 11px;
  font-size: .94rem;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav a.active .icon { color: #f2c9a6; }
.nav .count {
  margin-inline-start: auto;
  background: var(--accent); color: #fff;
  font-size: .72rem; border-radius: 99px; padding: 0 8px; line-height: 1.7;
}
.user-box {
  margin: 12px; padding: 14px;
  background: rgba(0,0,0,.16); border-radius: 13px;
  display: flex; align-items: center; gap: 11px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.user-box .who { flex: 1; min-width: 0; }
.user-box .name { color: #fff; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box .role { font-size: .78rem; color: #a9c6bf; }
.user-box button {
  background: transparent; border: 1px solid rgba(255,255,255,.2);
  color: #e6f0ed; border-radius: 9px; padding: 6px 8px; cursor: pointer;
  display: flex; align-items: center; gap: 4px; font-family: inherit; font-size: .8rem;
}
.user-box button:hover { background: rgba(255,255,255,.1); }

.main { flex: 1; margin-right: var(--sidebar-w); min-width: 0; }
.topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.content { padding: 28px 32px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); }
.scrim { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20,30,28,.35); z-index: 35; }
  .main { margin-right: 0; }
  .topbar { display: flex; }
  .content { padding: 18px 16px 50px; }
}

/* ===== Cards & grids ===== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.hero {
  background: linear-gradient(120deg, var(--primary-soft), #eef3e8 55%, var(--accent-soft));
  border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 28px; margin-bottom: 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.hero h1 { font-size: 1.5rem; }
.hero p { color: var(--ink-2); margin: 0; max-width: 620px; }
.hero .leaf { color: var(--primary); opacity: .55; }
@media (max-width: 720px) { .hero .leaf { display: none; } }

.stat {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s;
}
.stat:hover { transform: translateY(-2px); border-color: #cfdcd6; color: var(--ink); }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat:nth-child(2) .ic { background: var(--accent-soft); color: var(--accent); }
.stat:nth-child(3) .ic { background: #e9eef8; color: #4d6a9c; }
.stat:nth-child(4) .ic { background: var(--ok-soft); color: var(--ok); }
.stat .num { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat .lbl { font-size: .84rem; color: var(--muted); }

.access-list { list-style: none; margin: 0; padding: 0; }
.access-list li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.access-list li:last-child { border-bottom: 0; }
.access-list .icon { color: var(--ok); margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 16px; border-radius: 10px; border: 1px solid transparent;
  font-family: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  background: var(--primary); color: var(--primary-ink); line-height: 1.6;
  transition: background .15s, box-shadow .15s;
}
.btn:hover { background: var(--primary-deep); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); border-color: #cfe0da; }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary-deep); }
.btn-soft { background: var(--primary-soft); color: var(--primary-deep); }
.btn-soft:hover { background: #d4e8e1; color: var(--primary-deep); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #a9724a; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ok { background: var(--ok-soft); color: var(--ok); }
.btn-ok:hover { background: var(--ok); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: 11px 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eef1ed; color: var(--ink-2); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #eef1ed; color: var(--muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary-deep); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: right; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }

/* ===== Forms ===== */
label { font-weight: 600; font-size: .88rem; display: block; margin-bottom: 5px; color: var(--ink-2); }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=tel], select, textarea {
  width: 100%; font-family: inherit; font-size: .94rem;
  padding: 9px 12px; border: 1px solid #d5ddd6; border-radius: 10px;
  background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,111,104,.14); }
.field { margin-bottom: 14px; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--danger); font-size: .84rem; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin: 0; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 170px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-size: .86rem; }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== Messages (flash) ===== */
.flash { padding: 11px 16px; border-radius: 11px; margin-bottom: 12px; font-size: .9rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: #2a6a4a; border-color: #cbe6d6; }
.flash-info { background: var(--primary-soft); color: var(--primary-deep); border-color: #cde2dc; }
.flash-warning { background: var(--warn-soft); color: #8a6420; }
.flash-danger { background: var(--danger-soft); color: #8e3b35; border-color: #f0cfcb; }

/* ===== Auth pages ===== */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 85% 15%, rgba(196,138,92,.16), transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(47,111,104,.18), transparent 45%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 430px; }
.auth-card .brand { color: var(--primary-deep); justify-content: center; padding: 0 0 18px; }
.auth-card .brand .logo { background: var(--primary-soft); color: var(--primary); }
.auth-card .brand small { color: var(--muted); }

/* ===== Score bars ===== */
.bar { height: 9px; background: #edf1ec; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #6aa69c); border-radius: 99px; }
.bar.accent > span { background: linear-gradient(90deg, var(--accent), #ddb08b); }
.score-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 12px; align-items: center; padding: 8px 0; }
@media (max-width: 600px) { .score-row { grid-template-columns: 1fr 70px; } .score-row .bar { grid-column: 1 / -1; grid-row: 2; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--primary-deep); border-radius: 99px; padding: 2px 12px; font-size: .82rem; }
.chip.accent { background: var(--accent-soft); color: #8a5a35; }

/* ===== Test builder ===== */
.builder-section { border-right: 3px solid var(--primary); }
.trait-input { display: flex; gap: 8px; }
.trait-input input { flex: 1; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; display: flex; opacity: .7; }
.chip button:hover { opacity: 1; }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.q-card.invalid { border-color: var(--danger); }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.q-num { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.q-tools { display: flex; gap: 4px; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.opt-row { display: grid; grid-template-columns: 26px 1fr 96px; gap: 8px; align-items: center; margin-bottom: 7px; }
.opt-row .idx { color: var(--muted); font-size: .85rem; text-align: center; }
.opt-row input[type=number] { text-align: center; }
.weights { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.weight-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.weight-box .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.weight-box input { width: 72px; text-align: center; padding: 5px; }
.weight-box .range { font-size: .76rem; color: var(--muted); }
.sub-title { font-size: .84rem; font-weight: 700; color: var(--ink-2); margin: 14px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sticky-bar { position: sticky; bottom: 0; background: rgba(244,246,242,.94); backdrop-filter: blur(6px); padding: 14px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; align-items: center; z-index: 5; flex-wrap: wrap; }
.add-q { width: 100%; border: 2px dashed #c9d8d2; background: transparent; border-radius: var(--radius); padding: 16px; color: var(--primary); font-family: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.add-q:hover { background: var(--primary-soft); border-color: var(--primary); }

/* ===== Taking a test ===== */
.take-q { padding: 18px 0; border-bottom: 1px solid var(--line); }
.take-q:last-of-type { border-bottom: 0; }
.take-q.missing { background: var(--danger-soft); border-radius: 12px; padding: 18px 14px; }
.take-q .qt { font-weight: 600; margin-bottom: 10px; display: flex; gap: 10px; }
.take-q .qt span { color: var(--primary); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-block; padding: 7px 16px; border: 1px solid #d5ddd6; border-radius: 99px; cursor: pointer; background: #fff; font-size: .9rem; transition: all .12s; }
.choice span:hover { border-color: var(--primary); }
.choice input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgba(47,111,104,.25); }
.progress-line { height: 5px; background: #e4ebe6; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress-line span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }

/* ===== Chat ===== */
.chat-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } .chat-side { display: none; } }
.chat-box { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 420px; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 18px; background: linear-gradient(180deg, #fbfcfa, #f5f8f4); display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 72%; padding: 9px 14px; border-radius: 16px; background: #fff; border: 1px solid var(--line); align-self: flex-end; white-space: pre-wrap; word-wrap: break-word; position: relative; }
.msg.mine { align-self: flex-start; background: var(--primary); color: #fff; border-color: var(--primary); border-bottom-right-radius: 5px; }
.msg:not(.mine) { border-bottom-left-radius: 5px; }
.msg .meta { display: flex; gap: 8px; align-items: center; font-size: .72rem; opacity: .7; margin-top: 3px; }
.msg .sender { font-size: .76rem; font-weight: 700; opacity: .8; }
.msg form { display: inline; }
.msg .del { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; opacity: .8; display: flex; }
.chat-form { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: #fff; align-items: flex-end; }
.chat-form textarea { flex: 1; min-height: 44px; max-height: 140px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); }
.thread-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink); }
.thread-link:hover { background: var(--surface-2); color: var(--ink); }
.thread-link.active { background: var(--primary-soft); }

/* ===== Rating form ===== */
.rate-row { display: grid; grid-template-columns: 170px 1fr 54px; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.rate-row input[type=range] { width: 100%; accent-color: var(--accent); }
.rate-row output { text-align: center; font-weight: 800; color: var(--accent); font-size: 1.1rem; }
.rate-row .off output { color: var(--muted); }
@media (max-width: 600px) { .rate-row { grid-template-columns: 1fr 50px; } .rate-row input[type=range] { grid-column: 1 / -1; } }

.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty .icon { color: #b9c9c3; margin-bottom: 6px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.grid-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .grid-side { grid-template-columns: 1fr; } }

/* ===== Brand (webscanmetho logo) ===== */
.brand .logo-mark { width: 52px; height: auto; flex: none; }
.brand .brand-name { direction: ltr; text-align: right; font-family: "Inter", "Vazirmatn", sans-serif; letter-spacing: -.01em; }
.brand .brand-name small { direction: rtl; }
.auth-brand { flex-direction: column; gap: 4px; }
.auth-brand img { height: 46px; width: auto; }
.auth-brand small { color: var(--muted); font-weight: 400; font-size: .8rem; }
