/* Customer ↔ driver chat + call screens. Mobile first (full screen, safe areas, keyboard), side panel on computers.
   Deroua colours: navy #14213d, orange #c2410c / #f97316, green #16a34a. Light + dark (system setting). */
.cx, .cl { --cx-bg: #efeae2; --cx-panel: #ffffff; --cx-ink: #14213d; --cx-muted: #5b6782; --cx-mine: #dcf8e8; --cx-theirs: #ffffff; --cx-line: #e3e7ef;
  --cx-accent: #c2410c; --cx-go: #16a34a; --cx-read: #2563eb; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--cx-ink); }
@media (prefers-color-scheme: dark) {
  .cx, .cl { --cx-bg: #0b141a; --cx-panel: #111b21; --cx-ink: #e9edef; --cx-muted: #9aa6b2; --cx-mine: #005c4b; --cx-theirs: #202c33; --cx-line: #2a3942; --cx-read: #53bdeb; }
}
html.cx-open, html.cx-open body { overflow: hidden; }
.cx { position: fixed; inset: 0; z-index: 1200; display: flex; flex-direction: column; background: var(--cx-bg); height: 100dvh; animation: cx-in .22s ease-out; }
@keyframes cx-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 900px) { .cx { left: auto; width: 420px; border-left: 1px solid var(--cx-line); box-shadow: -12px 0 40px rgba(20,33,61,.2); } }

/* header */
.cx-head { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 10px 8px; background: #14213d; color: #fff; }
.cx-icon { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.cx-icon:active, .cx-send:active { transform: scale(.94); }
.cx-icon[disabled] { opacity: .4; cursor: default; }
.cx-avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #f97316; color: #fff; font-weight: 800; font-size: 17px; }
.cx-who { display: grid; flex: 1; min-width: 0; line-height: 1.2; }
.cx-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-status { font-size: 12.5px; color: #cbd5e1; } .cx-status--typing { color: #86efac; }
.cx-call { background: rgba(255,255,255,.12); }
.cx-banner { padding: 8px 14px; background: #fff7ed; color: #9a3412; font-size: 13px; text-align: center; } .cx-banner[hidden] { display: none; }

/* messages */
.cx-body { position: relative; flex: 1; min-height: 0; }
.cx-list { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 10px 10px 14px; display: flex; flex-direction: column; gap: 4px; }
.cx-day, .cx-unread { align-self: center; margin: 8px 0; }
.cx-day span { padding: 4px 12px; border-radius: 8px; background: var(--cx-panel); color: var(--cx-muted); font-size: 12px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.cx-unread { align-self: stretch; text-align: center; } .cx-unread span { display: inline-block; padding: 4px 14px; border-radius: 99px; background: #fff1e6; color: var(--cx-accent); font-size: 12px; font-weight: 700; }
.cx-msg { position: relative; align-self: flex-start; max-width: 80%; padding: 7px 10px 6px; border-radius: 14px 14px 14px 4px; background: var(--cx-theirs); box-shadow: 0 1px 1px rgba(0,0,0,.1); animation: cx-pop .16s ease-out; word-wrap: break-word; }
.cx-msg--mine { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: var(--cx-mine); }
[dir="rtl"] .cx-msg { border-radius: 14px 14px 4px 14px; } [dir="rtl"] .cx-msg--mine { border-radius: 14px 14px 14px 4px; }
@keyframes cx-pop { from { transform: scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }
.cx-msg--failed { outline: 2px solid #ef4444; cursor: pointer; }
.cx-text { white-space: pre-wrap; }
.cx-meta { float: inline-end; display: inline-flex; align-items: center; gap: 4px; margin: 6px 0 -2px 10px; font-size: 11px; color: var(--cx-muted); }
.cx-tick { letter-spacing: -3px; font-size: 12px; } .cx-tick--read { color: var(--cx-read); } .cx-tick--failed { color: #ef4444; font-weight: 800; letter-spacing: 0; }
.cx-callrow { align-self: center; display: inline-flex; align-items: center; gap: 6px; margin: 6px 0; padding: 6px 12px; border-radius: 99px; background: var(--cx-panel); color: var(--cx-muted); font-size: 13px; }
.cx-callrow small { font-size: 11px; } .cx-callrow--missed { color: #dc2626; }
.cx-empty { margin: auto; max-width: 300px; padding: 14px; border-radius: 12px; background: #fff7ed; color: #9a3412; text-align: center; font-size: 13.5px; }
.cx-tobottom { position: absolute; right: 12px; bottom: 12px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--cx-panel); color: var(--cx-ink); box-shadow: 0 2px 8px rgba(0,0,0,.2); cursor: pointer; display: grid; place-items: center; }
.cx-tobottom[hidden] { display: none; }

/* voice message */
.cx-voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.cx-play { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #14213d; color: #fff; cursor: pointer; }
.cx-voice--mine .cx-play { background: var(--cx-go); }
.cx-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.cx-wave i { flex: 1; min-width: 2px; min-height: 22%; border-radius: 2px; background: #94a3b8; opacity: .7; }
.cx-wave i.on { background: var(--cx-accent); opacity: 1; }
.cx-voice--mine .cx-wave i.on { background: var(--cx-go); }
.cx-vtime { flex: none; font-size: 12px; color: var(--cx-muted); min-width: 34px; }

/* input bar */
.cx-bar { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--cx-bg); }
.cx-bar[hidden] { display: none; }
.cx-field { flex: 1; min-width: 0; display: flex; align-items: center; min-height: 48px; padding: 0 6px 0 14px; border-radius: 24px; background: var(--cx-panel); box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.cx-input { flex: 1; width: 100%; max-height: 120px; padding: 12px 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--cx-ink); font: inherit; font-size: 16px; /* 16 px: no zoom on iPhone */ }
.cx-input[hidden] { display: none; }
.cx-send { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--cx-go); color: #fff; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.2); touch-action: none; transition: transform .1s ease; }
.cx-send[hidden] { display: none; }
.cx-mic.is-rec { transform: scale(1.18); background: #dc2626; }
.cx-rec { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 48px; color: var(--cx-ink); }
.cx-rec[hidden] { display: none; }
.cx-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #dc2626; animation: cx-blink 1s ease-in-out infinite; }
@keyframes cx-blink { 50% { opacity: .2; } }
.cx-rec-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.cx-rec-hint { flex: 1; color: var(--cx-muted); font-size: 13px; transition: transform .05s linear; white-space: nowrap; overflow: hidden; }
.cx-rec-hint[hidden] { display: none; }

/* ---- call screen */
.cl { position: fixed; inset: 0; z-index: 1300; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 40px) 20px calc(env(safe-area-inset-bottom) + 36px);
  background: radial-gradient(circle at 50% 25%, #24324f, #14213d 65%); color: #fff; animation: cx-in .2s ease-out; }
.cl-top { display: grid; justify-items: center; gap: 6px; text-align: center; }
.cl-avatar { display: grid; place-items: center; width: 108px; height: 108px; margin-bottom: 10px; border-radius: 50%; background: #f97316; font-size: 44px; font-weight: 800; box-shadow: 0 0 0 0 rgba(249,115,22,.5); animation: cl-ring 1.6s ease-out infinite; }
@keyframes cl-ring { to { box-shadow: 0 0 0 28px rgba(249,115,22,0); } }
.cl h2 { margin: 0; font-size: 26px; } .cl-sub { margin: 0; color: #cbd5e1; }
.cl-status { margin: 10px 0 0; color: #e2e8f0; font-size: 16px; max-width: 320px; } .cl-timer { margin: 0; font-size: 20px; font-variant-numeric: tabular-nums; } .cl-timer[hidden] { display: none; }
.cl-tools { display: flex; gap: 24px; } .cl-tools [hidden] { display: none; }
.cl-btn { display: grid; justify-items: center; gap: 6px; width: 76px; padding: 14px 0 10px; border: 0; border-radius: 22px; background: rgba(255,255,255,.12); color: #fff; font: 600 12.5px inherit; cursor: pointer; }
.cl-btn.is-on { background: #fff; color: #14213d; } .cl-spk { font-size: 24px; line-height: 1; }
.cl-actions { display: flex; gap: 56px; }
.cl-end, .cl-accept { display: grid; place-items: center; width: 74px; height: 74px; border: 0; border-radius: 50%; color: #fff; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.cl-end { background: #dc2626; } .cl-end svg { transform: rotate(135deg); }
.cl-accept { background: #16a34a; animation: cl-glow 1.2s ease-out infinite; } .cl-accept[hidden] { display: none; }
@keyframes cl-glow { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.6), 0 8px 24px rgba(0,0,0,.35); } 100% { box-shadow: 0 0 0 22px rgba(22,163,74,0), 0 8px 24px rgba(0,0,0,.35); } }
.cl-note { margin: 0; max-width: 320px; text-align: center; color: #94a3b8; font-size: 12px; }

/* entry buttons on the tracking page / driver app */
.chat-entry { display: flex; gap: 8px; }
.chat-btn { position: relative; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 14px; border: 0; border-radius: 16px; background: #14213d; color: #fff; font: 700 15px/1 inherit; cursor: pointer; }
.chat-btn--call { background: #16a34a; }
.chat-badge { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: #dc2626; color: #fff; font: 800 12px/22px system-ui, sans-serif; text-align: center; box-shadow: 0 0 0 2px #fff; }
.chat-badge[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .cx, .cl, .cx-msg, .cl-avatar, .cl-accept, .cx-rec-dot { animation: none; } }

/* shop: « Message au client » in the order list */
.chat-mini { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.chat-mini .chat-badge { position: static; box-shadow: none; }
