/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ───────────────────────────────────────────── */
:root {
  --header-bg:      #1E0A40;
  --accent:         #E91E8C;
  --accent-2:       #8B5CF6;
  --accent-3:       #F59E0B;
  --accent-dark:    #BE185D;
  --accent-light:   #FFF0F7;
  --accent-ring:    rgba(233,30,140,.18);
  --bg:             #FBF5FF;
  --surface:        #FFFFFF;
  --border:         #EDD5F5;
  --text:           #1A0535;
  --text-muted:     #6B4080;
  --text-subtle:    #A07CC0;
  --success:        #059669;
  --warning:        #D97706;
  --danger:         #DC2626;
  --shadow-sm:      0 1px 3px rgba(100,0,80,.06);
  --shadow-md:      0 4px 16px rgba(100,0,80,.10);
  --r-sm:           6px;
  --r-md:           12px;
  --r-lg:           18px;
  --r-pill:         9999px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Root sizing ─────────────────────────────────────────────── */
html, body { height: 100%; }

/* ── Body ────────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ════════════════════════════════════════════════════════════════
   DESKTOP LAYOUT  (default — no media query)
   ════════════════════════════════════════════════════════════════ */

/* ── Site header ─────────────────────────────────────────────── */
.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 24px;
  height: 60px;
  background: linear-gradient(135deg, #1E0A40 0%, #4A0E8F 50%, #1E0A40 100%);
  background-size: 200% 100%;
  animation: headerShimmer 7s ease-in-out infinite;
  flex-shrink: 0;
  gap: 12px;
  z-index: 20;
}

.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-logo { height: 44px; width: auto; object-fit: contain; border-radius: 5px; flex-shrink: 0; }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }

.brand-name {
  font-size: 17px; font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(135deg, #ffffff 20%, #D9AAFF 80%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: #fff;
}

.brand-tagline { font-size: 11px; color: rgba(255,255,255,.45); font-weight: 400; }

/* Site-header nav tabs */
.main-nav {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-pill);
  padding: 4px;
}

.nav-tab {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 16px; border-radius: var(--r-pill); border: none;
  background: transparent; color: rgba(255,255,255,.55);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .14s, color .14s;
  white-space: nowrap; font-family: var(--font);
}
.nav-tab:hover  { background: rgba(255,255,255,.12); color: rgba(255,255,255,.9); }
.nav-tab.active {
  background: linear-gradient(135deg, #E91E8C 0%, #8B5CF6 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(233,30,140,.38);
}
.nav-tab svg { flex-shrink: 0; }

/* Header right actions */
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }

.hdr-toggle {
  display: flex; align-items: center; gap: 5px;
  cursor: pointer; user-select: none; min-height: 44px;
}

/* ── Toggle switch ───────────────────────────────────────────── */
.toggle-icon  { width: 14px; height: 14px; color: rgba(255,255,255,.55); flex-shrink: 0; }
.toggle-label { font-size: 12px; color: rgba(255,255,255,.65); font-weight: 500; white-space: nowrap; }

.toggle-switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.2);
  border-radius: 10px;
  cursor: pointer;
  transition: background .18s;
}
.toggle-slider::after {
  content: '';
  position: absolute; left: 3px; top: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(255,255,255,.65);
  transition: transform .18s, background .18s;
}
.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #E91E8C 0%, #8B5CF6 100%);
}
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(16px); background: #fff; }

/* ── Phone frame wrapper ─────────────────────────────────────── */
.phone-frame {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* Status bar: hidden on desktop, shown on mobile via media query */
.status-bar { display: none; }

/* ── App shell — desktop: 2-column grid ─────────────────────── */
.app-shell {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: 1fr;
  overflow: hidden;
  background: var(--surface);
}

/* Chat always in left column (JS never hides it on desktop) */
#view-chat {
  grid-column: 1;
  grid-row: 1;
}

/* Sidebar: default, orders, escalations share right column */
#sidebar-default,
#view-orders,
#view-escalations {
  grid-column: 2;
  grid-row: 1;
  border-left: 1px solid var(--border);
  overflow: hidden;
}

/* Chat topbar: hidden on desktop (site-header handles branding/voice) */
.chat-topbar { display: none; }

/* Bottom nav: hidden on desktop */
.bottom-nav { display: none; }

/* Powered footer: hidden on desktop */
.powered-footer { display: none; }

/* ── Desktop footer strip ────────────────────────────────────── */
.desktop-footer {
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
  padding: 5px 0 7px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  letter-spacing: .02em;
}

/* ── Views ───────────────────────────────────────────────────── */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Chat view: stacking context for doodle-bg */
#view-chat {
  position: relative;
  isolation: isolate;
  background: var(--bg);
}

/* ── Decorative background doodles ──────────────────────────── */
.doodle-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.doodle { position: absolute; opacity: .065; }

.doodle-1  { top: 6%;  left: 4%;   color: #E91E8C; animation: dFloat  7.0s ease-in-out infinite 0.0s; }
.doodle-2  { top: 14%; right: 6%;  color: #8B5CF6; animation: dFloat2 5.5s ease-in-out infinite 0.8s; }
.doodle-3  { top: 36%; left: 9%;   color: #E91E8C; animation: dFloat  8.5s ease-in-out infinite 1.5s; }
.doodle-4  { top: 54%; right: 8%;  color: #8B5CF6; animation: dFloat2 6.5s ease-in-out infinite 0.4s; }
.doodle-5  { top: 3%;  left: 44%;  color: #F59E0B; animation: dFloat  9.0s ease-in-out infinite 2.2s; }
.doodle-6  { top: 68%; left: 16%;  color: #E91E8C; animation: dFloat2 7.0s ease-in-out infinite 1.8s; }
.doodle-7  { top: 78%; right: 13%; color: #F59E0B; animation: dFloat  6.0s ease-in-out infinite 3.0s; }
.doodle-8  { top: 44%; right: 22%; color: #E91E8C; animation: dFloat2 8.0s ease-in-out infinite 2.5s; }
.doodle-9  { top: 88%; left: 38%;  color: #8B5CF6; animation: dFloat  5.0s ease-in-out infinite 0.3s; }

/* ── Sidebar default panel (desktop only) ────────────────────── */
.sidebar-default {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  background: var(--bg);
  gap: 12px;
}

.sidebar-default-icon { font-size: 52px; line-height: 1; animation: dFloat 5s ease-in-out infinite; }
.sidebar-default-title { font-size: 17px; font-weight: 700; color: var(--text); }
.sidebar-default-sub { font-size: 13px; color: var(--text-muted); line-height: 1.65; max-width: 220px; }

.sidebar-quick-links {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; max-width: 220px; margin-top: 8px;
}

.sidebar-quick-btn {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-pill); padding: 9px 16px;
  font-size: 13px; font-weight: 500; font-family: var(--font);
  color: var(--text-muted); cursor: pointer; text-align: left;
  transition: border-color .13s, color .13s, background .13s;
}
.sidebar-quick-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ── Screen topbar (Orders + Escalations header) ─────────────── */
.screen-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 50px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 10px;
}

.screen-topbar-title { font-size: 15px; font-weight: 700; color: var(--text); }

.refresh-btn {
  display: flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--r-sm); padding: 6px 12px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-muted); white-space: nowrap; flex-shrink: 0;
  font-family: var(--font);
  transition: border-color .13s, color .13s;
}
.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Chat area ───────────────────────────────────────────────── */
.chat-area {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: transparent;
}

.chat-area::-webkit-scrollbar         { width: 4px; }
.chat-area::-webkit-scrollbar-track   { background: transparent; }
.chat-area::-webkit-scrollbar-thumb   { background: var(--border); border-radius: 10px; }

/* ── Bubbles ─────────────────────────────────────────────────── */
.bubble {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 72%;
  animation: bubbleIn .2s cubic-bezier(.22,.61,.36,1) both;
}

.bubble.agent { align-self: flex-start; }
.bubble.user  { align-self: flex-end; flex-direction: row-reverse; }

.bubble-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #E91E8C 0%, #8B5CF6 100%);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-bottom: 2px;
}

.bubble-body {
  padding: 10px 14px; border-radius: var(--r-lg);
  font-size: 14px; line-height: 1.6;
  max-width: 100%; word-break: break-word;
}

.bubble.agent .bubble-body {
  background: var(--surface); border: 1px solid var(--border);
  border-bottom-left-radius: 4px; color: var(--text);
  box-shadow: var(--shadow-sm);
}

.bubble.user .bubble-body {
  background: linear-gradient(135deg, #E91E8C 0%, #8B5CF6 100%);
  color: #fff; border-bottom-right-radius: 4px;
  box-shadow: 0 3px 14px rgba(233,30,140,.30);
}

/* Typing dots */
.typing-dots {
  display: flex; align-items: center; gap: 5px;
  padding: 12px 16px; min-width: 56px;
}
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); display: inline-block;
  animation: dotBounce 1.3s ease-in-out infinite; opacity: .6;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: .18s; }
.typing-dots span:nth-child(3) { animation-delay: .36s; }

/* ── Escalation ticket banner ────────────────────────────────── */
.esc-ticket-banner {
  display: flex; align-items: flex-start; gap: 12px;
  background: linear-gradient(135deg, #FFF0F7 0%, #F0EBFF 100%);
  border: 1px solid rgba(233,30,140,.20);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md); padding: 14px;
  margin: 4px 0;
  animation: bubbleIn .22s ease both;
  align-self: stretch;
}

.esc-ticket-header { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.esc-ticket-icon { font-size: 18px; line-height: 1; }
.esc-ticket-title { font-size: 14px; font-weight: 700; color: var(--accent-dark); }
.esc-ticket-id {
  font-size: 11px; font-weight: 700; font-family: monospace;
  color: var(--text-muted); background: rgba(233,30,140,.08);
  display: inline-block; padding: 2px 8px;
  border-radius: var(--r-sm); margin-bottom: 7px;
}
.esc-ticket-note { font-size: 13px; color: var(--text-muted); line-height: 1.55; }

/* ── Product cards ───────────────────────────────────────────── */
.product-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; margin-top: 6px;
  width: 100%; max-width: 680px;
  align-self: flex-start;
  animation: bubbleIn .22s cubic-bezier(.22,.61,.36,1) .06s both;
}

.product-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px;
  transition: box-shadow .16s, transform .16s, border-color .16s;
  cursor: default;
}
.product-card:hover {
  box-shadow: 0 8px 24px rgba(233,30,140,.14);
  transform: translateY(-3px); border-color: rgba(233,30,140,.28);
}

.product-card-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, #FFF0F7 0%, #EDE9FE 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 8px;
}

.product-card-name {
  font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.35;
  margin-bottom: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.product-card-brand  { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.product-card-price  { font-size: 13px; font-weight: 700; color: var(--accent); }
.product-card-stock  { font-size: 11px; font-weight: 600; margin-top: 4px; }
.product-card-stock.in-stock  { color: var(--success); }
.product-card-stock.low-stock { color: var(--warning); }
.product-card-stock.oos       { color: var(--danger);  }
.product-card-rating { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── Input area ──────────────────────────────────────────────── */
.input-area {
  padding: 8px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}

.suggestions {
  display: flex; gap: 6px; padding: 0 0 8px;
  flex-wrap: wrap;         /* inline chips on desktop */
  overflow-x: auto; scrollbar-width: none;
}
.suggestions::-webkit-scrollbar { display: none; }
.suggestions.hidden { display: none; }

.suggestion-chip {
  flex-shrink: 0;
  border: 1.5px solid var(--border); background: var(--surface);
  border-radius: var(--r-pill); padding: 5px 12px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-muted); white-space: nowrap; font-family: var(--font);
  transition: border-color .13s, color .13s, background .13s, box-shadow .13s;
}
.suggestion-chip:hover {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-light); box-shadow: 0 2px 8px rgba(233,30,140,.14);
}
.suggestion-chip:active { opacity: .75; }

.text-controls {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--r-pill); padding: 8px 8px 8px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.text-controls:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.text-input {
  flex: 1; border: none; background: transparent;
  font-family: var(--font); font-size: 14px; color: var(--text);
  resize: none; outline: none; line-height: 1.5;
  max-height: 120px; overflow-y: auto;
}
.text-input::placeholder { color: var(--text-subtle); }

.send-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #E91E8C 0%, #8B5CF6 100%);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .13s, transform .1s, box-shadow .13s;
}
.send-btn:hover { opacity: .88; transform: scale(1.07); box-shadow: 0 4px 14px rgba(233,30,140,.4); }
.send-btn:active  { transform: scale(.92); }
.send-btn svg     { width: 14px; height: 14px; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

.voice-controls { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 4px; }

.voice-hint { font-size: 13px; color: var(--text-muted); font-weight: 500; transition: color .2s; min-height: 18px; }

.mic-btn {
  width: 68px; height: 68px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #E91E8C 0%, #8B5CF6 100%);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow: 0 4px 18px rgba(233,30,140,.38);
  transition: opacity .13s, transform .1s, box-shadow .15s;
}
.mic-btn svg     { width: 26px; height: 26px; position: relative; z-index: 1; }
.mic-btn:hover   { opacity: .9; transform: scale(1.04); }
.mic-btn:active  { transform: scale(.93); }
.mic-btn:disabled { opacity: .4; cursor: not-allowed; }

.mic-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 2.5px solid #E91E8C;
  opacity: 0; pointer-events: none;
}

.mic-btn.recording { background: #DC2626; box-shadow: 0 3px 20px rgba(220,38,38,.4); }
.mic-btn.recording .mic-ring { border-color: #EF4444; animation: ripple 1.1s ease-out infinite; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state-view {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 24px; text-align: center;
  background: var(--bg);
}

.empty-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, #FFF0F7 0%, #EDE9FE 100%);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(233,30,140,.15);
}

.empty-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-sub   { font-size: 13px; color: var(--text-muted); line-height: 1.6; max-width: 320px; margin-bottom: 22px; }

.empty-action {
  background: linear-gradient(135deg, #E91E8C 0%, #8B5CF6 100%);
  color: #fff; border: none; border-radius: var(--r-pill); padding: 10px 24px;
  font-size: 13px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: opacity .13s, transform .1s;
}
.empty-action:hover  { opacity: .88; transform: translateY(-1px); }
.empty-action:active { transform: scale(.96); }

/* ── Escalations view ────────────────────────────────────────── */
.esc-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 20px 20px 32px; background: var(--bg);
}
.esc-scroll::-webkit-scrollbar        { width: 4px; }
.esc-scroll::-webkit-scrollbar-track  { background: transparent; }
.esc-scroll::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 10px; }

.stats-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }

.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px 14px;
  box-shadow: var(--shadow-sm); text-align: center;
  transition: box-shadow .16s, transform .16s, border-color .16s;
}
.stat-card:hover {
  box-shadow: 0 6px 20px rgba(233,30,140,.12);
  transform: translateY(-2px); border-color: rgba(233,30,140,.22);
}

.stat-label {
  font-size: 10px; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 7px;
}

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-value.total {
  color: var(--accent);
  background: linear-gradient(135deg, #E91E8C, #8B5CF6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.stat-value.pending  { color: var(--warning); }
.stat-value.resolved { color: var(--success); }

.esc-loading { display: flex; align-items: center; gap: 12px; padding: 40px 0; color: var(--text-muted); font-size: 14px; }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .65s linear infinite; flex-shrink: 0;
}

.esc-empty { text-align: center; padding: 64px 20px; color: var(--text-muted); }
.esc-empty-icon { font-size: 42px; margin-bottom: 14px; opacity: .4; }
.esc-empty p    { font-size: 15px; font-weight: 500; }
.esc-empty span { font-size: 13px; display: block; margin-top: 5px; }

.esc-list { display: flex; flex-direction: column; gap: 12px; }

.esc-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .16s, transform .16s, border-color .16s;
  animation: bubbleIn .18s ease both;
}
.esc-card:hover {
  box-shadow: 0 8px 24px rgba(233,30,140,.12);
  transform: translateY(-2px); border-color: rgba(233,30,140,.22);
}

.esc-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

.esc-id {
  font-size: 12px; font-weight: 700;
  background: linear-gradient(135deg, #FFF0F7 0%, #EDE9FE 100%);
  color: var(--accent-dark); border-radius: var(--r-sm); padding: 3px 8px; font-family: monospace;
}

.esc-status { font-size: 11px; font-weight: 600; border-radius: var(--r-pill); padding: 3px 10px; }
.esc-status.pending  { background: linear-gradient(135deg, #FEF3C7, #FDE68A); color: #92400E; }
.esc-status.assigned { background: linear-gradient(135deg, #EDE9FE, #DDD6FE); color: #5B21B6; }
.esc-status.resolved { background: linear-gradient(135deg, #D1FAE5, #A7F3D0); color: #065F46; }

.esc-meta { font-size: 12px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }

.esc-reason {
  font-size: 13px; font-weight: 600;
  color: var(--accent);
  background: linear-gradient(135deg, #E91E8C, #8B5CF6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 7px;
}

.esc-summary {
  font-size: 13px; color: var(--text); line-height: 1.6;
  background: var(--bg); border-radius: var(--r-sm); padding: 10px 12px;
  border-left: 3px solid var(--border); margin-bottom: 10px;
}

/* Conversation transcript */
.esc-transcript { margin-top: 4px; }
.esc-transcript > summary {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; padding: 6px 0; list-style: none;
  display: flex; align-items: center; gap: 4px; transition: color .13s;
}
.esc-transcript > summary:hover { color: var(--accent); }
.esc-transcript > summary::before { content: '▶'; font-size: 10px; transition: transform .15s; }
.esc-transcript[open] > summary::before { transform: rotate(90deg); }

.esc-transcript-body {
  margin-top: 8px; border: 1px solid var(--border);
  border-radius: var(--r-sm); overflow: hidden; max-height: 280px; overflow-y: auto;
}

.transcript-line { font-size: 12px; line-height: 1.55; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.transcript-line:last-child { border-bottom: none; }
.transcript-line.user      { background: var(--accent-light); }
.transcript-line.assistant { background: var(--surface); }
.transcript-line strong    { color: var(--text-muted); font-weight: 600; margin-right: 4px; }

/* ── Escalation badge ────────────────────────────────────────── */
.esc-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: var(--r-pill);
  padding: 0 4px; line-height: 1; margin-left: 4px; vertical-align: middle;
}

/* ── Mobile-only elements (styles defined here, visibility via @media) ── */
.status-time { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.9); letter-spacing: .03em; }
.status-center { flex: 1; text-align: center; }
.powered-by-status { font-size: 9px; font-weight: 400; color: rgba(255,255,255,.28); letter-spacing: .02em; white-space: nowrap; }
.status-icons { display: flex; align-items: center; gap: 5px; color: rgba(255,255,255,.88); }

.chat-agent-info { display: flex; align-items: center; gap: 10px; min-width: 0; }

.chat-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #E91E8C 0%, #8B5CF6 100%);
  color: #fff; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 2px solid rgba(255,255,255,.20);
  box-shadow: 0 2px 10px rgba(233,30,140,.35);
}

.chat-agent-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }

.chat-name { font-size: 14px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 6px; }
.topbar-logo { height: 17px; width: auto; object-fit: contain; border-radius: 3px; flex-shrink: 0; }
.chat-status-line { font-size: 11px; color: rgba(255,255,255,.5); display: flex; align-items: center; gap: 4px; margin-top: 2px; }

.online-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22C55E; box-shadow: 0 0 0 2px rgba(34,197,94,.2);
  flex-shrink: 0; animation: pulseOnline 2.5s ease-in-out infinite;
}

.voice-toggle { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; flex-shrink: 0; }

.bottom-tab {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: transparent;
  color: var(--text-subtle); font-family: var(--font);
  font-size: 10px; font-weight: 500;
  cursor: pointer; border-radius: var(--r-sm); padding: 6px 4px;
  transition: color .14s;
}
.bottom-tab svg { width: 21px; height: 21px; flex-shrink: 0; transition: transform .15s; }
.bottom-tab:hover { color: var(--text-muted); }
.bottom-tab.active { color: var(--accent); }
.bottom-tab.active svg { transform: translateY(-1px); }
.bottom-tab.active::after {
  content: '';
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.bottom-tab .esc-badge { position: absolute; top: 6px; right: calc(50% - 18px); }

/* ════════════════════════════════════════════════════════════════
   MOBILE LAYOUT  (≤ 768px — auto-switch, no manual toggle)
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Hide site header — bottom nav handles navigation */
  .site-header { display: none; }

  /* Status bar at top */
  .status-bar {
    display: flex;
    align-items: center; justify-content: space-between;
    height: 28px;
    background: linear-gradient(135deg, #1E0A40 0%, #2D0A5E 100%);
    padding: 0 18px 0 20px; flex-shrink: 0; gap: 8px;
  }

  /* App shell: single column on mobile */
  .app-shell {
    display: flex; flex-direction: column;
    grid-template-columns: unset; grid-template-rows: unset;
  }

  /* Reset grid placement */
  #view-chat,
  #sidebar-default,
  #view-orders,
  #view-escalations {
    grid-column: auto; grid-row: auto; border-left: none;
  }

  /* Sidebar default never shows on mobile */
  #sidebar-default { display: none !important; }

  /* Desktop footer hidden on mobile */
  .desktop-footer { display: none; }

  /* Chat topbar visible on mobile (inside #view-chat) */
  .chat-topbar {
    display: flex;
    align-items: center; justify-content: space-between;
    padding: 0 16px; height: 56px;
    background: linear-gradient(135deg, #1E0A40 0%, #3B0F6E 100%);
    flex-shrink: 0; gap: 10px;
  }

  /* Screen topbar dark on mobile */
  .screen-topbar {
    background: linear-gradient(135deg, #1E0A40 0%, #3B0F6E 100%);
    border-bottom: none; padding: 0 14px; height: 52px;
  }
  .screen-topbar-title { color: #fff; font-size: 14px; }
  .refresh-btn { border-color: rgba(255,255,255,.2); background: transparent; color: rgba(255,255,255,.65); padding: 5px 10px; }
  .refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

  /* Bottom nav visible */
  .bottom-nav {
    display: flex; align-items: stretch;
    border-top: 2px solid var(--border); background: var(--surface);
    flex-shrink: 0; height: 62px; padding: 0 4px;
  }

  /* Powered footer visible */
  .powered-footer {
    display: block; text-align: center;
    font-size: 9.5px; color: var(--text-subtle);
    padding: 4px 0 6px; background: var(--surface); flex-shrink: 0;
  }

  /* Tighter chat UI on mobile */
  .chat-area { padding: 14px 13px 10px; gap: 10px; }
  .input-area { padding: 7px 12px 11px; }
  .bubble { max-width: 84%; }
  .text-input { font-size: 16px; } /* prevent iOS zoom */
  .mic-btn { width: 62px; height: 62px; }
  .mic-btn svg { width: 24px; height: 24px; }
  .product-cards { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
  .esc-scroll { padding: 13px 13px 20px; }
  .stats-bar { gap: 8px; margin-bottom: 13px; }
  .stat-card { padding: 12px 8px; }
  .stat-value { font-size: 24px; }
  .esc-card { padding: 13px; }

  /* Suggestion chips scroll horizontally on mobile */
  .suggestions { flex-wrap: nowrap; overflow-x: auto; }
}

/* ════════════════════════════════════════════════════════════════
   KEYFRAMES
   ════════════════════════════════════════════════════════════════ */
@keyframes headerShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1);   }
}

@keyframes dotBounce {
  0%,80%,100% { transform: scale(.7);  opacity: .4; }
  40%          { transform: scale(1.1); opacity: 1;  }
}

@keyframes ripple {
  0%   { transform: scale(1);    opacity: .6; }
  100% { transform: scale(1.55); opacity: 0;  }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes dFloat {
  0%, 100% { transform: translateY(0)     rotate(-7deg) scale(1);    }
  50%       { transform: translateY(-15px) rotate(5deg)  scale(1.05); }
}

@keyframes dFloat2 {
  0%, 100% { transform: translateY(0)     rotate(7deg)   scale(1);    }
  50%       { transform: translateY(-11px) rotate(-5deg)  scale(1.07); }
}

@keyframes pulseOnline {
  0%, 100% { box-shadow: 0 0 0 2px rgba(34,197,94,.15); }
  50%       { box-shadow: 0 0 0 5px rgba(34,197,94,.08), 0 0 8px rgba(34,197,94,.25); }
}
