/* 1. THEME & TYPOGRAPHY DEFINITION */
:root {
  /* Brand / Primary Surfaces */
  --bg-primary: #050712;    /* Main page background */
  --bg-surface: #101322;    /* Main cards */
  --bg-surface-alt: #171a2a; /* Secondary/Input background (Old --bg-tertiary) */

  /* Borders */
  --border-subtle: #25273b; /* Old --border-color */
  --border-strong: #3b3f5c;

  /* Text */
  --text-primary: #F9FAFB;
  --text-secondary: #D1D5DB;
  --text-muted: #9CA3AF;    /* Old --text-tertiary */
  --text-subtle: #6B7280;

  /* Accent (Brand / Action) */
  --accent-start: #6A11CB;
  --accent-end: #2575FC;
  --accent-gradient: linear-gradient(90deg, var(--accent-start) 0%, var(--accent-end) 100%);
  --accent-gradient-hover: linear-gradient(90deg, #7B22DD 0%, #3685FF 100%);

  /* Semantic / Priority */
  --priority-high: #EF4444; /* Error */
  --priority-medium: #F97316; /* Warning */
  --priority-low: #22C55E;  /* Success */

  /* Typography & Spacing */
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --border-radius-base: 0.75rem; /* New, larger radius (12px) */
}

/* 2. GLOBAL RESETS & STYLES */
body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 2rem;
  display: flex;
  justify-content: center;
}

.container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem; /* Reduced gap for tighter layout */
  width: 100%;
  max-width: 1200px;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

aside {
  background-color: var(--bg-surface); /* New: --bg-surface */
  border-radius: var(--border-radius-base); /* New radius */
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: fit-content;
  border: 1px solid var(--border-subtle); /* Added consistent border */
}

h2 {
  font-size: 1.25rem; /* text-xl */
  margin: 0;
  font-weight: 600;
}

h3 {
  font-size: 1.125rem; /* text-lg */
  margin: 0;
  font-weight: 600;
}

/* 3. COMPONENT STYLING */
.card {
  background-color: var(--bg-surface); /* New: --bg-surface */
  border-radius: var(--border-radius-base); /* New radius */
  padding: 1.5rem;
  border: 1px solid var(--border-subtle); /* New: --border-subtle */
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35); /* Subtle shadow */
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  /* New status dot style: no inner shadow, rely on color and size */
}

.status-on {
  background-color: var(--priority-low); /* Green */
}

.status-off {
  background-color: var(--priority-high); /* Red */
}

.status-connecting {
  background-color: var(--priority-medium); /* Orange */
  animation: pulse 1.5s infinite;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.75rem; /* text-xs */
  font-weight: 500;
  color: var(--text-muted); /* New: --text-muted */
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input,
select,
textarea {
  font-size: 1rem;
  padding: 0.75rem 0.875rem; /* Slightly more padding */
  background-color: var(--bg-surface-alt); /* New: --bg-surface-alt */
  border: 1px solid var(--border-subtle); /* New: --border-subtle */
  border-radius: var(--border-radius-base); /* New radius */
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-end);
  box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.3);
}

button {
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-base); /* New radius */
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

#start,
#saveCoach {
  color: white;
  background: var(--accent-gradient);
  box-shadow: 0 4px 10px rgba(106, 17, 203, 0.3);
}

#start:hover,
#saveCoach:hover {
  background: var(--accent-gradient-hover);
  transform: scale(1.01); /* Subtle hover effect */
}

#start:active,
#saveCoach:active {
  transform: translateY(1px); /* Subtle active effect */
}

/* 4. LIVE COACH & TRANSCRIPT STYLING */
#coach {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-base);
  padding: 1.5rem;
  min-height: 120px;
  font-size: 1rem;
  transition: all 0.3s ease;
}

#coach em {
  color: var(--text-secondary);
}

/* New coach advice styling */
.coach-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.coach-category {
  font-size: 0.875rem; /* text-sm */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.coach-priority-high {
  color: var(--priority-high);
}

.coach-priority-medium {
  color: var(--priority-medium);
}

.coach-priority-low {
  color: var(--priority-low);
}

.coach-time {
  font-size: 0.75rem; /* text-xs */
  color: var(--text-muted); /* New: --text-muted */
}

.coach-headline {
  font-weight: 600;
  font-size: 1.125rem; /* text-lg */
  margin-bottom: 0.5rem;
}

.coach-advice-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.coach-microscript {
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--bg-surface-alt); /* New: --bg-surface-alt */
  border-radius: 0.5rem;
  font-size: 0.875rem; /* text-sm */
}

.coach-microscript strong {
  color: var(--text-primary);
}

.coach-microscript code {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.coach-talk-share {
  font-size: 0.75rem; /* text-xs */
  color: var(--text-muted); /* New: --text-muted */
  margin-top: 1rem;
}

#log {
  font-family: var(--font-sans);
  border: 1px solid var(--border-subtle);
  padding: 1rem;
  border-radius: var(--border-radius-base);
  margin-top: 1rem;
  max-height: 50vh;
  overflow-y: auto;
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* System log lines (status, errors) */
#log .log-line-system {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

#log .log-line-system:last-child {
  border-bottom: none;
}

.ok {
  color: var(--priority-low);
}

.err {
  color: var(--priority-high);
}

/* 5. AUTH PAGE LAYOUT & UTILITIES */
.auth-page {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.auth-card {
  margin-top: 6vh;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 1.25rem 0;
}

.tab {
  background: var(--bg-surface-alt); /* New: --bg-surface-alt */
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-base);
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.tab-active {
  background: var(--accent-gradient);
  color: white;
}

.tab-panel[hidden] { display: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-base);
  padding: 0.75rem 1.5rem; /* Match primary button size */
}

.btn-link {
  color: var(--accent-end); /* Use accent color for links */
  text-decoration: none;
}
.btn-link:hover { text-decoration: underline; }

.auth-footer {
  display: flex;
  align-items: center;
  margin-top: 1rem;
}
.spacer { flex: 1; }

.notice {
  border-radius: var(--border-radius-base);
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  margin: 0.5rem 0 1rem 0;
  font-size: 0.95rem;
}
.notice-info { border-color: #2f5aa5; background: #1a2740; color: #cdd9ff; }
.notice-success { border-color: color-mix(in srgb, var(--priority-low) 50%, transparent); background: color-mix(in srgb, var(--priority-low) 10%, transparent); color: #c7f9df; }
.notice-error { border-color: color-mix(in srgb, var(--priority-high) 50%, transparent); background: color-mix(in srgb, var(--priority-high) 10%, transparent); color: #ffd2d2; }

/* 6. Inline-style replacements and Utilities */
.helper-text {
  font-size: 0.875rem; /* text-sm */
  color: var(--text-muted); /* New: --text-muted */
  margin: 0;
}

.status-text {
  text-align: center;
  font-size: 0.75rem; /* text-xs */
  color: var(--text-muted);
}

.minw-160 {
  min-width: 160px;
}

hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1rem 0;
}

/* Transcript lines */
.log-line-transcript {
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  margin-bottom: 0.25rem;
  background-color: var(--bg-surface-alt);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Differentiate your speech vs prospect */
.log-line-transcript.log-line-you {
  border-left: 2px solid var(--priority-low); /* green-ish */
}

.log-line-transcript.log-line-prospect {
  border-left: 2px solid var(--accent-start);
}

.log-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.log-speaker-pill {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border-subtle);
}

.log-speaker-pill.speaker-you {
  border-color: var(--priority-low);
  color: var(--priority-low);
}

.log-speaker-pill.speaker-prospect {
  border-color: var(--accent-end);
  color: var(--accent-end);
}

.log-time {
  font-size: 0.7rem;
  color: var(--text-subtle);
}

.log-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* If you decide to show partials later, fade them */
.log-line-partial {
  opacity: 0.6;
}

/* Badge styling (reuse pattern from main page) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge-muted {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.badge-success {
  background: rgba(34, 197, 94, 0.14);
  color: #22c55e;
}

/* Summary card text */
.summary-text {
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0.25rem 0 0;
}

.summary-text.muted {
  color: var(--text-muted);
}

.summary-context {
  max-height: 180px;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background-color: rgba(15, 23, 42, 0.5); /* subtle surface */
  border: 1px solid var(--border-subtle);
}

/* Disabled primary button visual */
button[disabled],
.btn-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* SPIN Tracker Styles */
.spin-item { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 8px; border-radius: 8px; border: 1px solid transparent; background: rgba(255,255,255,0.02); transition: all 0.3s ease; opacity: 0.5; }
.spin-item.active { opacity: 1; background: rgba(37, 99, 235, 0.1); border-color: rgba(37, 99, 235, 0.4); box-shadow: 0 0 15px rgba(37, 99, 235, 0.15); transform: translateX(5px); }
.spin-letter { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.1); border-radius: 6px; font-weight: 800; font-size: 0.9rem; color: #fff; }
.spin-item.active .spin-letter { background: #3b82f6; }
.spin-title { font-weight: 600; font-size: 0.9rem; color: #e5e7eb; }
.spin-desc { font-size: 0.75rem; color: #6b7280; }

/* Pain Matrix */
.pain-card {
  background: rgba(255,255,255,0.03);
  border-left: 3px solid #64748b;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 0 6px 6px 0;
}
.pain-card.status-SURFACE { border-color: #fbbf24; }
.pain-card.status-PROBLEM { border-color: #f97316; }
.pain-card.status-IMPLICATION { border-color: #22c55e; }
.pain-card.status-SOLVED { border-color: #22c55e; }
.pain-label { color: #e2e8f0; font-size: 0.85rem; font-weight: 500; }
.pain-status { font-size: 0.65rem; text-transform: uppercase; opacity: 0.7; letter-spacing: 0.05em; }

/* Bridge / Pitch */
.btn-bridge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #000;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-bridge:hover { transform: scale(1.03); box-shadow: 0 0 15px rgba(245, 158, 11, 0.4); }
.btn-bridge.active-phase { background: linear-gradient(135deg, #22c55e, #16a34a); color: #052e16; }

.strategy-card {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 10px;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: slideInRight 0.4s ease-out;
}
.strategy-icon { font-size: 1rem; }
.strategy-text { font-size: 0.9rem; color: #fff; line-height: 1.4; }
