/* Morabiha CRM — RTL panel on Bootstrap 5.3 */
:root {
  --crm-ink: #14262b;
  --crm-muted: #5b6e6c;
  --crm-deep: #0f3b3a;
  --crm-deep-2: #164c4a;
  --crm-surface: #f4f7f6;
  --crm-card: #ffffff;
  --crm-line: #dde5e3;
  --crm-accent: #1f8a70;
  --crm-accent-dark: #17705a;
  --crm-accent-soft: #e3f2ed;
  --crm-signal: #e4572e;
  --crm-signal-soft: #fdece6;
  --crm-amber: #c98a12;
  --crm-radius: 10px;
  --crm-radius-sm: 6px;

  --bs-body-font-family: 'Vazirmatn', system-ui, sans-serif;
  --bs-body-color: var(--crm-ink);
  --bs-body-bg: var(--crm-surface);
  --bs-border-color: var(--crm-line);
  --bs-primary: var(--crm-accent);
  --bs-primary-rgb: 31, 138, 112;
  --bs-link-color: var(--crm-accent-dark);
  --bs-link-color-rgb: 23, 112, 90;
  --bs-link-hover-color: var(--crm-deep);
  --bs-danger: var(--crm-signal);
  --bs-danger-rgb: 228, 87, 46;
  --bs-border-radius: var(--crm-radius-sm);
  --bs-border-radius-lg: var(--crm-radius);
}

body {
  overflow-x: clip;
  font-feature-settings: 'tnum' 1;
  font-size: 0.94rem;
  line-height: 1.75;
}

h1, .h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em; }
h2, .h2 { font-size: 1.12rem; font-weight: 700; }
h3, .h3 { font-size: 1rem; font-weight: 700; }
.text-muted { color: var(--crm-muted) !important; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
/* Keeps "label number" pairs from being reordered by the bidi algorithm. */
.iso { unicode-bidi: isolate; }
:focus-visible { outline: 2px solid var(--crm-accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn-primary {
  --bs-btn-bg: var(--crm-accent);
  --bs-btn-border-color: var(--crm-accent);
  --bs-btn-hover-bg: var(--crm-accent-dark);
  --bs-btn-hover-border-color: var(--crm-accent-dark);
  --bs-btn-active-bg: var(--crm-deep);
  --bs-btn-active-border-color: var(--crm-deep);
  --bs-btn-disabled-bg: var(--crm-accent);
  --bs-btn-disabled-border-color: var(--crm-accent);
  font-weight: 600;
}
.btn-outline-primary {
  --bs-btn-color: var(--crm-accent-dark);
  --bs-btn-border-color: var(--crm-accent);
  --bs-btn-hover-bg: var(--crm-accent);
  --bs-btn-hover-border-color: var(--crm-accent);
  --bs-btn-active-bg: var(--crm-accent-dark);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--crm-line); }
.btn .bi { vertical-align: -0.1em; }

/* ---------- shell: sidebar on the right (RTL) ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--crm-deep);
  color: #cfe2de;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.85rem;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.08rem;
  padding: 0 0.5rem 1.1rem;
}
.sidebar .brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--crm-accent);
  display: grid; place-items: center;
  font-size: 1.05rem;
}
.sidebar .brand small { display: block; font-weight: 400; font-size: 0.72rem; color: #9fc3bc; }
.nav-group { margin-top: 0.9rem; }
.nav-group-title { font-size: 0.74rem; color: #86aaa4; padding: 0 0.6rem 0.3rem; }
.side-link {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--crm-radius-sm);
  color: #d5e6e2; text-decoration: none;
  font-weight: 500;
}
.side-link .bi { font-size: 1.05rem; opacity: 0.85; }
.side-link:hover { background: var(--crm-deep-2); color: #fff; }
.side-link.active { background: #fff; color: var(--crm-deep); font-weight: 700; }
.side-link.active .bi { opacity: 1; color: var(--crm-accent); }
.side-link .count {
  margin-inline-start: auto;
  background: var(--crm-signal); color: #fff;
  font-size: 0.72rem; font-weight: 700;
  border-radius: 999px; padding: 0 0.45rem; line-height: 1.5;
}
.sidebar .me {
  margin-top: auto;
  border-top: 1px solid var(--crm-deep-2);
  padding-top: 0.85rem;
  display: flex; align-items: center; gap: 0.6rem;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--crm-accent-soft); color: var(--crm-deep);
  display: inline-grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.sidebar .me .avatar { background: var(--crm-deep-2); color: #fff; }
.sidebar .me a { color: #9fc3bc; font-size: 0.8rem; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: none;
  background: var(--crm-deep); color: #fff;
  padding: 0.6rem 1rem;
  align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 1020;
}
.topbar a { color: #fff; }
.content { padding: 1.5rem 1.75rem 3rem; max-width: 1440px; }

.page-head {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--crm-muted); font-size: 0.85rem; }

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    z-index: 1040; transform: translateX(100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 59, 58, 0.4); }
  .topbar { display: flex; }
  .content { padding: 1rem 1rem 3rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* ---------- panels ---------- */
.panel {
  background: var(--crm-card);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--crm-line);
}
.panel-head h2 { margin: 0; font-size: 0.98rem; }
.panel-body { padding: 1rem; }
.panel + .panel { margin-top: 1rem; }

/* ---------- KPI strip (one row, separated, not cards) ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  background: var(--crm-card);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  margin-bottom: 1.25rem;
}
.kpi { padding: 0.85rem 1rem; border-inline-start: 1px solid var(--crm-line); }
.kpi:first-child { border-inline-start: 0; }
.kpi .v { font-size: 1.45rem; font-weight: 800; line-height: 1.3; }
.kpi .l { color: var(--crm-muted); font-size: 0.8rem; }
.kpi.alert-kpi .v { color: var(--crm-signal); }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { background: var(--crm-surface); }

/* ---------- follow-up queue (time rail) ---------- */
.queue { list-style: none; margin: 0; padding: 0; }
.queue li {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.75rem; align-items: center;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--crm-line);
}
.queue li:first-child { border-top: 0; }
.queue .time {
  font-weight: 800; font-size: 0.95rem; text-align: center;
  border-inline-end: 3px solid var(--crm-accent);
  padding-inline-end: 0.6rem;
}
.queue li.overdue .time { color: var(--crm-signal); border-color: var(--crm-signal); }
.queue .who { min-width: 0; }
.queue .who a { font-weight: 700; color: var(--crm-ink); text-decoration: none; }
.queue .who a:hover { color: var(--crm-accent-dark); }
.queue .who .meta { font-size: 0.8rem; color: var(--crm-muted); }

/* ---------- tables ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: 0.6rem 0.75rem; vertical-align: middle; }
.table thead th {
  font-size: 0.78rem; font-weight: 600; color: var(--crm-muted);
  background: var(--crm-surface); border-bottom-width: 1px; white-space: nowrap;
}
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f0f6f4; }
.lead-name { font-weight: 700; color: var(--crm-ink); text-decoration: none; }
.lead-name:hover { color: var(--crm-accent-dark); }
.phone { direction: ltr; unicode-bidi: isolate; font-weight: 600; white-space: nowrap; }

/* ---------- badges ---------- */
.stage-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c, #6c757d) 13%, #fff);
  color: color-mix(in srgb, var(--c, #6c757d) 80%, #000);
  white-space: nowrap;
}
.stage-badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--c, #6c757d);
}
.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 0 0.45rem; border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--c, #0d6efd) 45%, #fff);
  color: color-mix(in srgb, var(--c, #0d6efd) 85%, #000);
}
.prio { font-size: 0.75rem; font-weight: 700; }
.prio-hot { color: var(--crm-signal); }
.prio-warm { color: var(--crm-amber); }
.prio-cold { color: #4a7fa6; }
.due-overdue { color: var(--crm-signal); font-weight: 700; }
.due-today { color: var(--crm-accent-dark); font-weight: 700; }

/* ---------- call desk (lead page) ---------- */
.call-desk {
  background: var(--crm-deep);
  color: #fff;
  border-radius: var(--crm-radius);
  padding: 1.15rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
.call-desk h1 { color: #fff; margin: 0 0 0.15rem; font-size: 1.35rem; }
.call-desk .meta { color: #a9cbc4; font-size: 0.84rem; }
.call-desk .meta .stage-badge { background: #fff; }
.call-desk .big-phone {
  font-size: 1.9rem; font-weight: 800; letter-spacing: 0.02em;
  direction: ltr; unicode-bidi: isolate;
  color: #fff; text-decoration: none; line-height: 1.2;
}
.call-desk .big-phone:hover { color: #bfe9dd; }
.call-desk .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.btn-call {
  background: var(--crm-accent); color: #fff; border: 0;
  font-weight: 700; padding: 0.55rem 1.1rem; border-radius: 999px;
}
.btn-call:hover { background: #26a585; color: #fff; }
.btn-ghost {
  background: transparent; color: #d5e6e2; border: 1px solid #3a6d69;
  border-radius: 999px; padding: 0.5rem 0.85rem;
}
.btn-ghost:hover { background: var(--crm-deep-2); color: #fff; }
@media (max-width: 767.98px) {
  .call-desk { grid-template-columns: 1fr; }
  .call-desk .actions { justify-content: flex-start; }
  .call-desk .big-phone { font-size: 1.6rem; }
}

/* one-tap outcome picker */
.outcomes { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.outcomes input { position: absolute; opacity: 0; pointer-events: none; }
.outcomes label {
  border: 1px solid var(--crm-line); background: #fff;
  border-radius: 999px; padding: 0.3rem 0.8rem;
  cursor: pointer; font-size: 0.85rem; user-select: none;
}
.outcomes label:hover { border-color: var(--crm-accent); }
.outcomes input:checked + label { background: var(--crm-accent); border-color: var(--crm-accent); color: #fff; font-weight: 600; }
.outcomes input.neg:checked + label { background: var(--crm-signal); border-color: var(--crm-signal); }
.outcomes input:focus-visible + label { outline: 2px solid var(--crm-accent); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--crm-line); border-radius: var(--crm-radius-sm); overflow: hidden; background: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 0.35rem 0.85rem; cursor: pointer; font-size: 0.86rem; border-inline-start: 1px solid var(--crm-line); }
.seg label:first-of-type { border-inline-start: 0; }
.seg input:checked + label { background: var(--crm-deep); color: #fff; font-weight: 600; }
.seg input:focus-visible + label { outline: 2px solid var(--crm-accent); outline-offset: -2px; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
  position: relative;
  padding: 0.75rem 1rem 0.75rem 1rem;
  padding-inline-start: 3.1rem;
  border-top: 1px solid var(--crm-line);
}
.timeline > li:first-child { border-top: 0; }
.timeline .ico {
  position: absolute; inset-inline-start: 1rem; top: 0.85rem;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.8rem;
  background: var(--crm-accent-soft); color: var(--crm-accent-dark);
}
.timeline .ico.neg { background: var(--crm-signal-soft); color: var(--crm-signal); }
.timeline .ico.sys { background: #eef1f1; color: var(--crm-muted); }
.timeline .head { display: flex; flex-wrap: wrap; gap: 0.4rem 0.75rem; align-items: baseline; }
.timeline .head strong { font-weight: 700; }
.timeline .when { color: var(--crm-muted); font-size: 0.78rem; margin-inline-start: auto; }
.timeline .body { white-space: pre-line; margin-top: 0.2rem; }
.timeline .chip { font-size: 0.75rem; color: var(--crm-muted); border: 1px solid var(--crm-line); border-radius: 4px; padding: 0 0.35rem; }

/* ---------- definition list ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; font-size: 0.88rem; }
.facts dt { color: var(--crm-muted); font-weight: 400; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- forms ---------- */
.form-label { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.3rem; }
.form-text { font-size: 0.78rem; }
.form-control, .form-select { border-color: #cdd8d5; }
.form-control:focus, .form-select:focus { border-color: var(--crm-accent); box-shadow: 0 0 0 0.2rem rgba(31, 138, 112, 0.15); }
.required::after { content: ' *'; color: var(--crm-signal); }
.form-check-input:checked { background-color: var(--crm-accent); border-color: var(--crm-accent); }
input[data-jdp] { direction: ltr; text-align: right; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; padding: 0.8rem 1rem; border-bottom: 1px solid var(--crm-line); }
.filters .form-select, .filters .form-control { font-size: 0.85rem; min-width: 130px; }
.filters .grow { flex: 1 1 220px; }
.bulkbar {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  padding: 0.6rem 1rem; background: var(--crm-accent-soft); border-bottom: 1px solid var(--crm-line);
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--crm-line); padding: 0 0.75rem; overflow-x: auto; }
.tabs a {
  padding: 0.65rem 0.75rem; text-decoration: none; color: var(--crm-muted);
  border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500;
}
.tabs a.active { color: var(--crm-deep); border-color: var(--crm-accent); font-weight: 700; }
.tabs .n { font-size: 0.75rem; background: var(--crm-surface); border-radius: 999px; padding: 0 0.4rem; margin-inline-start: 0.25rem; }
.tabs a.overdue .n { background: var(--crm-signal); color: #fff; }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--crm-muted); padding: 2.25rem 1rem; }
.empty .bi { font-size: 1.8rem; display: block; margin-bottom: 0.35rem; color: #9db3af; }
.flash-stack .alert { border-radius: var(--crm-radius-sm); }
.dup-hint { font-size: 0.85rem; margin-top: 0.35rem; }
.stage-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--crm-surface); }
.stage-bar span { background: var(--c); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--crm-deep); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: var(--crm-radius); padding: 2rem 1.75rem; }
.auth-card .brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--crm-accent); color: #fff; display: grid; place-items: center; font-size: 1.3rem; margin-bottom: 1rem; }
.jdp-container { font-family: inherit !important; }
.pagination { --bs-pagination-active-bg: var(--crm-accent); --bs-pagination-active-border-color: var(--crm-accent); --bs-pagination-color: var(--crm-accent-dark); margin: 0; }
