/* ============================================================
   AUTOMATBOT — Built-in Offline Desktop Assistant
   Aesthetic: Vermilion Logo Glow & Precision Clinical Shell
   ============================================================ */

/* Banner Button */
.app-banner-automatbot {
  /* Kevin 2026-10-16: same row as Help and Settings, same height. It was
     dropping over the buttons underneath and covering them. */
  position: static;
  z-index: 6;
  box-sizing: border-box;
  font: 600 12px/1 inherit;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #9f2a22;
  background: #ffffff;
  border: 1px solid #e7d2cf;
  border-radius: 10px;
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  padding: 0 12px;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: none;
  transition: background 160ms ease, border-color 160ms ease;
}
#home-view .al-banner-right > #bannerAutomatbotBtn {
  position: static !important;
  top: auto !important;
  right: auto !important;
  height: 38px !important;
  min-height: 38px !important;
  max-height: 38px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em !important;
  text-transform: none !important;
  border-radius: 10px !important;
  z-index: 6 !important;
}

.app-banner-automatbot:hover {
  background: #fff5f5;
  border-color: #ff8787;
  color: #a61e4d;
  box-shadow: 0 3px 10px rgba(201, 42, 42, 0.2);
  transform: translateY(-1px);
}

.app-banner-automatbot:active {
  transform: translateY(0);
}

.automatbot-icon-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e03131;
  box-shadow: 0 0 8px #ff6b6b;
  display: inline-block;
  animation: botPulse 2s infinite ease-in-out;
}

@keyframes botPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px #ff4949; }
}

/* ============================================================
   DRAWER & MODAL CONTAINER
   ============================================================ */
#automatbotDrawer {
  position: fixed;
  top: 96px;
  left: auto;
  right: 16px;
  bottom: 76px;
  width: min(420px, calc(100vw - 32px));
  height: auto;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
  /* Above the frozen banner and footer (z-index 60), under dialogs (900+). */
  z-index: 80;
  display: flex;
  flex-direction: column;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1), opacity 280ms ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
}

#automatbotDrawer.is-open {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 980px) {
  #automatbotDrawer {
    top: 78px;
    right: 10px;
    bottom: 68px;
    width: min(420px, calc(100vw - 20px));
  }
}

.automatbot-veil {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

.automatbot-veil.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Drawer Header */
.automatbot-head {
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.automatbot-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.automatbot-head-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #0f172a;
  text-transform: uppercase;
}

.automatbot-head-sub {
  font-size: 11px;
  color: #64748b;
}

.automatbot-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.automatbot-btn-icon {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 120ms ease;
}

.automatbot-btn-icon:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.automatbot-close-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.automatbot-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Caseload Memory Header Pill */
.automatbot-caseload-pill {
  padding: 7px 14px;
  background: #eff6ff;
  border-bottom: 1px solid #dbeafe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #1e40af;
  flex-shrink: 0;
}

.automatbot-caseload-pill strong {
  color: #1d4ed8;
}

.automatbot-hello {
  padding: 8px 14px;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  font-size: 13px;
  color: #9a3412;
  flex-shrink: 0;
}

.automatbot-hello form {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.automatbot-hello input {
  flex: 1;
  border: 1px solid #fdba74;
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
}

.automatbot-hello button {
  border: none;
  background: #c2410c;
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  cursor: pointer;
}

/* Glowing Bell Curve Avatar Stage */
.automatbot-avatar-stage {
  padding: 8px 16px 8px;
  background: linear-gradient(180deg, #11141a 0%, #1a1e27 100%);
  border-bottom: 1px solid #2d3748;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: visible;
  flex-shrink: 0;
}

.automatbot-avatar-stage svg {
  width: 100%;
  max-width: 420px;
  height: auto;
  aspect-ratio: 500 / 170;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 4px 12px rgba(224, 49, 49, 0.25));
}

.curve-fill { fill: url(#botCurveFire); opacity: 0.15; }
.curve-halo {
  fill: none;
  stroke: #ff5436;
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#botLogoGlow);
  opacity: 0.45;
}
.curve-mid {
  fill: none;
  stroke: #ff6b4a;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.curve-line {
  fill: none;
  stroke: url(#botCurveFire);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.axis-glow {
  stroke: #ff5436;
  stroke-width: 2;
  opacity: 0.3;
  filter: url(#botLogoGlow);
}
.axis-line {
  stroke: rgba(255, 140, 100, 0.6);
  stroke-width: 0.8;
  stroke-dasharray: 2 3;
}

/* Wispy mouth. Idle is a closed slit. Speaking uses one shared burst so the
   glow, core, and spikes sit on the same centre instead of four random shapes. */
.mouth-group { transform-origin: 250px 96px; }
.mouth-group.is-idle .mouth-wisps { opacity: 0; }
.mouth-group.is-idle .mouth-static-glow { opacity: 0.35; }
.mouth-group.is-speaking .mouth-static-glow { opacity: 0.55; }
.mouth-static-glow {
  fill: #ff6b4a;
  opacity: 0.45;
  filter: url(#botStaticGlow);
}
.mouth-wisps {
  fill: none;
  stroke: #ffb088;
  stroke-width: 0.85;
  stroke-linecap: round;
  opacity: 0.9;
  filter: url(#botStaticGlow);
}
.mouth-core {
  fill: #fff4dc;
  opacity: 0.95;
}
.mouth-static {
  fill: #ffd59e;
  stroke: #ff4520;
  stroke-width: 0.8;
  stroke-linejoin: round;
}

/* Voice Bar */
.automatbot-voice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: #94a3b8;
}

.automatbot-voice-bar select {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10.5px;
}

.automatbot-voice-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10.5px;
  cursor: pointer;
}

.automatbot-voice-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Transcript Scroll Container */
.automatbot-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #ffffff;
}

/* Welcome discovery cards */
.automatbot-welcome {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.automatbot-welcome-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.automatbot-welcome-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.automatbot-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: all 140ms ease;
}

.automatbot-card:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.automatbot-card-title {
  font-weight: 600;
  font-size: 12px;
  color: #0f172a;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.automatbot-card-desc {
  font-size: 11px;
  color: #64748b;
  line-height: 1.35;
}

/* Messages */
.automatbot-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: botMsgFade 180ms ease-out;
}

@keyframes botMsgFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.automatbot-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.automatbot-msg.user .automatbot-bubble {
  background: #1e293b;
  color: #ffffff;
  border-radius: 12px 12px 2px 12px;
}

.automatbot-msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.automatbot-msg.assistant .automatbot-bubble {
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 12px 12px 12px 2px;
}

.automatbot-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.automatbot-bubble h3 {
  margin: 4px 0 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
}

.automatbot-bubble p {
  margin: 0 0 8px;
}

.automatbot-bubble p:last-child {
  margin-bottom: 0;
}

.automatbot-bubble ul, .automatbot-bubble ol {
  margin: 4px 0 8px 18px;
  padding: 0;
}

.automatbot-bubble li {
  margin-bottom: 4px;
}

.automatbot-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.automatbot-sources-label {
  font-size: 10.5px;
  color: #94a3b8;
  font-weight: 600;
}

.automatbot-source-tag {
  background: #e2e8f0;
  color: #475569;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

/* Action Dispatch Banner inside message */
.automatbot-action-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.automatbot-action-btn {
  background: #059669;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
  white-space: nowrap;
}

.automatbot-action-btn:hover {
  background: #047857;
}

/* Proactive Offer Chips */
.automatbot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.automatbot-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
}

.automatbot-chip:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

/* Stepper Card for Guided Tours / Setup */
.automatbot-stepper {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  display: none;
}

.automatbot-stepper.is-active {
  display: block;
}

.automatbot-stepper-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.automatbot-stepper-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #2563eb;
  background: #dbeafe;
  padding: 2px 7px;
  border-radius: 4px;
}

.automatbot-stepper-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.automatbot-stepper-body {
  font-size: 12px;
  color: #475569;
  line-height: 1.4;
  margin-bottom: 10px;
}

.automatbot-stepper-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.automatbot-stepper-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.automatbot-stepper-btn.primary {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Composer */
.automatbot-composer {
  padding: 12px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.automatbot-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  background: #ffffff;
  line-height: 1.4;
}

.automatbot-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.automatbot-mic-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 120ms ease;
  flex-shrink: 0;
}

.automatbot-mic-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.automatbot-mic-btn.is-listening {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
  animation: micPulse 1.2s infinite ease-in-out;
}

@keyframes micPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
}

.automatbot-send-btn {
  background: #e03131;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease;
  flex-shrink: 0;
}

.automatbot-send-btn:hover {
  background: #c92a2a;
}

#automatbotVoiceStatus {
  font-size: 10.5px;
  color: #e2e8f0;
}

/* Banner button matches Help and Settings, day and night. */
:root[data-al-theme="night"] #home-view .al-banner-right > #bannerAutomatbotBtn {
  background: var(--al-surface, #1c1b23);
  background-image: none;
  color: var(--al-ink, #eceaf2);
  border-color: var(--al-line, #343342);
}
:root[data-al-theme="night"] #home-view .al-banner-right > #bannerAutomatbotBtn:hover {
  background: var(--al-red-tint, #3a2320);
  background-image: none;
  color: var(--al-red-deep, #f27a66);
}

/* Night: the drawer is a dark panel. Text stays light on those surfaces.
   The bell-curve stage stays the same near-black in both themes so the
   vermillion mouth still reads. */
:root[data-al-theme="night"] #automatbotDrawer {
  background: #1c1b23;
  color: #eceaf2;
  border-color: #343342;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-head {
  background: #252430;
  border-bottom-color: #343342;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-head-title,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-card-title,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-stepper-title,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-bubble h3 {
  color: #eceaf2;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-head-sub,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-card-desc,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-stepper-body,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-welcome-label {
  color: #c8c4d2;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-scroll,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-avatar-stage {
  background: #14131a;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-avatar-stage {
  background: linear-gradient(180deg, #11141a 0%, #1a1e27 100%);
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-card,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-stepper {
  background: #252430;
  border-color: #343342;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-msg.assistant .automatbot-bubble {
  background: #2a2936;
  color: #eceaf2;
  border-color: #3a3944;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-msg.user .automatbot-bubble {
  background: #9d2235;
  color: #ffffff;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-composer {
  background: #252430;
  border-top-color: #343342;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-input,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-hello input {
  background: #14131a;
  color: #eceaf2;
  border-color: #5a5866;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-caseload-pill {
  background: #1e2a40;
  color: #d6e4ff;
  border-bottom-color: #343342;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-caseload-pill strong { color: #ffffff; }
:root[data-al-theme="night"] #automatbotDrawer .automatbot-hello {
  background: #33281a;
  color: #ffd7a8;
  border-bottom-color: #5a4630;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-source-tag {
  background: #343342;
  color: #eceaf2;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-sources-label { color: #c8c4d2; }
:root[data-al-theme="night"] #automatbotDrawer .automatbot-chip {
  background: #252430;
  color: #eceaf2;
  border-color: #5a5866;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-btn-icon,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-close-btn,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-mic-btn,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-stepper-btn,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-voice-toggle {
  background: #2c2a36;
  background-image: none;
  color: #eceaf2;
  border-color: #5a5866;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-send-btn,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-action-btn,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-stepper-btn.primary,
:root[data-al-theme="night"] #automatbotDrawer .automatbot-hello button {
  background: #9d2235;
  background-image: none;
  color: #ffffff;
  border-color: #9d2235;
}
:root[data-al-theme="night"] #automatbotDrawer .automatbot-action-box {
  background: #1e3327;
  border-color: #2e5a3e;
  color: #d8f3e4;
}

/* Kevin, 2026-10-30: with a conversation on screen the avatar gives up its
   room so answers are read in full instead of in a letterbox. */
#automatbotDrawer.has-chat .automatbot-avatar-stage {
  padding: 4px 16px 2px;
}
#automatbotDrawer.has-chat .automatbot-avatar-stage svg {
  max-width: 230px;
}
.automatbot-scroll {
  min-height: 220px;
}
