/* ============================================================
   Service Console — Lightning-style design tokens
   Mirrors the palette and spacing used by the email-bot console
   so the two simulators read as one product.
   ============================================================ */
:root {
  --brand: #0176d3;
  --brand-dark: #014486;
  --brand-header: #0b5fb3;
  --brand-soft: #eef4ff;

  --primary: #032d60;
  --secondary: #0176d3;
  --success: #2e844a;
  --warning: #fe9339;
  --danger: #ea001e;
  --light: #f3f2f2;
  --dark: #181818;

  --bg: #f3f2f2;
  --surface: #ffffff;
  --border: #c9c7c5;
  --border-soft: #e5e5e5;
  --text: #181818;
  --text-muted: #5c5c5c;
  --radius: 4px;
  --shadow-card: 0 2px 2px rgba(0, 0, 0, 0.05);
  --shadow-raised: 0 2px 8px rgba(0, 0, 0, 0.12);

  --header-h: 52px;
  --tabs-h: 40px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Salesforce Sans", "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

.hidden {
  display: none !important;
}

/* ---------- Inline SVG icons ---------- */
.icon-sprite {
  display: none;
}

.ico {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

/* ============================================================
   Global header
   ============================================================ */
.global-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--brand-header);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  z-index: 100;
}

.gh-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.gh-app-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: #fff;
  color: var(--brand-header);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.gh-app-name {
  font-size: 15px;
  letter-spacing: 0.2px;
}

.gh-search {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 30px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
}

.gh-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
}

.gh-search input::placeholder {
  color: rgba(255, 255, 255, 0.75);
}

.gh-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
}

.gh-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--brand-header);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* ============================================================
   Console workspace tabs
   ============================================================ */
.console-tabs {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  height: var(--tabs-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 8px;
  z-index: 99;
}

.console-tab,
.console-tab-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-right: 1px solid var(--border-soft);
  cursor: default;
  white-space: nowrap;
}

.console-tab.active {
  color: var(--brand);
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--brand);
  background: #fff;
}

.console-tab-add {
  border-right: none;
  color: var(--text-muted);
}

/* ============================================================
   Body shell
   ============================================================ */
/* The console fills the viewport and never scrolls as a page — individual
   panels scroll inside their own frame, the way a real console behaves. */
.console-body {
  display: flex;
  align-items: stretch;
  margin-top: calc(var(--header-h) + var(--tabs-h));
  height: calc(100vh - var(--header-h) - var(--tabs-h));
}

.nav-rail {
  width: 208px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-title {
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 16px 8px;
}

.nav-rail ul {
  list-style: none;
}

.nav-rail li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  color: #3e3e3c;
  font-size: 13px;
  cursor: default;
  border-left: 3px solid transparent;
}

.nav-rail li i {
  width: 14px;
  text-align: center;
  color: var(--text-muted);
}

.nav-rail li:hover {
  background: var(--light);
}

.nav-rail li.active {
  background: var(--brand-soft);
  border-left-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 600;
}

.nav-rail li.active i {
  color: var(--brand);
}

#app {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 16px;
  overflow-y: auto;
}

/* ============================================================
   Shared: cards, badges, fields
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: #fafaf9;
}

.card-header i {
  color: var(--brand);
  font-size: 13px;
}

.card-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.card-body {
  padding: 14px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
}

.badge-high {
  background: #feded8;
  color: #8e030f;
}

.badge-medium {
  background: #fff2cd;
  color: #7a4b00;
}

/* ============================================================
   Screen 1 — scenario list view
   ============================================================ */
.list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.list-header-icon,
.highlights-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.list-header-eyebrow,
.highlights-eyebrow {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.list-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.list-header-meta {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

.list-table {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.list-table-head,
.scenario-card {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr 1fr;
  align-items: center;
  gap: 6px 12px;
  padding: 10px 16px;
}

.list-table-head {
  background: #fafaf9;
  border-bottom: 1px solid var(--border-soft);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.scenario-card {
  position: relative;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.15s ease;
}

.scenario-card:last-child {
  border-bottom: none;
}

.scenario-card:hover {
  background: var(--brand-soft);
}

.cell-contact {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-hot {
  background: #ba0517;
}

.contact-text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.scenario-card h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
}

.contact-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.scenario-card p {
  font-size: 13px;
  color: var(--text);
}

.cell-channel,
.cell-status {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  display: inline-block;
}

/* "Strong language" flag — sits on its own line under the subject so it never
   collides with the status column */
.warning {
  grid-column: 2;
  grid-row: 2;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #feded8;
  color: #8e030f;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
}

.list-footnote {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   Screen 2 — chat console
   ============================================================ */
#chat-interface {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
  height: 100%;
  min-height: 560px;
}

.console-center {
  min-width: 0;
  /* Grid items default to min-height:auto, which would let the transcript push
     the column past the console height instead of scrolling inside it. */
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Record highlights panel */
.highlights {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.highlights-title h1,
.highlights-title h2,
.customer-profile h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
}

.highlights-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  margin-top: 4px;
}

.field-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.field-value,
.field p {
  font-size: 13px;
  color: var(--text);
}

/* Transcript — grows to fill the console, scrolls internally */
.chat-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

#chat-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fafaf9;
  border-bottom: 1px solid var(--border-soft);
}

/* The scroll lives on #chat-messages, not its wrapper: script.js pins new
   messages with chatMessages.scrollTop, which only works if this is the
   scrolling box. */
#chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 74%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  position: relative;
  box-shadow: var(--shadow-card);
}

.bot-message {
  background: #fff;
  border: 1px solid var(--border-soft);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.user-message {
  background: var(--brand);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.message-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
}

.user-message .message-time {
  color: rgba(255, 255, 255, 0.8);
}

.system-message {
  align-self: center;
  background: #ececec;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 12px;
}

.termination-message {
  background: #feded8;
  border: 1px solid #f5b7b1;
  border-left: 4px solid var(--danger);
  color: #8e030f;
}

/* Guided-mode option buttons */
.options-container {
  align-self: stretch;
  margin: 4px 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
}

.option-button {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  transition: all 0.15s ease;
}

.option-button:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* Evidence attachments */
.evidence-container {
  background: #fafaf9;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 10px;
}

.evidence-image {
  max-width: 100%;
  max-height: 200px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.evidence-image.enlarged {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: 80vh;
  max-width: 80vw;
  z-index: 1000;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.35);
}

.small {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
}

/* Violation toast — collapses when empty */
#violation-warnings {
  background: #feded8;
  border-bottom: 1px solid #f5b7b1;
  color: #8e030f;
  font-size: 12px;
  font-weight: 600;
  padding: 10px 16px;
}

#violation-warnings:empty {
  display: none;
}

/* Composer */
.input-area {
  padding: 12px 14px 14px;
  background: #fff;
}

.composer-toolbar {
  display: flex;
  gap: 2px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #fafaf9;
  padding: 4px 6px;
}

.composer-toolbar button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
}

.composer-toolbar button:hover {
  background: #ececec;
  color: var(--brand);
}

#user-input {
  display: block;
  width: 100%;
  min-height: 92px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  color: var(--text);
}

#user-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

#user-input:disabled {
  background: var(--light);
  color: var(--text-muted);
}

/* In guided mode script.js hides the textarea; the toolbar has to follow it,
   otherwise it floats above nothing. */
.input-area:has(#user-input[style*="none"]) .composer-toolbar {
  display: none;
}

.button-container {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

#send-btn,
#end-chat-btn,
#restart-btn,
.actions button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  height: 32px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#send-btn,
#restart-btn {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
}

#send-btn:hover,
#restart-btn:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

#end-chat-btn {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--brand);
}

#end-chat-btn:hover {
  background: var(--light);
}

#send-btn:disabled,
#end-chat-btn:disabled {
  background: #ececec;
  border-color: #dddbda;
  color: #a8a8a8;
  cursor: not-allowed;
}

/* ---------- Right console rail ---------- */
.console-rail {
  overflow-y: auto;
  min-height: 0;
}

.console-rail .card:last-child {
  margin-bottom: 0;
}

.omni-state {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.omni-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

#api-status {
  font-size: 12px;
  color: var(--text-muted);
}

.timers {
  display: flex;
  gap: 10px;
}

.timer {
  flex: 1;
  background: #fafaf9;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 8px 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.timer .countdown {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0;
  text-transform: none;
}

.score-display {
  text-align: center;
}

.score-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

#current-score {
  display: block;
  font-size: 30px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.2;
}

#star-rating {
  display: block;
  font-size: 16px;
  letter-spacing: 2px;
  color: #f5b800;
}

.rail-guide ul {
  list-style: none;
}

.rail-guide li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 7px;
  font-size: 12px;
  color: #3e3e3c;
  line-height: 1.45;
}

.rail-guide li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 5px;
  width: 8px;
  height: 4px;
  border-left: 2px solid var(--success);
  border-bottom: 2px solid var(--success);
  transform: rotate(-45deg);
}

/* ============================================================
   Screen 3 — results
   ============================================================ */
.results-highlights {
  grid-template-columns: auto 1fr;
}

.results-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.score-summary {
  text-align: center;
  padding: 20px 14px;
}

.score-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.score-text #final-score {
  font-size: 34px;
  font-weight: 700;
  color: var(--brand);
  display: block;
  line-height: 1.2;
}

.stars {
  font-size: 24px;
  letter-spacing: 3px;
  color: #f5b800;
  margin-top: 6px;
}

#violations-list {
  list-style: none;
}

#violations-list li {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fafaf9;
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  font-size: 13px;
}

#violations-list li:last-child {
  margin-bottom: 0;
}

.termination-warning {
  background: #feded8 !important;
  border-left-color: #8e030f !important;
  color: #8e030f;
  font-weight: 700;
}

#feedback-tips {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.feedback-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 14px;
}

.feedback-item.success {
  border-left-color: var(--success);
}

.feedback-item h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.feedback-item p {
  font-size: 12px;
  color: #3e3e3c;
  margin: 4px 0;
  line-height: 1.5;
}

.actions {
  display: flex;
  justify-content: center;
  margin: 24px 0 8px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  #chat-interface,
  .results-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Stacked, the console scrolls as one column again */
  #chat-interface {
    height: auto;
  }

  .chat-card {
    min-height: 460px;
  }

  .console-rail {
    overflow: visible;
  }
}

@media (max-width: 900px) {
  .nav-rail,
  .gh-search {
    display: none;
  }

  .list-table-head {
    display: none;
  }

  .scenario-card {
    grid-template-columns: 1fr 1fr;
    row-gap: 8px;
  }

  .highlights-fields {
    grid-template-columns: repeat(2, 1fr);
  }
}
