/* Zyncochat operator inbox. Same colours as the agent app. */
:root {
  --primary: #0E5A4A;
  --primary-dark: #0A4236;
  --primary-soft: #DCEBE5;
  --ground: #F3F5F2;
  --chat-bg: #EDF1EE;
  --surface: #FFFFFF;
  --ink: #14201D;
  --muted: #4F5B57;
  --subtle: #6B7672;
  --border: #D5DCD9;
  --divider: #E3E8E5;
  --online: #1E9E6A;
  --badge: #B4570A;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --read: #2F80C0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 32, 29, .06), 0 4px 16px rgba(20, 32, 29, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 14px/1.45 "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------------------------------------------------------- login */
.login-body { display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--divider);
  border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--primary); color: #fff;
  display: inline-grid; place-items: center; flex: none;
}
.brand-mark.sm { width: 34px; height: 34px; border-radius: 10px; }
.brand-name { font-size: 16px; color: var(--muted); }
.brand-name b { color: var(--ink); }
.login-card h1 { font-size: 24px; margin: 0 0 4px; }
.login-sub { margin: 0 0 18px; color: var(--muted); }
.login-card label { display: block; font-weight: 500; margin: 14px 0 6px; }
.login-card input[type=email], .login-card input[type=password] {
  width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; background: #FBFCFB;
}
.login-card input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.login-card .check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--muted); }
.btn-primary {
  width: 100%; height: 46px; margin-top: 18px; border: 0; border-radius: 10px; background: var(--primary);
  color: #fff; font-weight: 700;
}
.btn-primary:hover { background: var(--primary-dark); }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; }

/* ---------------------------------------------------------------- layout */
.shell { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.shell.with-info { grid-template-columns: 340px minmax(0, 1fr) 300px; }
.list-pane { background: var(--surface); border-right: 1px solid var(--divider); display: flex; flex-direction: column; min-height: 0; }
.chat-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
.info-pane { background: var(--surface); border-left: 1px solid var(--divider); overflow-y: auto; }

/* ---------------------------------------------------------------- list */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 10px; }
.ws { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ws-text { min-width: 0; }
.ws-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-switch { border: 1px solid var(--border); border-radius: 8px; padding: 2px 6px; background: #fff; max-width: 190px; }
.ws-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--subtle); }
.ws-sub .dot { width: 7px; height: 7px; border-radius: 50%; background: #B9C2BE; }
.ws-sub.live .dot { background: var(--online); }
.me { display: flex; align-items: center; gap: 4px; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; border-radius: 50%; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; background: #fff;
  border: 1px solid var(--divider); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.menu-who { padding: 8px 10px; display: flex; flex-direction: column; border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.menu-who span { color: var(--subtle); font-size: 12px; word-break: break-all; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.menu-item:hover { background: var(--ground); }

.tabs { display: flex; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--divider); }
.tabs button {
  border: 0; background: none; padding: 9px 8px 10px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected=true] { color: var(--primary); border-bottom-color: var(--primary); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--badge); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.count:empty { display: none; }

.search { display: flex; align-items: center; gap: 8px; margin: 10px 12px; padding: 0 12px; height: 38px; border-radius: 10px; background: var(--ground); color: var(--subtle); }
.search input { flex: 1; border: 0; background: none; outline: none; color: var(--ink); min-width: 0; }

.chat-list { list-style: none; margin: 0; padding: 0 6px 10px; overflow-y: auto; flex: 1; }
.chat-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 9px 8px; border-radius: 12px; cursor: pointer; position: relative;
}
.chat-row:hover { background: var(--ground); }
.chat-row.active { background: var(--primary-soft); }
.chat-row .top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.chat-row .code { font-weight: 700; white-space: nowrap; }
.chat-row .name { color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.chat-row .preview { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.chat-row.unread .preview { color: var(--ink); font-weight: 500; }
.chat-row .preview.typing-now { color: var(--online); font-style: italic; }
.chat-row .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--subtle); }
.chat-row.unread .time { color: var(--badge); font-weight: 700; }
.chat-row .who { font-size: 11px; color: var(--subtle); background: var(--ground); border-radius: 6px; padding: 0 6px; }
.list-empty { text-align: center; color: var(--subtle); padding: 40px 16px; }

/* ---------------------------------------------------------------- avatars */
.avatar {
  --av-bg: var(--primary-soft); --av-fg: var(--primary);
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--av-bg) center/cover no-repeat; color: var(--av-fg); font-weight: 700; font-size: 15px; position: relative;
}
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.xs { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }
.avatar .on { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--online); border: 2px solid #fff; }

/* ---------------------------------------------------------------- chat */
.empty-chat { margin: auto; text-align: center; color: var(--muted); padding: 24px; max-width: 360px; }
.empty-chat h2 { color: var(--ink); margin: 12px 0 4px; font-size: 20px; }
.empty-art { width: 84px; height: 84px; border-radius: 24px; margin: 0 auto; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }

.chat { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--divider); min-height: 64px; }
.chat-head .back { display: none; }
.chat-title { flex: 1; min-width: 0; }
.chat-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { color: var(--subtle); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub.typing-now { color: var(--online); }
.chat-actions { display: flex; align-items: center; gap: 6px; }
.assign select { height: 36px; border: 1px solid var(--border); border-radius: 9px; padding: 0 8px; background: #fff; max-width: 170px; }
.btn-ghost { height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: #fff; font-weight: 500; white-space: nowrap; }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost.done { background: var(--primary); border-color: var(--primary); color: #fff; }
.icon-btn { width: 38px; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--muted); display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--ground); color: var(--ink); }
.btn-link { border: 0; background: none; color: var(--primary); font-weight: 500; padding: 6px 10px; border-radius: 8px; }
.btn-link:hover { background: rgba(14, 90, 74, .08); }

.messages { flex: 1; overflow-y: auto; padding: 14px 18px 8px; min-height: 0; }
.older { text-align: center; margin-bottom: 8px; }
.day { text-align: center; margin: 14px 0 10px; }
.day span { background: rgba(255,255,255,.85); color: var(--muted); font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 10px; }

.msg { display: flex; gap: 8px; margin: 2px 0; align-items: flex-end; }
.msg.agent { justify-content: flex-start; }
.msg.operator { justify-content: flex-end; }
.msg .spacer { width: 26px; flex: none; }
.bubble-wrap { max-width: min(72%, 560px); display: flex; flex-direction: column; }
.msg.operator .bubble-wrap { align-items: flex-end; }
.sender { font-size: 12px; font-weight: 700; color: var(--primary); margin: 8px 4px 2px; }
.bubble {
  position: relative; padding: 8px 12px 6px; border-radius: 16px; background: var(--surface); box-shadow: 0 1px 1px rgba(20,32,29,.05);
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg.agent .bubble { border-bottom-left-radius: 6px; }
.msg.operator .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 6px; }
.msg.operator.other .bubble { background: #2D6E60; }
.bubble a { color: inherit; }
.meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; margin-top: 2px; color: var(--subtle); }
.msg.operator .meta { color: #CFE5DC; }
.meta .tick.read { color: #8FD8FF; }
.bubble.media { padding: 4px; }
.bubble.media .meta { padding: 2px 6px 2px; }
/* Caption under a photo (or file) inside the same bubble. */
.bubble .caption { padding: 6px 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 320px; }
.bubble:not(.media) .caption { padding: 6px 0 0; }
.bubble img { display: block; max-width: 280px; max-height: 320px; width: 100%; object-fit: cover; border-radius: 12px; cursor: zoom-in; background: var(--divider); min-height: 80px; }
/* Voice message: same look as the agent app (play button, waveform you can click, time, speed). */
.voice { display: flex; align-items: center; gap: 12px; width: 248px; max-width: 100%; padding-top: 2px; white-space: normal; }
.v-play {
  width: 44px; height: 44px; border-radius: 50%; border: 0; flex: none; display: grid; place-items: center;
  background: var(--primary); color: #fff; box-shadow: 0 2px 4px rgba(10, 42, 34, .18); transition: transform .1s;
}
.v-play:active { transform: scale(.94); }
.v-play svg { margin-left: 3px; }
.voice.playing .v-play svg { margin-left: 0; }
.voice.loading .v-play { opacity: .7; }
.v-right { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.v-wave { height: 28px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; border-radius: 4px; }
.v-wave i { width: 3px; border-radius: 2px; background: #C3CFCA; }
.v-wave i.on { background: var(--primary); }
.v-under { display: flex; align-items: center; justify-content: space-between; }
.v-time { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--subtle); font-variant-numeric: tabular-nums; }
.v-time.on svg { color: var(--primary); }
.v-speed { border: 0; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.msg.operator .v-play { background: #fff; color: var(--primary); }
.msg.operator .v-wave i { background: rgba(255,255,255,.38); }
.msg.operator .v-wave i.on { background: #fff; }
.msg.operator .v-time { color: #CFE5DC; }
.msg.operator .v-time.on svg { color: #fff; }
.msg.operator .v-speed { background: rgba(255,255,255,.18); color: #fff; }
.bubble.voice-bubble { padding: 10px 12px 6px; }
.file-card { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 6px 4px; min-width: 200px; }
.file-card .ic { width: 38px; height: 38px; border-radius: 10px; background: rgba(0,0,0,.06); display: grid; place-items: center; flex: none; }
.msg.operator .file-card .ic { background: rgba(255,255,255,.16); }
.file-card .fn { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.reaction { position: absolute; bottom: -12px; right: 8px; display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--divider); background: #fff; border-radius: 12px; padding: 1px 6px; font-size: 14px; line-height: 1.3; box-shadow: var(--shadow); cursor: pointer; color: var(--ink); }
.reaction small { font-size: 11px; color: var(--subtle); }
.msg.has-reaction { margin-bottom: 12px; }
.msg-tools { align-self: center; display: flex; gap: 2px; }
.msg-tools .more { width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--subtle); display: grid; place-items: center; opacity: .35; }
@media (hover: hover) { .msg:hover .msg-tools .more { opacity: 1; } }
@media (hover: none) { .msg-tools .more { opacity: .7; } }
.msg-tools .more:hover, .msg-tools .more[aria-expanded=true], .msg-tools .more:focus-visible { opacity: 1; background: rgba(255,255,255,.9); color: var(--ink); }
.msg-menu {
  position: fixed; z-index: 40; min-width: 220px; background: #fff; border: 1px solid var(--divider);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.msg-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.msg-menu button:hover, .msg-menu button:focus-visible { background: var(--ground); }
.msg-menu button.danger { color: var(--danger); }
.msg-menu button small { display: block; font-weight: 400; color: var(--subtle); font-size: 12px; }
.msg.pending .bubble { opacity: .7; }
.msg.failed .bubble { box-shadow: 0 0 0 2px var(--danger); }
.fail { font-size: 12px; color: var(--danger); margin: 2px 4px; }
.fail button { border: 0; background: none; color: var(--danger); text-decoration: underline; padding: 0; }
.seen-line { text-align: right; font-size: 12px; color: var(--subtle); margin: 2px 4px 6px; }
.msg.has-reaction .seen-line { margin-top: 14px; }
.info-assign { padding: 4px 16px 16px; }
.info-assign label { display: block; color: var(--subtle); margin-bottom: 6px; }
.info-assign select { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 9px; padding: 0 8px; background: #fff; }

.typing { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; color: var(--subtle); font-size: 13px; }
.dots { display: inline-flex; gap: 3px; background: #fff; padding: 9px 11px; border-radius: 14px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #9AA6A1; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }

.banner { background: var(--danger-soft); color: var(--danger); padding: 8px 14px; font-size: 13px; text-align: center; cursor: pointer; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--divider); }
.composer textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 160px; border: 1px solid var(--border); border-radius: 21px;
  padding: 10px 16px; background: #F6F8F7; outline: none; line-height: 1.4;
}
.composer textarea:focus { border-color: var(--primary); background: #fff; }
.send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; display: grid; place-items: center; flex: none; }
.send:hover { background: var(--primary-dark); }
.send:disabled { background: #9DB7AF; cursor: default; }
/* Recording a voice note: replaces the reply box while recording. */
.recorder { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--divider); }
.rec-cancel { color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: rec-pulse 1.2s infinite; flex: none; }
.rec-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 44px; }
.rec-bars { flex: 1; height: 28px; display: flex; align-items: center; gap: 3px; overflow: hidden; }
.rec-bars i { width: 3px; height: 4px; border-radius: 2px; background: var(--primary); transition: height .08s; }
.rec-hint { color: var(--subtle); font-size: 13px; white-space: nowrap; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } .rec-bars i { transition: none; } }
@media (max-width: 520px) { .rec-hint { display: none; } }
.drop-hint {
  position: absolute; inset: 64px 0 0; background: rgba(14, 90, 74, .12); border: 2px dashed var(--primary);
  display: grid; place-items: center; font-weight: 700; color: var(--primary); font-size: 18px; pointer-events: none;
}

/* ---------------------------------------------------------------- info */
.info-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--divider); }
.info-head h2 { margin: 0; font-size: 15px; }
.info-card { padding: 20px 16px; text-align: center; border-bottom: 1px solid var(--divider); }
.info-card .avatar { margin: 0 auto 10px; }
.info-card .big { font-weight: 700; font-size: 18px; }
.info-card .small { color: var(--subtle); }
.facts { margin: 0; padding: 8px 16px 16px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--divider); }
.facts dt { color: var(--subtle); }
.facts dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; background: var(--ground); color: var(--muted); }
.pill.ok { background: var(--primary-soft); color: var(--primary); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- image viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(6, 12, 10, .94); display: grid; place-items: center; padding: 64px 72px; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain; }
.viewer .v-top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; color: #fff; background: linear-gradient(rgba(0,0,0,.5), transparent); }
.viewer .v-top b { display: block; }
.viewer .v-top span { font-size: 12px; color: #CFE5DC; }
.viewer .v-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.viewer .v-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.viewer .v-nav:hover, .viewer .v-close:hover { background: rgba(255,255,255,.26); }
.viewer .v-nav.prev { left: 14px; }
.viewer .v-nav.next { right: 14px; }
.viewer .v-caption { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 24px 16px; background: rgba(0,0,0,.6); color: #fff; max-height: 45vh; overflow: auto; }
.viewer .v-caption p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 820px; margin-inline: auto; }
.viewer .v-caption.short p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.viewer .v-more { display: block; max-width: 820px; margin: 6px auto 0; border: 0; background: none; color: #9FE3C8; font-weight: 700; padding: 0; cursor: pointer; text-align: left; width: 100%; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 1180px) {
  .shell.with-info { grid-template-columns: 320px minmax(0, 1fr); }
  .shell.with-info .info-pane { position: fixed; right: 0; top: 0; bottom: 0; width: min(320px, 100%); z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 860px) {
  .shell, .shell.with-info { grid-template-columns: 1fr; }
  .chat-pane { display: none; }
  .shell.show-chat .list-pane { display: none; }
  .shell.show-chat .chat-pane { display: flex; }
  .chat-head .back { display: inline-grid; }
  .chat-head { padding: 8px 8px; gap: 6px; }
  .chat-actions .assign { display: none; }
  .btn-ghost { padding: 0 10px; }
  .bubble-wrap { max-width: 84%; }
  .messages { padding: 12px 10px 6px; }
  .bubble img { max-width: 220px; }
}

/* Replies: a quote on top of a bubble, and the "Replying to" bar over the message box. */
.quote { display: flex; align-items: stretch; gap: 8px; width: 100%; max-width: 320px; text-align: left; border: 0; cursor: pointer;
  background: rgba(14, 90, 74, 0.07); border-left: 3px solid var(--primary); border-radius: 8px; padding: 6px 8px; margin: 0 0 6px; font: inherit; color: inherit; }
.quote.agent { border-left-color: #B4570A; background: rgba(180, 87, 10, 0.07); }
.bubble.media .quote { margin: 0 0 4px; }
.quote .q-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.quote b { font-size: 12px; color: var(--primary); }
.quote.agent b { color: #B4570A; }
.quote .q-text > span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.quote img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex: none; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
.reply-bar[hidden] { display: none; }
.reply-bar .quote { max-width: none; margin: 0; cursor: default; }
.reply-x { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--subtle); cursor: pointer; padding: 4px 8px; }
.msg.flash .bubble { animation: zc-flash 1.2s ease; }
@keyframes zc-flash { 0%, 60% { box-shadow: 0 0 0 3px rgba(242, 163, 58, 0.7); } 100% { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .msg.flash .bubble { animation: none; outline: 3px solid rgba(242, 163, 58, 0.7); } }

/* Pinned message bar at the top of the chat. */
.pin-bar { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-bottom: 1px solid var(--divider); background: #fff; padding: 8px 16px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.pin-bar[hidden] { display: none; }
.pin-bar:hover { background: var(--ground); }
.pin-bar .pin-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pin-bar b { font-size: 12px; color: var(--primary); }
.pin-bar .pin-text > span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-bar img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }

/* Quick reactions on top of the message menu (and alone from the 😊 button). */
.menu-reacts { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.msg-menu.react-only .menu-reacts { border-bottom: 0; margin-bottom: 0; padding-bottom: 2px; }
.msg-menu .menu-reacts button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 22px; border-radius: 50%; }
.msg-menu .menu-reacts button.on { background: var(--primary-soft); }
.msg-menu .menu-reacts button.plus { font-size: 22px; color: var(--muted); background: var(--ground); }

/* Every emoji: search, groups, recently used. */
.emoji-pop { position: fixed; z-index: 60; width: 352px; max-width: calc(100vw - 16px); height: 380px; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--divider); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.ep-search { padding: 8px; }
.ep-search input { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; background: var(--ground); font: inherit; }
.ep-tabs { display: flex; justify-content: space-between; padding: 0 6px 4px; border-bottom: 1px solid var(--divider); }
.ep-tabs button { border: 0; background: none; font-size: 18px; padding: 4px 3px; border-radius: 8px; cursor: pointer; }
.ep-tabs button:hover { background: var(--ground); }
.ep-grid { flex: 1; overflow-y: auto; padding: 4px 6px 8px; position: relative; }
.ep-grid h3 { font-size: 12px; font-weight: 500; color: var(--subtle); margin: 8px 4px 4px; }
.ep-cells { display: grid; grid-template-columns: repeat(8, 1fr); }
.ep-cells button { border: 0; background: none; font-size: 24px; height: 40px; border-radius: 8px; cursor: pointer; padding: 0; }
.ep-cells button:hover, .ep-cells button:focus-visible { background: var(--primary-soft); }
.ep-empty { color: var(--subtle); text-align: center; margin: 24px 0; }

/* Check photos / files before sending, with a caption. */
.send-preview { position: fixed; inset: 0; z-index: 55; background: rgba(6, 12, 10, .72); display: grid; place-items: center; padding: 24px; }
.sp-card { width: min(720px, 100%); max-height: 100%; display: flex; flex-direction: column; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.sp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--divider); }
.sp-head .v-close { background: var(--ground); color: var(--ink); width: 36px; height: 36px; border: 0; border-radius: 50%; font-size: 22px; cursor: pointer; }
.sp-main { flex: 1; min-height: 220px; max-height: 56vh; display: grid; place-items: center; background: #0E1A16; }
.sp-main img { max-width: 100%; max-height: 56vh; object-fit: contain; }
.sp-file { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #fff; padding: 40px; }
.sp-file small { color: #CFE5DC; }
.sp-strip { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; border-bottom: 1px solid var(--divider); }
.sp-thumb { position: relative; flex: none; }
.sp-thumb > button:first-child { width: 56px; height: 56px; border-radius: 10px; border: 2px solid transparent; padding: 0; overflow: hidden; background: var(--ground); display: grid; place-items: center; cursor: pointer; }
.sp-thumb.on > button:first-child { border-color: var(--primary); }
.sp-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sp-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 13px; line-height: 1; cursor: pointer; }
.sp-add { flex: none; width: 56px; height: 56px; border-radius: 10px; border: 2px dashed var(--border); background: none; font-size: 26px; color: var(--muted); cursor: pointer; }
.sp-foot { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; }
.sp-foot textarea { flex: 1; min-height: 42px; max-height: 140px; resize: vertical; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font: inherit; background: var(--ground); }
.sp-foot .send { position: relative; }
.sp-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: #fff; color: var(--primary-dark, #0A4236); font-size: 11px; font-weight: 700; display: grid; place-items: center; box-shadow: var(--shadow); }

/* Phones: photo viewer, send preview and menus use the whole screen. */
@media (max-width: 600px) {
  .viewer { padding: 60px 6px 70px; }
  .viewer .v-nav { width: 40px; height: 40px; font-size: 28px; background: rgba(0,0,0,.35); }
  .viewer .v-nav.prev { left: 6px; }
  .viewer .v-nav.next { right: 6px; }
  .viewer .v-caption { padding: 10px 14px 14px; }
  .send-preview { padding: 8px; }
  .sp-main, .sp-main img { max-height: 46vh; }
  .msg-menu { max-width: calc(100vw - 16px); }
  .menu-reacts { flex-wrap: wrap; }
}

/* Reply quote inside a bubble: a small thumbnail (not the big photo style), readable on the green bubble too. */
.bubble .quote img { width: 40px; height: 40px; min-height: 0; max-width: none; max-height: none; border-radius: 6px; cursor: inherit; flex: none; }
.msg.operator .bubble .quote { background: rgba(255, 255, 255, 0.16); border-left-color: #CFE5DC; }
.msg.operator .bubble .quote b { color: #fff; }
.msg.operator .bubble .quote .q-text > span { color: #E3F1EC; }
.msg.operator .bubble .quote:hover { background: rgba(255, 255, 255, 0.24); }
.msg.agent .bubble .quote:hover { background: rgba(14, 90, 74, 0.12); }
.bubble .quote { align-items: center; }
