/* ==========================================================================
   Live Call Transcript Pro — Production Static Web App Styles
   ========================================================================== */

:root {
  --bg: #080c17;
  --bar: #0e1526;
  --card: #131c31;
  --card-hover: #17223b;
  --input: #192540;
  --border: #263554;
  --border-subtle: #1d2942;
  --text: #eef2ff;
  --muted: #94a3b8;
  --accent: #638cff;
  --accent-hover: #7da0ff;
  --accent2: #a87ffb;
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245, 158, 11, 0.12);
  --red: #f43f5e;
  --red-bg: rgba(244, 63, 94, 0.12);
  --client: #38bdf8;
  --client-bg: rgba(56, 189, 248, 0.1);
  --agent: #c084fc;
  --agent-bg: rgba(192, 132, 252, 0.1);
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --radius: 10px;
  --radius-sm: 7px;
}

html[data-theme="light"] {
  --bg: #f1f5f9;
  --bar: #ffffff;
  --card: #ffffff;
  --card-hover: #f8fafc;
  --input: #f1f5f9;
  --border: #cbd5e1;
  --border-subtle: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent2: #7c3aed;
  --green: #059669;
  --green-bg: rgba(5, 150, 105, 0.1);
  --yellow: #d97706;
  --yellow-bg: rgba(217, 119, 6, 0.1);
  --red: #e11d48;
  --red-bg: rgba(225, 29, 72, 0.1);
  --client: #0284c7;
  --client-bg: rgba(2, 132, 199, 0.08);
  --agent: #7e22ce;
  --agent-bg: rgba(126, 34, 206, 0.08);
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, select, input, textarea {
  font: inherit;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease, transform 0.08s ease;
}

button, select {
  cursor: pointer;
  padding: 6px 11px;
  font-size: 0.84rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

button:hover:not(:disabled), select:hover:not(:disabled) {
  border-color: var(--accent);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled, select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #ffffff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(99, 140, 255, 0.25);
}

button.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

button.stop {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
  font-weight: 600;
}

button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

button.subtle {
  background: transparent;
  border-color: var(--border-subtle);
}

button.subtle:hover:not(:disabled) {
  background: var(--input);
  border-color: var(--border);
}

.app {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header & Top Navigation */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bar);
  z-index: 10;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.brand {
  font-weight: 700;
  font-size: 0.96rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.badge-pro {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(99, 140, 255, 0.16);
  color: var(--accent);
  border: 1px solid rgba(99, 140, 255, 0.3);
}

.status {
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status.live {
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.35);
  background: var(--green-bg);
}

.status.live .status-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulseDot 1.5s infinite;
}

.status.warn {
  color: var(--yellow);
  border-color: rgba(245, 158, 11, 0.35);
  background: var(--yellow-bg);
}

.status.warn .status-dot {
  background: var(--yellow);
}

.status.error {
  color: var(--red);
  border-color: rgba(244, 63, 94, 0.35);
  background: var(--red-bg);
}

.status.error .status-dot {
  background: var(--red);
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* Live Audio Meter */
.meter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input);
  font-size: 0.75rem;
  color: var(--muted);
}

.meter-bar-track {
  width: 54px;
  height: 6px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.meter-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  transition: width 0.08s linear;
}

.timer {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--input);
  border: 1px solid var(--border-subtle);
}

.spacer {
  flex: 1;
}

/* Engine Pill Selector */
.engine-select {
  font-weight: 600;
  border-color: rgba(99, 140, 255, 0.4);
}

/* Secondary Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bar);
}

.seg {
  display: inline-flex;
  background: var(--bg);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 2px;
}

.seg button {
  border: none;
  background: transparent;
  padding: 4px 9px;
  border-radius: 5px;
  font-size: 0.8rem;
}

.seg button.active {
  background: var(--accent);
  color: #fff;
}

.seg button[data-speaker="Client"].active {
  background: var(--client);
  color: #062232;
  font-weight: 700;
}

.seg button[data-speaker="Agent"].active {
  background: var(--agent);
  color: #230638;
  font-weight: 700;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 150px;
  max-width: 280px;
}

.search {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.83rem;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* Main Workspace Layout */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

#feed {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 14px 16px;
  scroll-behavior: smooth;
}

/* Transcript Line Cards */
.line {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 11px 13px;
  margin-bottom: 8px;
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--client);
  border-radius: var(--radius);
  line-height: 1.52;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.line:hover {
  border-color: var(--border);
}

.line.agent {
  border-left-color: var(--agent);
}

.line.starred {
  background: color-mix(in srgb, var(--card), #fbbf24 8%);
  border-color: rgba(251, 191, 36, 0.35);
}

.line.interim {
  background: rgba(99, 140, 255, 0.04);
  border: 1px dashed var(--accent);
  border-left: 4px solid var(--accent);
}

.meta {
  color: var(--muted);
  font-size: 0.74rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
   align-items: flex-start;
}

.meta-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.speaker-tag {
  margin-top: 2px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 5px;
  background: var(--client-bg);
  color: var(--client);
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.line.agent .speaker-tag {
  background: var(--agent-bg);
  color: var(--agent);
  border-color: rgba(192, 132, 252, 0.28);
}

.engine-badge {
  font-size: 0.66rem;
  color: var(--muted);
  opacity: 0.8;
}

.text, .roman {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.93rem;
}

.roman {
  color: var(--muted);
  font-style: italic;
  margin-top: 4px;
  font-size: 0.86rem;
}

.roman.only {
  color: var(--text);
  font-style: normal;
  margin-top: 0;
  font-size: 0.93rem;
}

.highlight {
  background: rgba(251, 191, 36, 0.3);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.line-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: start;
  opacity: 0.75;
}

.line:hover .line-actions {
  opacity: 1;
}

.line-actions button {
  padding: 4px 7px;
  font-size: 0.78rem;
}

.edit-box {
  width: 100%;
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
  font-size: 0.92rem;
  line-height: 1.45;
}

.edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* Empty / Welcome State */
.empty {
  max-width: 680px;
  margin: 28px auto;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.empty h2 {
  color: var(--text);
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.quick-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 16px;
  text-align: left;
}

.quick-card {
  padding: 12px;
  border-radius: 10px;
  background: var(--input);
  border: 1px solid var(--border-subtle);
}

.quick-card b {
  color: var(--text);
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
}

.quick-card p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
}

/* Right Sidebar Panel */
aside {
  width: 340px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 12px;
  border-left: 1px solid var(--border);
  background: var(--bar);
}

aside[hidden] {
  display: none;
}

.section {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 10px;
}

.section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section p {
  margin: 6px 0;
  font-size: 0.8rem;
  line-height: 1.48;
  color: var(--muted);
}

.field-group {
  margin-bottom: 9px;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-group label {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.field-group select,
.field-group input[type="text"],
.field-group input[type="password"],
.field-group input[type="search"],
.field-group textarea {
  width: 100%;
  padding: 6px 9px;
  font-size: 0.82rem;
}

.field-group label.check {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  white-space: normal;
  line-height: 1.4;
  color: var(--text);
  font-size: 0.8rem;
  width: 100%;
}

.field-group label.check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  padding: 0;
  margin: 2px 0 0 0;
}

.field-group textarea {
  min-height: 54px;
  resize: vertical;
}

.field-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.stat {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--input);
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border-subtle);
}

.stat b {
  display: block;
  font-size: 0.98rem;
  color: var(--text);
  margin-bottom: 1px;
}

.kbd-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  font-size: 0.78rem;
  color: var(--muted);
  align-items: center;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Modal Dialog (Diagnostics & Cloud Setup & Deploy Guide) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 17, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bar);
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  line-height: 1.55;
  font-size: 0.86rem;
}

.modal-body h3 {
  margin: 14px 0 6px;
  font-size: 0.92rem;
  color: var(--accent);
}

.modal-body h3:first-child {
  margin-top: 0;
}

.diag-box {
  padding: 11px 13px;
  border-radius: 9px;
  background: var(--input);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.diag-box b {
  color: var(--text);
}

/* Toast Notification */
#toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  padding: 9px 14px;
  color: #ffffff;
  background: #059669;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive Adjustments */
@media (max-width: 860px) {
  aside {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(340px, 92vw);
    z-index: 20;
    box-shadow: var(--shadow);
  }

  .line {
    grid-template-columns: 1fr auto;
  }

  .meta {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }
}
