/* WisTech Customer Care – fiber navy + signal orange */
:root {
  --navy: #0E2A47; --navy-2: #163B61; --navy-3: #21507F;
  --orange: #F07D1A; --orange-dark: #C8620A; --orange-soft: #FFE9D4;
  --paper: #EDF1F5; --card: #FFFFFF; --ink: #172434; --muted: #5E6E80; --line: #DCE3EA;
  --ok: #1E9E6A; --danger: #D9363E;
  --font: "Noto Sans", "Noto Sans Devanagari", "Noto Sans Bengali", "Segoe UI", Roboto, system-ui, sans-serif;
  --r-bubble: 16px; --r-card: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--navy); -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ---------- layout ---------- */
.shell { height: 100vh; height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
.side { display: none; }
.app { position: relative; display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--paper); overflow: hidden; }

@media (min-width: 960px) {
  body:not(.embed) .shell {
    grid-template-columns: 340px minmax(0, 760px); justify-content: center; gap: 32px; padding: 28px;
    background:
      repeating-linear-gradient(115deg, rgba(255,255,255,.035) 0 1px, transparent 1px 22px),
      radial-gradient(1200px 600px at 10% 0%, var(--navy-3) 0%, transparent 60%), var(--navy);
  }
  body:not(.embed) .side { display: flex; }
  body:not(.embed) .app { border-radius: var(--r-card); box-shadow: 0 24px 60px rgba(3, 14, 28, .45); }
}

/* ---------- side panel ---------- */
.side { flex-direction: column; gap: 18px; color: #DCE6F1; padding: 8px 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 44px; height: 44px; border-radius: 12px; background: var(--orange); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 22px; box-shadow: 0 0 0 4px rgba(240,125,26,.18); }
.brand-name { font-weight: 800; font-size: 20px; color: #fff; letter-spacing: .2px; }
.brand-sub { font-size: 13px; color: #A9BCD0; }
.side-title { font-size: 26px; line-height: 1.25; font-weight: 700; color: #fff; margin: 10px 0 0; }
.side-text { margin: 0; font-size: 14.5px; line-height: 1.55; color: #B7C7D8; max-width: 34ch; }
.actions { display: grid; gap: 8px; }
.action { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: #fff; font-size: 15px; cursor: pointer; transition: background .15s, border-color .15s; }
.action:hover:not(:disabled) { background: rgba(240,125,26,.16); border-color: rgba(240,125,26,.55); }
.action:disabled { opacity: .55; cursor: not-allowed; }
.ai { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: rgba(255,255,255,.08); font-size: 16px; flex: none; }
.actions-hint { margin: -8px 0 0; font-size: 12.5px; color: #8FA6BE; }
.self { border-top: 1px solid rgba(255,255,255,.1); padding-top: 16px; display: grid; gap: 8px; }
.self-title { font-size: 14px; font-weight: 700; color: #fff; }
.self-link { display: flex; gap: 12px; align-items: center; color: #fff; text-decoration: none; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.05); }
.self-link:hover { background: rgba(255,255,255,.1); }
.self-link small { display: block; color: #A9BCD0; font-size: 12.5px; font-weight: 400; margin-top: 1px; }
.sl-icon { font-size: 20px; }
.self-note { font-size: 12.5px; color: #8FA6BE; line-height: 1.5; }
.side-foot { margin-top: auto; font-size: 12.5px; color: #8FA6BE; line-height: 1.5; }

/* ---------- header ---------- */
.bar { position: relative; display: flex; align-items: center; gap: 12px; background: var(--navy); color: #fff; padding: 10px 12px 12px; padding-top: calc(10px + env(safe-area-inset-top)); flex: none; }
.avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--orange); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 19px; flex: none; }
.who { flex: 1; min-width: 0; }
.name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { font-size: 12.5px; color: #A9C2DA; display: flex; align-items: center; gap: 6px; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: #3DDC97; box-shadow: 0 0 0 3px rgba(61,220,151,.18); }
.icon-btn { background: none; border: 0; color: inherit; font-size: 18px; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(255,255,255,.1); }
.call-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 19px; border: 1.5px solid rgba(240,125,26,.8); background: rgba(240,125,26,.12); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.call-btn:hover { background: var(--orange); border-color: var(--orange); }
/* the fiber: a thin strand under the header; light runs through it while the bot works */
.fiber { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(240,125,26,.25); overflow: hidden; }
.fiber::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; left: -35%; background: linear-gradient(90deg, transparent, #FFB36B, var(--orange), transparent); opacity: 0; }
.fiber.active::after { opacity: 1; animation: light 1.1s linear infinite; }
@keyframes light { to { left: 100%; } }

/* ---------- messages ---------- */
#chat { flex: 1; overflow-y: auto; padding: 14px clamp(10px, 4%, 28px) 10px; display: flex; flex-direction: column; gap: 3px; scroll-behavior: smooth;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(14,42,71,.06) 1px, transparent 1.2px); background-size: 18px 18px; }
.day-chip, .sys-chip { align-self: center; background: var(--card); color: var(--muted); font-size: 12px; padding: 5px 12px; border-radius: 10px; margin: 6px 0; box-shadow: 0 1px 1px rgba(14,42,71,.08); text-align: center; max-width: 92%; }
.msg { position: relative; max-width: min(80%, 560px); padding: 8px 11px 7px; border-radius: var(--r-bubble); font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(14,42,71,.08); margin: 2px 0; }
.msg.in { align-self: flex-start; background: var(--card); }
.msg.out { align-self: flex-end; background: var(--orange-soft); }
.msg.in.first { border-top-left-radius: 4px; margin-top: 8px; }
.msg.out.first { border-top-right-radius: 4px; margin-top: 8px; }
.msg a { color: #0B63B5; text-decoration: underline; text-underline-offset: 2px; }
.msg.secret { background: #FFF7DD; border: 1.5px dashed #E0A800; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15.5px; }
.meta { float: right; margin: 7px 0 -3px 10px; font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.ticks { letter-spacing: -3px; color: #93A1AF; }
.ticks.read { color: #2C8FE0; }
.speak { border: 0; background: none; cursor: pointer; font-size: 12px; padding: 0 2px; opacity: .5; }
.speak:hover { opacity: 1; }
.voice-note { display: flex; align-items: center; gap: 8px; min-width: 170px; }
.voice-note .wave { flex: 1; height: 18px; background: repeating-linear-gradient(90deg, var(--orange-dark) 0 2px, transparent 2px 5px); border-radius: 2px; opacity: .55; }
.heard { display: block; font-size: 12.5px; color: var(--muted); font-style: italic; margin-top: 3px; }

/* quick replies */
.quick { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 6px; max-width: min(92%, 600px); margin: 4px 0 6px; }
.quick button { background: var(--card); border: 1.5px solid #C9D5E1; color: var(--navy); font-size: 14.5px; font-weight: 600; min-height: 40px; padding: 8px 14px; border-radius: 20px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.quick button:hover { border-color: var(--orange); color: var(--orange-dark); }
.quick button:active { background: var(--orange); color: #fff; border-color: var(--orange); }

.typing { align-self: flex-start; background: var(--card); border-radius: var(--r-bubble); border-top-left-radius: 4px; padding: 11px 14px; margin: 8px 0 2px; box-shadow: 0 1px 1px rgba(14,42,71,.08); }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 1.5px; background: #9AA8B6; border-radius: 50%; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.err { align-self: center; background: #FDECEC; color: #9B1C1C; font-size: 13px; padding: 7px 12px; border-radius: 10px; margin: 6px 0; text-align: center; }

.to-bottom { position: absolute; right: 16px; bottom: 84px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card); color: var(--navy); font-size: 18px; box-shadow: 0 4px 12px rgba(14,42,71,.2); cursor: pointer; z-index: 2; }

/* ---------- composer ---------- */
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); flex: none; background: var(--paper); border-top: 1px solid rgba(14,42,71,.06); }
.field, .recbar { flex: 1; background: var(--card); border-radius: 24px; display: flex; align-items: center; min-height: 48px; padding: 0 16px; box-shadow: 0 1px 2px rgba(14,42,71,.1); border: 1.5px solid transparent; }
.field:focus-within { border-color: rgba(240,125,26,.6); }
.field input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 12px 0; background: transparent; color: var(--ink); min-width: 0; }
.field input:focus-visible { outline: none; }
.recbar { gap: 10px; padding: 0 10px; color: var(--muted); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
.rec-hint { font-size: 13px; }
.icon-btn.danger { color: var(--danger); width: 34px; height: 34px; font-size: 17px; }
.fab { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--orange); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: 0 2px 6px rgba(200,98,10,.4); transition: transform .1s; }
.fab:active { transform: scale(.94); }
.fab.recording { background: var(--ok); box-shadow: 0 2px 6px rgba(30,158,106,.4); }

/* ---------- voice call ---------- */
.call { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; color: #EAF1F8;
  background: radial-gradient(700px 500px at 50% 35%, var(--navy-3) 0%, transparent 70%), linear-gradient(180deg, var(--navy-2), #081A2D);
  padding: calc(26px + env(safe-area-inset-top)) 18px calc(26px + env(safe-area-inset-bottom)); }
.call-top { text-align: center; }
.call-name { font-size: 20px; font-weight: 700; }
.call-sub { font-size: 13px; color: #A9C2DA; margin-top: 4px; }
.call-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; min-height: 0; }
.ring { width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.ring::before, .ring::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.ring.listening::before { border-color: rgba(61,220,151,.75); animation: pulse 1.4s infinite; }
.ring.speaking::before { border-color: rgba(240,125,26,.8); animation: pulse 1s infinite; }
.ring.thinking::after { border-color: rgba(255,255,255,.2); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar.big { width: 112px; height: 112px; border-radius: 32px; font-size: 46px; }
.call-state { font-size: 15px; color: #CFE0F0; min-height: 20px; }
.caption { font-size: 16px; line-height: 1.5; max-width: 520px; max-height: 32vh; overflow-y: auto; white-space: pre-wrap; background: rgba(255,255,255,.07); border-radius: 14px; padding: 12px 16px; }
.caption:empty, .you:empty { display: none; }
.you { font-size: 13.5px; color: #A9C2DA; font-style: italic; max-width: 520px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 560px; }
.chips button { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 20px; padding: 9px 15px; font-size: 14px; cursor: pointer; }
.chips button:hover { background: rgba(240,125,26,.3); border-color: var(--orange); }
.call-controls { display: flex; justify-content: center; gap: 18px; flex: none; }
.cbtn { width: 64px; height: 64px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 22px; gap: 1px; }
.cbtn small { font-size: 10px; color: #CFE0F0; }
.cbtn.off { opacity: .55; }
.cbtn.mic { background: var(--orange); width: 76px; height: 76px; }
.cbtn.mic.active { background: var(--ok); animation: pulse-btn 1.2s infinite; }
@keyframes pulse-btn { 50% { transform: scale(1.06); } }
.cbtn.end { background: var(--danger); }
.cbtn.end span { transform: rotate(135deg); display: inline-block; }

/* ---------- small screens ---------- */
@media (max-width: 380px) {
  .call-label { display: none; }
  .call-btn { padding: 0 10px; }
  .msg { max-width: 88%; }
  .call-controls { gap: 12px; }
}

/* ---------- dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root { --paper: #0F1D2C; --card: #1A2C40; --ink: #E6EDF4; --muted: #93A6BA; --orange-soft: #4A2C12; --line: #2A3F55; }
  #chat { background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1.2px); }
  .msg a { color: #7DB8FF; }
  .msg.secret { background: #3A3112; border-color: #B88A00; }
  .quick button { border-color: #35506C; color: #E6EDF4; }
  .ticks { color: #7F92A6; }
  .composer { border-top-color: rgba(255,255,255,.05); }
  .err { background: #3B1C1F; color: #F6B8BC; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* private link + QR */
.msg.link-card { font-family: inherit; }
.link-btn { display: inline-block; padding: 10px 14px; border-radius: 10px; background: var(--orange, #F07D1A); color: #fff;
  font-weight: 600; text-decoration: none; }
.link-btn:focus-visible { outline: 3px solid #0E2A47; outline-offset: 2px; }
.msg.qr-card img { display: block; width: 220px; max-width: 100%; height: auto; border-radius: 8px; background: #fff; }
