/* Live chat: the Chat button (assets/chat.js) and Admin → Support chats. FareFinders colours (light theme). */
.chat, [data-cs], .admin-live, .al-alerts {
  --c-bg: #ffffff; --c-2: #f1f5f9; --c-line: #e2e8f0; --c-text: #0f172a; --c-mute: #64748b;
  --c-brand: var(--color-brand-600, #1c54f0); --c-brand-dark: var(--color-brand-700, #1640d9); --c-me: var(--color-brand-50, #eef5ff); --c-ok: #059669;
  --c-font: var(--font-sans, system-ui, sans-serif);
}
.chat-fab { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 20px 0 16px; border: 0; border-radius: 999px;
  background: var(--c-brand); color: #fff; font: 700 15px var(--c-font); cursor: pointer; box-shadow: 0 10px 28px rgba(28, 84, 240, .35); transition: transform .15s, background .15s; }
.chat-fab:hover { background: var(--c-brand-dark); transform: translateY(-1px); }
.chat-fab:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(28, 84, 240, .3); }
.chat-fab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.chat-dot { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: #dc2626; color: #fff; font: 800 11.5px/20px var(--c-font); text-align: center; box-shadow: 0 0 0 2px #fff; }
.chat-dot[hidden] { display: none; }
.chat-panel { position: fixed; right: 18px; bottom: 78px; z-index: 61; width: 370px; max-width: calc(100vw - 32px); height: 540px; max-height: calc(100vh - 100px);
  display: flex; flex-direction: column; border-radius: 18px; background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-line); box-shadow: 0 24px 60px rgba(15, 23, 42, .22); overflow: hidden; font-family: var(--c-font); }
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: linear-gradient(135deg, var(--color-brand-800, #1935b0), var(--c-brand)); color: #fff; }
.chat-title { display: grid; gap: 2px; min-width: 0; }
.chat-title b { font-size: 15px; }
.chat-status { font-size: 12.5px; color: rgba(255, 255, 255, .8); display: inline-flex; align-items: center; gap: 6px; }
.chat-status.on { color: #fff; }
.chat-status.on::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .3); }
.chat-acts { display: flex; align-items: center; gap: 6px; }
.chat-x, .chat-end { height: 32px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; font: 600 12.5px var(--c-font); }
.chat-x { width: 32px; font-size: 14px; }
.chat-end { padding: 0 10px; }
.chat-x:hover, .chat-end:hover { background: rgba(255, 255, 255, .22); }
.chat-end[hidden] { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; background: #f8fafc; }
.cm { max-width: 85%; display: grid; gap: 3px; }
.cm p { margin: 0; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm small { font-size: 11px; color: var(--c-mute); padding: 0 4px; font-variant-numeric: tabular-nums; }
.cm-them { align-self: flex-start; }
.cm-them p { background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-line); border-bottom-left-radius: 4px; }
.cm-me { align-self: flex-end; text-align: right; }
.cm-me p { background: var(--c-brand); color: #fff; border-bottom-right-radius: 4px; text-align: left; }
.cm-hi .chat-help { font-size: 12.5px; color: var(--c-brand); padding: 0 4px; text-decoration: underline; }
.cm .cm-receipt { font-size: 11px; color: var(--c-mute); padding: 0 4px; }
.cm .cm-receipt.seen { color: var(--c-ok); font-weight: 600; }
.chat-form { display: grid; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--c-line); background: var(--c-bg); }
.chat-form[hidden] { display: none; }
.chat-who { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chat-form input, .chat-form textarea, .chat-rate textarea { width: 100%; box-sizing: border-box; padding: 9px 11px; border-radius: 10px; border: 1px solid #cbd5e1; background: #fff; color: var(--c-text); font: 14px var(--c-font); resize: none; }
.chat-form input:focus, .chat-form textarea:focus, .chat-rate textarea:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px rgba(28, 84, 240, .15); }
.chat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.chat-send, .chat-btn { height: 42px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--c-brand); color: #fff; font: 700 14px var(--c-font); cursor: pointer; }
.chat-send:hover, .chat-btn:hover { background: var(--c-brand-dark); }
.chat-send:disabled, .chat-btn:disabled { opacity: .5; cursor: default; }
.chat-btn-ghost { height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--c-line); background: #fff; color: var(--c-mute); font: 600 14px var(--c-font); cursor: pointer; }
.chat-btn-ghost:hover { color: var(--c-text); }
.chat-err { margin: 0; font-size: 13px; color: #dc2626; }
.chat-err[hidden] { display: none; }
.chat-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.chat-typing, .cs-typing { margin: 0; font-size: 12.5px; color: var(--c-mute); display: flex; align-items: center; gap: 6px; }
.chat-typing { padding: 4px 16px 8px; background: #f8fafc; }
.cs-typing { padding: 0 18px 10px; }
.chat-typing[hidden], .cs-typing[hidden] { display: none; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .35; animation: chat-dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes chat-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
/* End chat and the rating */
.chat-rate { display: grid; gap: 10px; padding: 14px 16px 16px; border-top: 1px solid var(--c-line); text-align: center; justify-items: center; background: var(--c-bg); }
.chat-rate b { font-size: 15px; }
.chat-rate-note { margin: 0; font-size: 12.5px; color: var(--c-mute); }
.chat-stars { display: flex; gap: 4px; }
.chat-stars button { width: 38px; height: 38px; border: 0; background: none; font-size: 28px; line-height: 1; color: #e2e8f0; cursor: pointer; -webkit-text-stroke: 1px #94a3b8; transition: transform .1s; }
.chat-stars button.on { color: #f5b301; -webkit-text-stroke: 0; }
.chat-stars button:hover { transform: scale(1.12); }
.chat-stars button:focus-visible { outline: 2px solid var(--c-brand); border-radius: 8px; }
.chat-rate-row { display: flex; gap: 8px; justify-content: center; }
/* "Need help? 👋" above the Chat button */
.chat-hint { position: fixed; right: 18px; bottom: 78px; z-index: 60; display: flex; align-items: flex-start; gap: 4px; max-width: 250px; padding: 4px; border-radius: 14px;
  background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-line); box-shadow: 0 14px 34px rgba(15, 23, 42, .18); animation: chat-hint-in .35s ease-out both; font-family: var(--c-font); }
.chat-hint::after { content: ""; position: absolute; right: 30px; bottom: -7px; width: 12px; height: 12px; background: var(--c-bg); border-right: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); transform: rotate(45deg); }
.chat-hint-body { display: grid; gap: 2px; padding: 8px 4px 8px 10px; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font-family: var(--c-font); }
.chat-hint-body b { font-size: 14px; }
.chat-hint-body span { font-size: 12.5px; color: var(--c-mute); line-height: 1.4; }
.chat-hint-body:hover b { color: var(--c-brand); }
.chat-hint-x { flex: none; width: 26px; height: 26px; border: 0; border-radius: 8px; background: none; color: var(--c-mute); cursor: pointer; font-size: 12px; }
.chat-hint-x:hover { background: var(--c-2); color: var(--c-text); }
@keyframes chat-hint-in { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-hint { animation: none; } .dots i { animation: none; opacity: .7; } }
@media (max-width: 560px) {
  .chat-fab span { display: none; }
  .chat-fab { padding: 0; width: 52px; height: 52px; justify-content: center; }
  .chat-panel { right: 8px; left: 8px; bottom: 80px; width: auto; max-width: none; height: min(560px, calc(100vh - 100px)); }
  .chat-who { grid-template-columns: 1fr; }
  .chat-hint::after { right: 20px; }
  /* Sign-in pages: the button sits at the end of the page instead of floating over the form */
  .chat-auth { display: flex; justify-content: center; padding: 4px 16px 28px; }
  .chat-auth .chat-fab { position: static; width: auto; height: 44px; padding: 0 20px 0 16px; box-shadow: none; }
  .chat-auth .chat-fab span { display: inline; }
  body:has(.chat:not(.chat-auth)) { padding-bottom: 76px; }
}

/* Admin → Support chats */
.cs-wrap { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.cs-card { background: #fff; border: 1px solid var(--c-line); border-radius: 14px; overflow: hidden; }
.cs-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 84px; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--c-line); color: var(--c-text); text-decoration: none; }
.cs-row:first-child { border-top: 0; }
.cs-row:hover { background: #f8fafc; }
.cs-row.cur { background: var(--c-me); }
.cs-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--c-brand); color: #fff; font: 700 12px var(--c-font); }
.cs-main { min-width: 0; display: grid; gap: 2px; }
.cs-main b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-main span { font-size: 12.5px; color: var(--c-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-row.unread .cs-main b { font-weight: 800; }
.cs-row.unread .cs-main span { color: #334155; }
.cs-when { display: grid; gap: 4px; justify-items: start; font-size: 12px; color: var(--c-mute); font-variant-numeric: tabular-nums; padding-left: 12px; border-left: 1px solid var(--c-line); }
.cs-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #dc2626; color: #fff; font: 800 11px/20px var(--c-font); text-align: center; }
.cs-empty { margin: 0; padding: 22px 18px; color: var(--c-mute); font-size: 14px; }
.cs-conv { display: flex; flex-direction: column; min-height: 440px; }
.cs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--c-line); }
.cs-back { display: none; font-size: 13px; color: var(--c-brand); text-decoration: none; flex-basis: 100%; font-weight: 600; }
.cs-who { display: grid; gap: 3px; min-width: 0; }
.cs-who b { font-size: 16px; }
.cs-who > span { font-size: 12.5px; color: var(--c-mute); overflow-wrap: anywhere; }
.cs-who a { color: #334155; }
.cs-type { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--c-2); color: #334155; font-weight: 600; font-size: 11.5px; }
.cs-here i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c-ok); margin-right: 5px; vertical-align: 1px; }
.cs-here[hidden] { display: none; }
.cs-acts { display: flex; gap: 6px; }
.cs-acts form { margin: 0; }
.cs-btn { height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--c-line); background: #fff; color: #334155; font: 600 13px var(--c-font); cursor: pointer; }
.cs-btn:hover { background: #f8fafc; }
.cs-btn.danger { color: #dc2626; border-color: #fecaca; }
.cs-btn.danger:hover { background: #fef2f2; }
.cs-bookings { padding: 8px 18px; border-bottom: 1px solid var(--c-line); font-size: 12.5px; color: var(--c-mute); }
.cs-bookings a { color: var(--c-brand); font-weight: 600; font-family: ui-monospace, monospace; margin-right: 8px; }
.cs-msgs { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; max-height: 520px; overflow-y: auto; background: #f8fafc; }
.cs-msgs .cm { max-width: 75%; }
.cs-reply { display: grid; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--c-line); }
.cs-reply textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid #cbd5e1; background: #fff; color: var(--c-text); font: 14px var(--c-font); resize: vertical; }
.cs-reply textarea:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px rgba(28, 84, 240, .15); }
.cs-send { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--c-mute); }
.cs-stars { color: #f5b301; letter-spacing: 1px; font-size: 12px; }
.cs-ended { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--c-line); background: #fffbeb; font-size: 13px; color: #334155; }
.cs-rating .cs-stars { font-size: 14px; }
@media (max-width: 900px) {
  .cs-wrap { grid-template-columns: 1fr; }
  .cs-wrap.has-thread .cs-list { display: none; }
  .cs-wrap:not(.has-thread) .cs-conv { display: none; }
  .cs-back { display: block; }
  .cs-msgs .cm { max-width: 88%; }
}

/* ---------- Admin: live chat alerts on every admin page (assets/admin-chat.js) ---------- */
.al-ctl { border: 0; border-radius: 999px; padding: 5px 11px; background: rgba(255, 255, 255, .1); color: #d9e8ff; font: 600 12px var(--font-sans, system-ui, sans-serif); cursor: pointer; white-space: nowrap; transition: background .15s; }
.al-ctl:hover:not(:disabled) { background: rgba(255, 255, 255, .2); color: #fff; }
.al-alerts { position: relative; }
.al-menu { position: absolute; left: 0; top: calc(100% + 8px); z-index: 85; width: 260px; display: grid; gap: 6px; padding: 12px; border-radius: 14px; background: #fff;
  border: 1px solid var(--c-line); box-shadow: 0 18px 40px -12px rgba(15, 29, 79, .35); font-family: var(--c-font); animation: al-up .18s ease; }
.al-menu[hidden] { display: none; }
.al-menu b { font-size: 13px; color: var(--c-text); }
.al-opt { text-align: left; border: 1px solid var(--c-line); border-radius: 10px; padding: 8px 12px; background: #fff; color: var(--c-text); font: 600 13px var(--c-font); cursor: pointer; }
.al-opt:hover:not(:disabled) { background: var(--c-2); }
.al-opt:disabled { cursor: default; color: var(--c-mute); }
.al-opt[hidden] { display: none; }
.al-note { margin: 0; font-size: 12px; line-height: 1.45; color: var(--c-mute); }
.al-toasts { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 10px; width: min(360px, calc(100vw - 24px)); }
.admin-live:has(.al-chat) .al-toasts { right: 396px; }
.al-toast { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 14px; border-radius: 16px; background: #fff; border: 1px solid var(--c-line);
  box-shadow: 0 18px 40px -12px rgba(15, 29, 79, .35); font-family: var(--c-font); animation: al-in .3s cubic-bezier(.2, .7, .2, 1); }
.al-av { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--c-brand); color: #fff; font: 700 13px var(--c-font); }
.al-main { min-width: 0; display: grid; gap: 4px; }
.al-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.al-top b { font-size: 14px; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-top small { font-size: 11.5px; color: var(--c-mute); white-space: nowrap; }
.al-toast p { margin: 0; font-size: 13.5px; line-height: 1.45; color: #334155; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.al-acts { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.al-reply { border: 0; border-radius: 10px; padding: 7px 16px; background: var(--c-brand); color: #fff; font: 700 13px var(--c-font); cursor: pointer; }
.al-reply:hover { background: var(--c-brand-dark); }
.al-x { border: 0; background: none; width: 30px; height: 30px; border-radius: 50%; color: var(--c-mute); font-size: 20px; line-height: 1; cursor: pointer; }
.al-x:hover { background: var(--c-2); color: var(--c-text); }
.al-chat { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; width: min(360px, calc(100vw - 24px)); height: min(500px, calc(100vh - 100px));
  background: #fff; border: 1px solid var(--c-line); border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px -16px rgba(15, 29, 79, .45); font-family: var(--c-font); animation: al-up .28s cubic-bezier(.2, .7, .2, 1); }
.al-head { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 12px 12px 12px 14px; background: var(--color-brand-900, #1a328a); color: #fff; }
.al-head .al-av { background: rgba(255, 255, 255, .15); }
.al-who { min-width: 0; display: grid; }
.al-who b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-who small { font-size: 11.5px; color: #bcd7ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-full { font-size: 12px; font-weight: 600; color: #e9c46a; text-decoration: none; white-space: nowrap; }
.al-full:hover { text-decoration: underline; }
.al-head .al-x { color: #d9e8ff; }
.al-head .al-x:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.al-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px; background: #f8fafc; }
.al-typing { margin: 0; padding: 4px 14px; font-size: 12px; color: var(--c-mute); background: #f8fafc; }
.al-typing[hidden], .al-err[hidden] { display: none; }
.al-err { margin: 0; padding: 6px 14px; font-size: 12.5px; color: #b91c1c; background: #fef2f2; }
.al-send { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--c-line); margin: 0; }
.al-send textarea { flex: 1; resize: none; border: 1px solid var(--c-line); border-radius: 12px; padding: 9px 12px; font: 14px/1.4 var(--c-font); color: var(--c-text); max-height: 120px; }
.al-send textarea:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px rgba(28, 84, 240, .15); }
.al-send button { border: 0; border-radius: 12px; padding: 10px 16px; background: var(--c-brand); color: #fff; font: 700 14px var(--c-font); cursor: pointer; }
.al-send button:disabled { opacity: .6; cursor: default; }
@keyframes al-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes al-up { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .admin-live:has(.al-chat) .al-toasts { right: 12px; bottom: auto; top: 76px; }
  .al-toasts, .al-chat { right: 12px; bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) { .al-toast, .al-chat { animation: none; } }
