/* Spec Ai · lab 01 — phone first, RTL */
:root {
  --ink: #12302f;
  --ink-soft: #4b6564;
  --bg: #f4f1ea;
  --card: #ffffff;
  --line: #ddd7c9;
  --brand: #0f6b66;
  --brand-dark: #0a4f4b;
  --brand-tint: #e3f1ef;
  --warn: #b4560b;
  --warn-tint: #fdf0e2;
  --bad: #b3261e;
  --bad-tint: #fcebe9;
  --ok: #1b7a43;
  --ok-tint: #e6f4ec;
  --radius: 14px;
  --font: "SF Arabic", "Geeza Pro", "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
.wrap.wide { max-width: 980px; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: var(--ink); color: #fff;
}
header.top .brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
header.top .brand small { font-weight: 400; opacity: .7; margin-inline-start: 8px; font-size: 13px; }
header.top a, header.top button.link { color: #fff; opacity: .85; font-size: 14px; background: none; border: 0; cursor: pointer; font-family: inherit; text-decoration: none; }

h1 { font-size: 24px; margin: 20px 0 6px; line-height: 1.4; }
h2 { font-size: 18px; margin: 0 0 10px; }
p.lead { margin: 0 0 18px; color: var(--ink-soft); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}

/* ── form ── */
label { display: block; font-weight: 600; margin-bottom: 4px; }
label .opt { font-weight: 400; color: var(--ink-soft); font-size: 14px; margin-inline-start: 6px; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=tel], input[type=password], select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 46px;
}
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brand-tint); border-color: var(--brand); }
input[dir=ltr] { text-align: left; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--bad); background: var(--bad-tint); }
.err { color: var(--bad); font-size: 14px; margin-top: 4px; min-height: 0; }
.hint { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.counter { text-align: end; }

/* the bot trap: off-screen, never display:none (bots skip those) */
.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 12px 20px; min-height: 48px;
  background: var(--brand); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.ghost:hover { background: var(--brand-tint); }
.btn.danger { background: var(--bad); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 14px; }

.notice { border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; font-size: 15px; }
.notice.ok { background: var(--ok-tint); color: var(--ok); }
.notice.warn { background: var(--warn-tint); color: var(--warn); }
.notice.bad { background: var(--bad-tint); color: var(--bad); }
.notice ul { margin: 6px 0 0; padding-inline-start: 20px; }

/* ── files ── */
.files { margin-top: 6px; }
.files input[type=file] { width: 100%; font: inherit; }
.file-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.file-list li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }
.file-list li.bad { color: var(--bad); }

/* ── confirmation ── */
.ref {
  display: block; text-align: center; direction: ltr; font-size: 30px; font-weight: 800; letter-spacing: 1px;
  background: var(--brand-tint); color: var(--brand-dark); border-radius: 12px; padding: 14px; margin: 10px 0 16px;
}
.linkbox { direction: ltr; text-align: left; word-break: break-all; background: #f3f0e7; border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* ── status chips ── */
.chip { display: inline-block; border-radius: 999px; padding: 2px 12px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip.new { background: #e5eefb; color: #1e4f9c; }
.chip.waiting_customer { background: var(--warn-tint); color: var(--warn); }
.chip.customer_replied { background: #f3e6fa; color: #7a2a9e; }
.chip.closed { background: #e8e8e4; color: #5b5b55; }

/* ── thread ── */
.thread { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.msg { max-width: 92%; border-radius: 14px; padding: 10px 14px; border: 1px solid var(--line); background: #fff; }
.msg.me { align-self: flex-start; background: var(--brand-tint); border-color: #c4e0dc; }
.msg.them { align-self: flex-end; }
.msg .who { font-size: 13px; color: var(--ink-soft); display: flex; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att img { display: block; max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--line); }
.att a.file { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--brand-dark); text-decoration: none; font-size: 14px; background: #fff; }
.att .dl { display: block; font-size: 13px; color: var(--brand-dark); margin-top: 2px; }

.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-soft); font-size: 14px; }
.meta b { color: var(--ink); }

/* ── bottom sheet (confirm close) ── */
.sheet-bg { position: fixed; inset: 0; background: rgba(18, 48, 47, .5); display: none; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-bg.open { display: flex; }
.sheet { background: #fff; width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 22px 18px 26px; }
.sheet .row { display: flex; gap: 10px; margin-top: 14px; }
.sheet .row .btn { flex: 1; }

.center { text-align: center; }
.muted { color: var(--ink-soft); }
.hidden { display: none !important; }

/* ── dashboard ── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.chips button {
  flex: 0 0 auto; font: inherit; font-size: 14px; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips button .n { opacity: .7; margin-inline-start: 4px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 8px; }
.toolbar > * { flex: 1; }
.toolbar select, .toolbar input { min-height: 42px; }
.tabs { display: flex; gap: 8px; margin: 10px 0 14px; }
.tabs button { flex: 1; font: inherit; font-weight: 700; padding: 10px; border: 0; border-radius: 10px; background: #e8e4d9; cursor: pointer; }
.tabs button.on { background: var(--brand); color: #fff; }

.tlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tlist li button {
  width: 100%; text-align: start; font: inherit; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.tlist li button:hover { border-color: var(--brand); }
.tlist .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tlist .name { font-weight: 700; }
.tlist .snip { color: var(--ink-soft); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tlist .row3 { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }

table.admin { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin th, table.admin td { text-align: start; padding: 6px 8px; border-bottom: 1px solid var(--line); }

@media (min-width: 900px) {
  .split { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
  .split .back { display: none; }
}
@media (max-width: 899px) {
  .split.detail-open .listpane { display: none; }
  .split:not(.detail-open) .detailpane { display: none; }
}

/* visually hidden but still focusable/readable by assistive tech */
.sr-only, .files input.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0 !important; inset-inline-start: 0; }
.filepick:focus-within, .sr-only:focus + .filepick { outline: 3px solid var(--brand-tint); }
.files { position: relative; }
