/* ITC Voice Agent — Custom styles (supplements Tailwind CDN) */

:root {
  --accent: #0B6E99;
}

/* ── Background glow ─────────────────────────────────────────────────────── */
.bg-glow {
  position: fixed;
  bottom: -10%;
  right: 10%;
  width: 50%;
  height: 50%;
  background: var(--accent);
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}

/* ── Status dot ──────────────────────────────────────────────────────────── */
.dot-active {
  background-color: #22c55e !important;
  animation: dot-pulse 2s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

.dot-inactive {
  background-color: #d1d5db !important;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Tool indicator badge ────────────────────────────────────────────────── */
.tool-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: #fff1f2;
  border: 1px solid #fecaca;
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

/* ── Waveform bars ───────────────────────────────────────────────────────── */
.bar {
  width: 6px;
  background-color: var(--accent);
  border-radius: 9999px;
  animation: wave 1.5s ease-in-out infinite;
  height: 20px;
}

.bar:nth-child(1)  { animation-delay: 0.00s; }
.bar:nth-child(2)  { animation-delay: 0.10s; }
.bar:nth-child(3)  { animation-delay: 0.20s; }
.bar:nth-child(4)  { animation-delay: 0.30s; }
.bar:nth-child(5)  { animation-delay: 0.40s; }
.bar:nth-child(6)  { animation-delay: 0.50s; }
.bar:nth-child(7)  { animation-delay: 0.40s; }
.bar:nth-child(8)  { animation-delay: 0.30s; }
.bar:nth-child(9)  { animation-delay: 0.20s; }
.bar:nth-child(10) { animation-delay: 0.10s; }
.bar:nth-child(11) { animation-delay: 0.05s; }
.bar:nth-child(12) { animation-delay: 0.00s; }

@keyframes wave {
  0%, 100% {
    height: 16px;
    opacity: 0.3;
  }
  50% {
    height: 80px;
    opacity: 1.0;
  }
}

/* ── Start button hover state for SVG color ─────────────────────────────── */
.start-btn:hover svg {
  color: var(--accent);
}

/* ── Capability card tooltips ────────────────────────────────────────────── */
.tool-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  width: 20rem;
  max-width: 90vw;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  padding: 14px 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 50;
}

.capability-card:hover .tool-tooltip,
.capability-card:focus-within .tool-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* caret */
.tool-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #fff;
  filter: drop-shadow(0 1px 0 #e5e7eb);
}

.tool-tooltip h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
}

.tool-tooltip ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.tool-tooltip li {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tool-tooltip li strong {
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
}

.tool-tooltip li span {
  font-size: 11px;
  line-height: 1.4;
  color: #6b7280;
}

/* ── Test data button ────────────────────────────────────────────────────── */
.test-data-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #4b5563;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.test-data-btn:hover {
  background: #fff1f2;
  border-color: #fecaca;
  color: var(--accent);
}

.test-data-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #fff;
  border-color: #e5e7eb;
  color: #9ca3af;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px);
}

.modal-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 880px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 22px 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-subtitle {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 16px;
}

.modal-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  margin-top: 24px;
  margin-bottom: 6px;
}

.modal-table-wrap {
  overflow: auto;
  border: 1px solid #f3f4f6;
  border-radius: 10px;
}

/* ── Auth reference table ────────────────────────────────────────────────── */
.auth-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.auth-table th {
  text-align: left;
  background: #f9fafb;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
}

.auth-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  white-space: nowrap;
}

.auth-table tr:last-child td {
  border-bottom: none;
}

.auth-table tbody tr:hover td {
  background: #fff7f7;
}

.auth-table-empty {
  text-align: center;
  color: #9ca3af;
  white-space: normal;
}

/* ── Location map modal ──────────────────────────────────────────────────── */
.map-wrap {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #f3f4f6;
}

#location-map {
  display: block;
  width: 100%;
  height: 340px;
  border: 0;
}

.map-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.map-coords {
  font-size: 12px;
  color: #6b7280;
  margin-right: auto;
}

.map-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #e5e7eb;
  color: #4b5563;
  background: #fff;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.map-btn:hover {
  background: #fff1f2;
  border-color: #fecaca;
  color: var(--accent);
}

.map-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.map-btn-primary:hover {
  background: #c40511;
  border-color: #c40511;
  color: #fff;
}

/* ── Chat panel (text transcript + input) ────────────────────────────────── */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 2px 12px;
}

.chat-bubble {
  max-width: 80%;
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble-gemini {
  align-self: flex-start;
  background: #f3f4f6;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border-radius: 9999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  background: transparent;
  color: #1f2937;
}

.chat-input::placeholder {
  color: #9ca3af;
}

.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-send-btn:hover {
  background: #c40511;
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Split view: session (left) | debug console (right) ──────────────────── */
/* Lives inside the home page's voice-agent popup (#voiceAgentRoot, a fixed-
   height flex column — see embed-responsive.css). Each half scrolls on its
   own, so a long conversation never pushes the debug console (or vice versa)
   out of view. */
.app-split {
  flex: 1;
  min-height: 0;
  display: flex;
}

.session-pane {
  flex: 1 1 50%;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* embed-responsive.css makes <main> shrink and clip so everything fits the
   popup without scrolling; with the typed-chat panel under the mic that
   would clip the conversation, so let it keep its height and scroll the
   session pane instead. */
#voiceAgentRoot .session-pane main {
  flex: 1 0 auto;
  overflow: visible;
}

/* The popup is phone-sized (520px); with the debug console shown it widens
   to fit both halves. Hidden, it's exactly the home page's popup. */
body:not(.debug-hidden) .chat-modal {
  max-width: min(1500px, 96vw);
  height: 92vh;
  max-height: none;
}

.debug-pane {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-left: 1px solid #e5e7eb;
  background: #f3f4f6;
  position: relative;
  z-index: 10;
}

body.debug-hidden .debug-pane {
  display: none;
}

/* Too narrow for side-by-side halves: stack them and scroll them together. */
@media (max-width: 900px) {
  .app-split {
    flex-direction: column;
    overflow-y: auto;
  }
  .session-pane {
    flex: 0 0 auto;
    overflow-y: visible;
  }
  .debug-pane {
    border-left: none;
    border-top: 1px solid #e5e7eb;
    min-height: 70vh;
  }
}

.debug-empty {
  font-size: 12px;
  color: #9ca3af;
  padding: 4px 0;
}

/* ── Verification steps panel ────────────────────────────────────────────── */
.steps-panel {
  flex-shrink: 0;
  /* Up to 7 steps with the registration route; keep the rest for the log. */
  max-height: 65%;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 16px 18px 12px;
}

.steps-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.steps-header h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: #1f2937;
}

.steps-mode {
  font-size: 10px;
  color: #6b7280;
  white-space: nowrap;
}

.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.step {
  position: relative;
  display: flex;
  gap: 12px;
  padding-bottom: 12px;
}

/* connector line between step markers */
.step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 26px;
  bottom: 2px;
  width: 2px;
  background: #e5e7eb;
  transition: background 0.3s ease;
}

.step-done:not(:last-child)::before {
  background: #22c55e;
}

.step-marker {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  border: 2px solid #e5e7eb;
  background: #fff;
  color: #9ca3af;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.step-done .step-marker {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}

.step-just-done .step-marker {
  animation: step-pop 0.35s ease;
}

.step-current .step-marker {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px rgba(11, 110, 153, 0.12);
  animation: step-pulse 1.8s ease-in-out infinite;
}

.step-failed .step-marker {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

.step-skipped .step-marker {
  background: #f9fafb;
  border-color: #d1d5db;
  color: #6b7280;
}

@keyframes step-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes step-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(11, 110, 153, 0.12); }
  50% { box-shadow: 0 0 0 7px rgba(11, 110, 153, 0.04); }
}

.step-body {
  min-width: 0;
  padding-top: 2px;
}

.step-label {
  font-size: 13px;
  font-weight: 500;
  color: #9ca3af;
  line-height: 1.3;
}

.step-done .step-label,
.step-current .step-label {
  color: #1f2937;
}

.step-failed .step-label,
.step-skipped .step-label {
  color: #6b7280;
  text-decoration: line-through;
}

.step-sub {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
  line-height: 1.35;
}

.step-current .step-sub.step-status {
  color: var(--accent);
}

.step-retry {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 500;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
}

/* ── Decision tree: trunk -> fork -> branch columns ─────────────────────── */
.steps-tree {
  margin-bottom: 10px;
}

/* Carry the trunk's line from the last trunk node down to the fork bar. */
.tree-trunk {
  position: relative;
}

.tree-trunk .step:last-child::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 26px;
  bottom: 0;
  width: 2px;
  background: #d1d5db;
}

.tree-trunk .step-done:last-child::before {
  background: #22c55e;
}

.tree-fork {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-top: 16px;
}

.tree-branch {
  position: relative;
  padding: 8px 10px 0;
  border: 1px solid #f0f0f0;
  border-radius: 10px;
  background: #fafafa;
  transition: opacity 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

/* Fork bar: each column draws the segment from the previous column's marker
   (or, for the first, the trunk's) across to its own, plus a drop into itself. */
.tree-branch::after {
  content: "";
  position: absolute;
  top: -16px;
  height: 2px;
  left: calc(22px - 100% - 10px);
  width: calc(100% + 10px);
  background: #d1d5db;
}

.tree-branch:first-child::after {
  left: 11px;
  width: 11px;
}

.tree-branch::before {
  content: "";
  position: absolute;
  top: -16px;
  left: 21px;
  width: 2px;
  height: 16px;
  background: #d1d5db;
}

.branch-taken {
  background: #f6fdf8;
  border-color: #bbf7d0;
}

.branch-taken::before,
.on-path::after {
  background: #22c55e;
}
/* Fade a column's contents, not the column itself: its connector lines
   (::before/::after) may be part of the path to the taken branch. */
.branch-skipped > *,
.branch-unavailable > * {
  opacity: 0.42;
}

.branch-skipped,
.branch-unavailable {
  background: #fcfcfc;
  border-color: #f5f5f5;
}

/* In a branch that wasn't taken, nothing was "skipped" step by step. */
.branch-skipped .step-label,
.branch-unavailable .step-label {
  text-decoration: none;
}

.branch-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 8px;
  min-height: 30px;
}

.branch-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #374151;
}

.branch-note {
  font-size: 10.5px;
  color: #6b7280;
}

.branch-taken .branch-note {
  color: #15803d;
  font-weight: 600;
}

.tree-branch .step-label {
  font-size: 12px;
}

.steps-verified {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  font-size: 12px;
  font-weight: 600;
}

.steps-note {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 11px;
  line-height: 1.4;
}

/* ── Debug console: tool calls & errors ──────────────────────────────────── */
.debug-log-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
}

.debug-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid #f3f4f6;
}

.debug-log-header h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: #1f2937;
}

.debug-log-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.debug-clear-btn {
  font-size: 11px;
  color: #6b7280;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  padding: 2px 10px;
  cursor: pointer;
}

.debug-clear-btn:hover {
  color: var(--accent);
  border-color: #fecaca;
}

.debug-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.dbg-entry {
  border: 1px solid #e5e7eb;
  border-left: 3px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #1f2937;
  background: #fff;
}

.dbg-entry.dbg-pending { border-left-color: #93c5fd; }
.dbg-entry.dbg-ok      { border-left-color: #22c55e; }
.dbg-entry.dbg-failed  { border-left-color: #f59e0b; background: #fffdf5; }
.dbg-entry.dbg-error   { border-left-color: #dc2626; background: #fef7f7; }
.dbg-entry.dbg-info    { border-left-color: #a78bfa; background: #faf8ff; }

.dbg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.dbg-time {
  color: #9ca3af;
  font-size: 10.5px;
}

.dbg-name {
  font-weight: 700;
  color: #111827;
}

.dbg-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 0 7px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.dbg-pending .dbg-badge { background: #eff6ff; color: #1d4ed8; }
.dbg-ok .dbg-badge      { background: #f0fdf4; color: #15803d; }
.dbg-failed .dbg-badge  { background: #fffbeb; color: #b45309; }
.dbg-error .dbg-badge   { background: #fef2f2; color: #b91c1c; }
.dbg-info .dbg-badge    { background: #f5f3ff; color: #6d28d9; }

.dbg-ms {
  margin-left: auto;
  color: #9ca3af;
  font-size: 10.5px;
}

.dbg-args {
  margin-top: 4px;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 8px;
}

.dbg-args .k { color: #6b7280; }
.dbg-args .v { color: #0f766e; overflow-wrap: anywhere; }
.dbg-noargs { color: #9ca3af; margin-top: 4px; }

.dbg-msg {
  margin-top: 5px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #f9fafb;
  color: #374151;
  overflow-wrap: anywhere;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11.5px;
}

.dbg-error .dbg-msg { background: #fee2e2; color: #991b1b; }
.dbg-failed .dbg-msg { background: #fef3c7; color: #92400e; }

/* verify_voice match score */
.dbg-score {
  margin-top: 6px;
  padding: 7px 9px;
  border-radius: 6px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.dbg-score-match { background: #f0fdf4; color: #166534; }
.dbg-score-miss  { background: #fff7ed; color: #9a3412; }

.dbg-score-line {
  font-weight: 600;
  font-size: 12px;
}

.dbg-meter {
  position: relative;
  height: 8px;
  margin: 6px 0 4px;
  border-radius: 9999px;
  background: #e5e7eb;
  overflow: visible;
}

.dbg-meter-fill {
  height: 100%;
  border-radius: 9999px;
}

.dbg-score-match .dbg-meter-fill { background: #22c55e; }
.dbg-score-miss .dbg-meter-fill  { background: #f97316; }

/* the threshold, drawn as a tick across the bar */
.dbg-meter-mark {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 14px;
  margin-left: -1px;
  background: #111827;
}

.dbg-score-per {
  font-size: 10.5px;
  opacity: 0.85;
}

.dbg-result {
  margin-top: 5px;
}

.dbg-result summary {
  cursor: pointer;
  color: #6b7280;
  font-size: 10.5px;
  user-select: none;
}

.dbg-result pre {
  margin-top: 4px;
  padding: 6px 8px;
  max-height: 220px;
  overflow: auto;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 10.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Start / End Session buttons: accent color on hover, tap and loading ─── */
.accent-text,
.group:hover .accent-hover-text,
.group:active .accent-hover-text {
  color: var(--accent);
}

.accent-hover-border:hover,
.accent-hover-border:active {
  border-color: color-mix(in srgb, var(--accent) 45%, white);
}
