/* «الدعم» as one chat (decisions 100 and 102): on its own page (.chat-page > .chat-stage) and in the window the
   floating «الدعم» opens on every page (.chat-dialog > .chat-slot). A phone: the whole screen. A computer: a tall
   card in the middle, the page dimmed behind. The bubbles and the reply box are components.css (.msg, .composer).
   One family of shapes: bubbles 18px, chips and the reply box round, rows 14px; gold only for the send button, a
   chosen chip, a new reply's dot and «أرسل رقم طلبي». */

/* ---------- the window ---------- */
.chat-dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0; background: transparent; color: var(--text); }
.chat-dialog[open] { display: flex; align-items: center; justify-content: center; }
.chat-dialog::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
html.chat-open { overflow: hidden; }
.chat-slot { display: flex; width: 100%; height: 100%; min-height: 0; }
.chat-loading { display: grid; place-items: center; align-content: center; gap: var(--sp-3); width: 100%; height: 100%; background: var(--bg); }

/* ---------- its own page ---------- */
.chat-page { background: var(--bg); }
.chat-stage { display: flex; justify-content: center; height: 100dvh; }

/* ---------- the chat ---------- */
.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: 100%; min-height: 0; background: var(--bg); }
@media (min-width: 900px) {
  .chat-slot { width: min(720px, calc(100% - 48px)); height: min(calc(100dvh - 48px), 880px); }
  .chat-stage { align-items: center; padding: var(--sp-6); }
  .chat-stage > .chat { max-width: 720px; height: min(calc(100dvh - 48px), 880px); }
  .chat, .chat-loading { overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-3); }
}

/* the header: who he talks to, and when they answer */
.chat-head { display: flex; align-items: center; gap: var(--sp-3); min-height: 64px; padding: var(--sp-2) var(--sp-3); padding-top: max(var(--sp-2), env(safe-area-inset-top)); border-bottom: 1px solid var(--border); background: var(--header-bg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.chat-btn { flex: none; display: grid; place-items: center; width: var(--touch); height: var(--touch); border-radius: 50%; color: var(--text-muted); text-decoration: none; transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
.chat-btn:hover { background: var(--surface-2); color: var(--text); }
.chat-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.chat-avatar { position: relative; flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface-1); }
.chat-avatar img { width: 28px; height: 28px; object-fit: contain; }
.chat-dot { position: absolute; bottom: 0; inset-inline-end: 0; width: 12px; height: 12px; border: 2px solid var(--bg); border-radius: 50%; background: var(--warning); }
.chat-dot.is-open { background: var(--text-faint); }
.chat-dot.is-on { background: var(--success); }
.chat-title { flex: 1; display: grid; gap: 2px; min-width: 0; }
.chat-name { margin: 0; color: var(--text); font-family: var(--font-head); font-size: var(--fs-16); font-weight: 800; line-height: 1.3; }
.chat-status { color: var(--text-muted); font-size: var(--fs-13); }
.chat-status.is-on { color: var(--success); }
.chat-status.is-away { color: var(--warning); }
/* a state: a small dot and its word */
.chat-state { display: inline-flex; flex: none; align-items: center; gap: 5px; color: var(--text-muted); font-size: var(--fs-12); font-weight: 700; }
.chat-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chat-state.is-info { color: var(--info); }
.chat-state.is-warning { color: var(--warning); }
.chat-state.is-success { color: var(--success); }
.chat-state.is-danger { color: var(--danger); }
.chat-state.is-neutral { color: var(--text-faint); }

/* the conversation's room */
.chat-body { display: grid; align-content: start; gap: var(--sp-3); min-height: 0; padding: var(--sp-4) var(--sp-3) var(--sp-5); overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 900px) { .chat-body { padding-inline: var(--sp-5); } }
.chat-body > .thread { padding-block: 0; }
.chat-body .msg { max-width: min(84%, 520px); }
.chat-step { display: grid; gap: var(--sp-2); }
.msg.is-error .msg-bubble { border-color: var(--danger-line); background: var(--danger-soft); }
.chat-end { display: block; height: 1px; }
.chat-link { display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch); padding-inline: var(--sp-2); color: var(--silver); font-size: var(--fs-14); font-weight: 600; text-decoration: underline; text-decoration-color: var(--border-hover); text-underline-offset: 5px; }
.chat-link:hover { text-decoration-color: var(--silver); }
.chat-link:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* the bottom: the reply box, and over it one thin line at most */
.chat-foot { display: grid; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); padding-bottom: max(var(--sp-2), env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--header-bg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.chat-foot .composer { border-radius: 26px; }
.chat-start { display: flex; align-items: center; gap: var(--sp-2); min-height: 52px; padding: 0 var(--sp-4); border: 1px solid var(--border-strong); border-radius: 26px; background: var(--surface-1); color: var(--text-muted); text-decoration: none; transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
.chat-start:hover { border-color: var(--border-hover); color: var(--text); }
.chat-start:focus-visible { outline: none; box-shadow: var(--ring); }
.chat-start .icon:last-child { margin-inline-start: auto; transform: scaleX(-1); }

/* ---------- what he can say: chips on his side ---------- */
.chat-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); }
.chat-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch); padding: 8px 16px; border: 1px solid var(--border-strong); border-radius: var(--r-full); background: transparent; color: var(--text); font: inherit; font-size: var(--fs-14); font-weight: 600; line-height: 1.4; text-align: start; text-decoration: none; cursor: pointer; transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease); }
.chat-chip:hover { border-color: var(--border-hover); background: var(--surface-2); }
.chat-chip:focus-visible, .chat-chip:has(.chat-pick:focus-visible) { outline: none; box-shadow: var(--ring); }
.chat-chip .icon { color: var(--text-muted); }
.chat-chip.is-order { gap: 8px; }
.chat-order-name { color: var(--text-muted); font-weight: 500; }
.chat-pick { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chat-chip:has(.chat-pick:checked) { border-color: var(--gold-line); background: var(--gold-soft); }
.chat-chips.is-done .chat-chip:not(:has(.chat-pick:checked)) { display: none; }
.chat-chips.is-done .chat-chip { cursor: default; }
.chat-ask { align-self: center; color: var(--text-muted); font-size: var(--fs-13); }

/* ---------- motion (the «يكتب…» dots are components.css .chat-typing) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .chat-in { animation: chat-in .3s var(--ease-out) both; }
  .chat-dialog[open] .chat-slot { animation: chat-up .3s var(--ease-out); }
}
@keyframes chat-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes chat-up { from { opacity: 0; transform: translateY(16px); } }

/* ---------- «محادثاتي» (decision 104): one clear row on the start, and its own view ---------- */
.chat-mine { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--touch); padding: 0 var(--sp-3) 0 var(--sp-2); border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); color: var(--text); font-size: var(--fs-14); font-weight: 700; text-decoration: none; transition: border-color var(--dur-1) var(--ease); }
.chat-mine:hover { border-color: var(--border-hover); }
.chat-mine:focus-visible { outline: none; box-shadow: var(--ring); }
.chat-mine > .icon { flex: none; color: var(--text-muted); }
.chat-mine-text { flex: 1; }
.chat-mine-count { color: var(--text-muted); font-weight: 600; }
.chat-convo-list { display: grid; margin: 0; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); list-style: none; }
.chat-convo-list li + li { border-top: 1px solid var(--border); }
.chat-convo { display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: 8px 14px; color: var(--text); text-decoration: none; transition: background var(--dur-1) var(--ease); }
.chat-convo:hover { background: var(--surface-2); }
.chat-convo:focus-visible { outline: none; box-shadow: inset var(--ring); }
.chat-convo > .icon { flex: none; color: var(--text-faint); }
.chat-convo-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.chat-convo-subject { overflow: hidden; font-size: var(--fs-14); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.chat-convo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; color: var(--text-faint); font-size: var(--fs-12); }
.chat-convo.is-unread .chat-convo-subject { color: var(--silver); font-weight: 800; }
.chat-unread { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }

/* ---------- one conversation ---------- */
.chat-info { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; margin: 0; color: var(--text-faint); font-size: var(--fs-12); }
/* decision 103: a number's copy button (its touch is full size, the line stays thin) */
.chat-copy { display: inline-grid; place-items: center; width: var(--touch); height: var(--touch); margin: -12px -10px; border: 0; border-radius: 50%; background: transparent; color: var(--text-faint); cursor: pointer; }
.chat-copy:hover { color: var(--text); }
.chat-copy:focus-visible { outline: none; box-shadow: var(--ring); }
.chat-copy .icon { width: 14px; height: 14px; }
.msg.is-hint .msg-bubble b { color: var(--text); font-weight: 700; }
.chat-order-wrap { display: grid; gap: var(--sp-2); }
.chat-order { position: relative; display: flex; align-items: center; gap: var(--sp-3); min-height: 64px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); color: var(--text); transition: border-color var(--dur-1) var(--ease); }
.chat-order:hover { border-color: var(--border-hover); }
.chat-order:has(.chat-order-names:focus-visible) { box-shadow: var(--ring); }
.chat-order-names { color: var(--text); text-decoration: none; }
.chat-order-names:focus-visible { outline: none; }
.chat-order-names::after { content: ""; position: absolute; inset: 0; border-radius: 14px; }  /* the whole row opens the order */
.chat-order .chat-copy { position: relative; z-index: 1; }
.chat-order > .icon { flex: none; color: var(--text-faint); }
.chat-order-pic { flex: none; display: grid; place-items: center; width: 36px; height: 48px; overflow: hidden; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-muted); }
.chat-order-pic img { width: 100%; height: 100%; object-fit: cover; }
.chat-order-text { flex: 1; display: grid; gap: 3px; min-width: 0; }
.chat-order-names { overflow: hidden; font-size: var(--fs-14); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.chat-order-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; color: var(--text-faint); font-size: var(--fs-12); }
.chat-order-send { justify-self: stretch; justify-content: center; min-height: var(--touch); }
.chat-context { justify-self: center; display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch); padding: 4px 14px; border: 1px solid var(--border); border-radius: var(--r-full); color: var(--text-muted); font-size: var(--fs-13); text-decoration: none; }
.chat-context:hover { border-color: var(--border-hover); color: var(--text); }
.chat-typing-line .msg-bubble { padding: 12px 14px; }
.chat-seen { justify-self: end; display: inline-flex; align-items: center; gap: 4px; margin: calc(-1 * var(--sp-2)) 0 0; color: var(--text-faint); font-size: var(--fs-12); }
.chat-seen .icon { color: var(--success); }
/* «كيف كانت مساعدتنا؟»: the stars first; the note and «إرسال» once a star is chosen */
.chat-rate { display: grid; justify-items: center; gap: var(--sp-2); margin: 0; padding: var(--sp-4); border: 1px solid var(--border); border-radius: 18px; background: var(--surface-1); text-align: center; }
.chat-rate-title { margin: 0; font-weight: 700; }
.chat-rate .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat-rate-more { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); width: 100%; }
.chat-rate-more .input { flex: 1 1 200px; min-width: 0; }
.chat-rate:not(:has(input[type="radio"]:checked)) .chat-rate-more { display: none; }
.chat-rated { justify-self: center; display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text-muted); font-size: var(--fs-13); }
.chat-ended { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 52px; color: var(--text-muted); }
.chat-blocked { flex: 1 1 100%; color: var(--warning); font-size: var(--fs-13); font-weight: 600; }  /* decision 116: the team's block */
/* «نبّهني»: one thin line over the box, gone once it is on (or he closes it) */
.chat-push { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--touch); padding-inline: var(--sp-3) var(--sp-1); border: 1px solid var(--border); border-radius: var(--r-full); color: var(--text-muted); font-size: var(--fs-13); }
.chat-push > .icon { flex: none; color: var(--silver); }
.chat-push-text { flex: 1; min-width: 0; }
.chat-push-on { flex: none; min-height: var(--touch); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-full); background: transparent; color: var(--silver); font: inherit; font-weight: 700; cursor: pointer; }
.chat-push-on:hover { background: var(--surface-2); }
.chat-push-on:focus-visible { outline: none; box-shadow: var(--ring); }
.chat-push-x { flex: none; display: grid; place-items: center; width: var(--touch); height: var(--touch); border: 0; border-radius: 50%; background: transparent; color: var(--text-faint); cursor: pointer; }
.chat-push-x:hover { background: var(--surface-2); color: var(--text); }
.chat-push-x:focus-visible { outline: none; box-shadow: var(--ring); }
/* the bot's answers */
.chat-logos { display: grid; gap: 6px; margin-top: var(--sp-2); white-space: normal; }
.chat-logo { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: var(--fs-13); }
.chat-logo img { border-radius: var(--r-sm); }
.msg-bubble.chat-hours { min-width: min(280px, 64vw); }
.chat-hours-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.chat-hours-list li { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 4px 8px; border-radius: var(--r-sm); color: var(--text-muted); font-size: var(--fs-13); }
.chat-hours-list li.is-today { background: var(--surface-3); color: var(--text); font-weight: 700; }
/* the ready questions like what he writes, over the box */
.chat-suggest { display: grid; gap: 6px; }
.chat-suggest-title { margin: 0; color: var(--text-muted); font-size: var(--fs-12); font-weight: 700; }
.chat-chips.is-suggest { justify-content: flex-start; }
