/* Elsalon support dashboard: Arabic, right to left. Elsalon purple #5b6dc8 (as the chat widget's theme). */
:root {
  --brand: #5b6dc8;
  --brand-dark: #4a5bb0;
  --bg: #f5f6fb;
  --panel: #ffffff;
  --line: #e3e6f0;
  --text: #1f2330;
  --muted: #6b7183;
  --team: #eef0fa;
  --note: #fff6d6;
  --danger: #c0392b;
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--brand); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; padding: 24px; }
.error { color: var(--danger); }
.spacer { flex: 1; }
.pill { background: #fdecea; color: var(--danger); border-radius: 999px; padding: 2px 10px; font-size: 13px; }

/* sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 24px; display: grid; gap: 14px;
}
.login-card h1 { margin: 0; color: var(--brand); font-size: 22px; }
.login-card label { display: grid; gap: 6px; font-size: 14px; }
.login-card input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }

/* layout */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar strong { color: var(--brand); }
.layout { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.sidebar { border-inline-end: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.filters button { font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.filters button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.chat-list li {
  padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 3px;
}
.chat-list li:hover { background: var(--bg); }
.chat-list li.selected { background: var(--team); }
.chat-list li.unanswered .name::before { content: "●"; color: var(--danger); margin-inline-end: 6px; }
.chat-list li.unread { background: #f3f5ff; }
.chat-list li.unread .name { font-weight: 800; }
.chat-list li.unread .when { color: var(--brand-dark); font-weight: 700; }
.chat-list li.selected { background: var(--team); }
.country { font-size: 13px; color: var(--muted); white-space: nowrap; }
.typing { padding: 2px 16px 8px; font-size: 13px; color: var(--brand-dark); font-style: italic; }
.chat-list .row { display: flex; gap: 8px; align-items: center; }
.chat-list .name { font-weight: 600; }
.badge { font-size: 12px; border-radius: 999px; padding: 1px 8px; background: var(--bg); color: var(--muted); }
.badge.ai { background: #e8ecff; color: var(--brand-dark); }
.badge.waiting { background: #fdecea; color: var(--danger); }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; }
#chat-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.chat-head h2 { margin: 0; font-size: 18px; }
.assign { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.assign select { padding: 5px; border-radius: 8px; border: 1px solid var(--line); }
.handover { margin: 10px 16px 0; padding: 8px 12px; background: var(--note); border-radius: 8px; font-size: 14px; }
.messages { list-style: none; margin: 0; padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.msg .meta { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg.visitor { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.team { align-self: flex-end; background: var(--team); }
.msg.note { align-self: flex-end; background: var(--note); border: 1px dashed #e0c25a; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; max-width: 90%; }
.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px; display: grid; gap: 8px; }
.composer-mode { display: flex; gap: 16px; font-size: 14px; }
.composer textarea { width: 100%; resize: vertical; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.composer.note-mode textarea { background: var(--note); }
.composer-actions { display: flex; align-items: center; gap: 8px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 40vh; }
  .msg { max-width: 90%; }
}
