/* SmartServe Contact Center: calm, readable, operational. Logical properties keep Arabic (right-to-left) correct. */
:root {
  --bg: #f4f6f8; --card: #ffffff; --line: #e3e8ee; --text: #17212b; --muted: #66727f;
  --brand: #0f766e; --brand-dark: #0b5d57; --brand-soft: #e6f4f2;
  --ok: #15803d; --ok-soft: #e8f6ed; --ring: #1d4ed8; --ring-soft: #e8efff; --busy: #b42318; --busy-soft: #fdecea;
  --wrap: #7a3db8; --wrap-soft: #f3ecfb; --pause: #b45309; --pause-soft: #fdf3e6; --warn: #c2410c; --warn-soft: #fff1e8;
  --off: #8a94a0; --off-soft: #f0f2f4;
  /* "on a call" is calm indigo; red (--busy) is kept for problems only */
  --call: #4338ca; --call-soft: #eef2ff;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", "Noto Sans", Arial, sans-serif;
  color: var(--text); font-size: 14px; line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 22px; margin: 18px 0 12px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--warn); }
.error { color: var(--busy); font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 6px; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }

button, .button {
  font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover:not(:disabled), .button:hover { border-color: #c5ced8; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--brand-dark); }
button.ghost, .button.ghost { background: transparent; }
button.small, .button.small, select.small { padding: 5px 10px; font-size: 13px; }
button.big { padding: 12px 20px; font-size: 16px; width: 100%; justify-content: center; }
button.answer { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 700; padding: 12px 26px; font-size: 16px; }
button.decline { background: var(--busy); border-color: var(--busy); color: #fff; font-weight: 600; }
button.answer.small, button.decline.small { padding: 5px 12px; font-size: 13px; }
input, select, textarea {
  font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--text); min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea { font-size: 14px; color: var(--text); }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }

/* header */
header.top {
  display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo { color: var(--brand); font-size: 18px; }
.top-right { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
nav.tabs button.on { background: var(--brand-soft); color: var(--brand-dark); }
.badge { background: var(--warn); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; margin-inline-start: 4px; }

/* chips, pills, dots */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--off-soft); color: var(--muted); font-size: 12px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.pause { background: var(--pause-soft); color: var(--pause); }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.ring { background: var(--ring-soft); color: var(--ring); }
.pill.busy { background: var(--call-soft); color: var(--call); }
.pill.wrap { background: var(--wrap-soft); color: var(--wrap); }
.pill.pause { background: var(--pause-soft); color: var(--pause); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--off-soft); color: var(--off); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.dot.ok { background: var(--ok); } .dot.ring { background: var(--ring); } .dot.busy { background: var(--call); }
.dot.wrap { background: var(--wrap); } .dot.pause { background: var(--pause); } .dot.warn { background: var(--warn); }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); }
.timer.big { font-size: 22px; color: var(--text); font-weight: 600; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }

/* agent desk */
.desk-grid { display: grid; grid-template-columns: minmax(300px, 360px) minmax(360px, 1fr) minmax(280px, 340px); gap: 14px; padding: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.status-line { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; }
.stat b { font-size: 16px; }
.stat span { font-size: 11px; color: var(--muted); }
.stat.warn b { color: var(--warn); }
form.dial { display: flex; gap: 6px; }
form.dial input { flex: 1; font-size: 18px; letter-spacing: .5px; direction: ltr; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.keypad button { justify-content: center; font-size: 18px; padding: 10px; }
.incoming { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 10px 0; animation: glow 1.4s ease-in-out infinite; border-radius: var(--radius); }
@keyframes glow { 50% { background: var(--ok-soft); } }
.big-number { font-size: 24px; font-weight: 700; direction: ltr; unicode-bidi: isolate; letter-spacing: .3px; }
.call { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.controls .ctl { justify-content: center; }
.controls .ctl.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.controls .decline { grid-column: 1 / -1; justify-content: center; padding: 10px; }
.consult { background: var(--pause-soft); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.transfer { text-align: start; display: flex; flex-direction: column; gap: 8px; }
.transfer form.dial input { font-size: 15px; }
.list { display: flex; flex-direction: column; }
.list-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 10px 0 4px; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-top: 1px solid var(--line); }
.list-row:first-of-type { border-top: 0; }
#mycalls .list-row { cursor: pointer; }
.dir { color: var(--muted); width: 16px; text-align: center; }
.customer-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.wrapform { display: flex; flex-direction: column; gap: 10px; background: var(--brand-soft); padding: 12px; border-radius: 8px; margin: 6px 0 12px; }
.wrapform select { width: 100%; }
.history .hist { border-top: 1px solid var(--line); padding: 8px 0; display: flex; flex-direction: column; gap: 4px; }
.note { white-space: pre-wrap; background: var(--bg); border-radius: 6px; padding: 6px 8px; }
.qline { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border-top: 1px solid var(--line); }
.qline.hot b { color: var(--busy); }

/* manager */
#spybar .spybar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: #12313a; color: #fff; flex-wrap: wrap; }
#spybar .spybar .muted { color: #b9cbd1; }
#spybar .spybar button.ghost { color: #fff; border-color: #4c6b74; }
main.mgr { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi > b { font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi > span { font-size: 12px; color: var(--muted); }
.kpi.hot { border-color: #f3b0a9; background: var(--busy-soft); }
.kpi.hot > b { color: var(--busy); }
.kpi.warn > b { color: var(--warn); }
.mgr-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.hot td { background: var(--busy-soft); }
.tbl tr.off td { color: var(--off); }
.tbl td.notes { max-width: 260px; white-space: pre-wrap; }
.tbl audio { height: 30px; width: 220px; }
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.agent { border: 1px solid var(--line); border-inline-start: 4px solid var(--off); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.agent.ok { border-inline-start-color: var(--ok); } .agent.ring { border-inline-start-color: var(--ring); }
.agent.busy { border-inline-start-color: var(--call); } .agent.wrap { border-inline-start-color: var(--wrap); }
.agent.pause { border-inline-start-color: var(--pause); } .agent.warn { border-inline-start-color: var(--warn); }
.agent-call { background: var(--bg); border-radius: 6px; padding: 6px 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; direction: ltr; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 48px 1fr 110px; gap: 8px; align-items: center; }
.bar { display: flex; height: 14px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar i, .legend i { display: inline-block; height: 100%; }
.bar i.in, .legend i.in { background: var(--ok); } .bar i.lost, .legend i.lost { background: var(--busy); } .bar i.out, .legend i.out { background: var(--ring); }
.legend { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.checks { display: inline-flex; gap: 10px; flex-wrap: wrap; }
.qform { border-top: 1px solid var(--line); padding: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.qform.off { opacity: .6; }
.qform input[type=number] { width: 90px; }
.hours { display: inline-flex; gap: 4px; align-items: center; background: var(--bg); padding: 4px 6px; border-radius: 8px; }
.invite-box { border-color: var(--brand); background: var(--brand-soft); }
tr.editing td { background: var(--brand-soft); }

/* sign-in */
body.auth { display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; padding-top: 10vh; }
.auth-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px 28px; width: min(420px, 94vw); box-shadow: var(--shadow); }
.auth-box form { display: flex; flex-direction: column; gap: 14px; }

/* toast */
.toast { position: fixed; bottom: 18px; inset-inline-start: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #17212b; color: #fff; padding: 10px 16px; border-radius: 8px; transition: all .2s; z-index: 50; max-width: 90vw; }
[dir=rtl] .toast { transform: translateX(50%) translateY(20px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
[dir=rtl] .toast.show { transform: translateX(50%) translateY(0); }
.toast.error { background: var(--busy); }
.toast.ok { background: var(--ok); }

@media (max-width: 1100px) {
  .desk-grid { grid-template-columns: 1fr 1fr; }
  .desk-grid .col.wide { grid-column: 1 / -1; order: 3; }
  .mgr-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .desk-grid { grid-template-columns: 1fr; }
  .tbl { display: block; overflow-x: auto; }
}
.dirtag { font-size: 10px; font-weight: 700; letter-spacing: .4px; padding: 1px 5px; border-radius: 4px; background: var(--off-soft); color: var(--muted); flex: none; }
.dirtag.in { background: var(--ok-soft); color: var(--ok); }
.dirtag.out { background: var(--ring-soft); color: var(--ring); }

/* grid cells may shrink; wide tables scroll inside their card instead of widening the page (long Arabic headings) */
.mgr-grid > *, main.mgr > .card, .desk-grid .card { min-width: 0; }
main.mgr .card { overflow-x: auto; }

/* one agent's day */
a.link { color: inherit; text-decoration: none; }
a.link:hover { text-decoration: underline; color: var(--brand-dark); }
.agent-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.agent-head h2 { margin: 0; }
.mgr-grid.even { grid-template-columns: 1fr 1fr; }
.tbl td.warn { color: var(--warn); font-weight: 600; }
.timeline { position: relative; height: 28px; background: var(--off-soft); border-radius: 6px; overflow: hidden; }
.timeline i { position: absolute; top: 0; bottom: 0; }
.timeline i.ok, .legend i.tl.ok { background: var(--ok); }
.timeline i.ring, .legend i.tl.ring { background: var(--ring); }
.timeline i.busy, .legend i.tl.busy { background: var(--call); }
.timeline i.wrap, .legend i.tl.wrap { background: var(--wrap); }
.timeline i.pause, .legend i.tl.pause { background: var(--pause); }
.timeline i.warn, .legend i.tl.warn { background: #f5b48a; }
.ticks { position: relative; height: 18px; margin-top: 4px; }
.ticks span { position: absolute; font-size: 11px; color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
[dir=rtl] .ticks span { transform: translateX(50%); }
@media (max-width: 1100px) { .mgr-grid.even { grid-template-columns: 1fr; } }
