/* ============================================================
   DESIGN SYSTEM — matches ai-receptionist-agent exactly
   ============================================================ */
:root {
  --bg: #020617;
  --surface: rgba(30, 41, 59, 0.7);
  --surface-solid: #1e293b;
  --border: rgba(148, 163, 184, 0.1);
  --border-hover: rgba(148, 163, 184, 0.25);
  --ink: #f8fafc;
  --muted: #94a3b8;
  --brand: #22d3ee;
  --brand-glow: rgba(34, 211, 238, 0.5);
  --brand-deep: #0891b2;
  --brand-tint: rgba(34, 211, 238, 0.08);
  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.5);
  --radius: 12px;
  --radius-sm: 6px;
  --font-head: "Outfit", sans-serif;
  --font-body: "DM Sans", sans-serif;
  --topbar-h: 64px;
  --star-gold: #fbbf24;
  --positive: #34d399;
  --positive-bg: rgba(52, 211, 153, 0.1);
  --neutral: #fbbf24;
  --neutral-bg: rgba(251, 191, 36, 0.1);
  --negative: #f87171;
  --negative-bg: rgba(248, 113, 113, 0.1);
  color-scheme: dark;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden; /* dashboard fills viewport */
}

h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: var(--font-body); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(2, 6, 23, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}
.logo:hover { text-decoration: none; color: var(--brand); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--brand);
  color: #020617;
  font-weight: 700;
}
.btn-primary:hover { box-shadow: 0 0 16px var(--brand-glow); }

.btn-secondary {
  background: var(--surface-solid);
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--brand); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--border-hover); }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dashboard {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - var(--topbar-h));
  margin-top: var(--topbar-h);
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  background: rgba(15, 23, 42, 0.8);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Paste section */
.paste-section {
  border-bottom: 1px solid var(--border);
  padding: 1rem;
}

.paste-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand);
  border: 1px solid var(--border);
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.paste-header:hover { background: var(--brand-tint); border-color: var(--brand); }

.paste-chevron {
  transition: transform 0.2s;
  font-size: 1.1rem;
  line-height: 1;
}
.paste-chevron.open { transform: rotate(90deg); }

.paste-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.75rem;
}

.paste-name {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}
.paste-name:focus { border-color: var(--brand); }

.paste-textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.6rem 0.75rem;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: border-color 0.15s;
}
.paste-textarea:focus { border-color: var(--brand); }
.paste-textarea::placeholder { color: var(--muted); }
.paste-name::placeholder { color: var(--muted); }

/* Star input */
.star-input {
  display: flex;
  gap: 0.2rem;
}

.star-btn {
  background: none;
  border: none;
  color: var(--border-hover);
  font-size: 1.4rem;
  padding: 0;
  line-height: 1;
  transition: color 0.1s;
}
.star-btn.active { color: var(--star-gold); }
.star-btn:hover { color: var(--star-gold); }

/* Sidebar divider */
.sidebar-divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 0.75rem 1rem;
}

/* Review list */
.review-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0.75rem 1rem;
}

.review-sample {
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 0.4rem;
}
.review-sample:hover {
  background: var(--brand-tint);
  border-color: var(--border);
}
.review-sample.active {
  background: var(--brand-tint);
  border-color: var(--brand);
}

.sample-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.25rem;
}

.sample-reviewer {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink);
}

.sample-stars {
  color: var(--star-gold);
  font-size: 0.75rem;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.sample-preview {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
   MAIN PANEL
   ============================================================ */
.main-panel {
  overflow-y: auto;
  padding: 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.main-panel::-webkit-scrollbar { width: 4px; }
.main-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
  gap: 1rem;
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.4;
}

.empty-state h2 {
  font-size: 1.5rem;
  color: var(--ink);
}

.empty-state p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Review panel */
.review-panel {
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Review card */
.review-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.review-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  gap: 1rem;
}

.reviewer-name {
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.2rem;
}

.stars {
  color: var(--star-gold);
  font-size: 1rem;
  letter-spacing: 2px;
}

.sentiment-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.sentiment-badge.positive { background: var(--positive-bg); color: var(--positive); }
.sentiment-badge.neutral  { background: var(--neutral-bg);  color: var(--neutral); }
.sentiment-badge.negative { background: var(--negative-bg); color: var(--negative); }
.sentiment-badge.analyzing { background: var(--surface); color: var(--muted); }

.review-text {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.topics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 1.5rem;
}

.topic-badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--brand);
  border: 1px solid rgba(34, 211, 238, 0.2);
}

/* Tone section */
.tone-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tone-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.tone-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tone-btn {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}
.tone-btn:hover {
  border-color: var(--brand);
  color: var(--ink);
  background: var(--brand-tint);
}
.tone-btn.active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-tint);
  font-weight: 700;
}

/* Draft button */
.draft-btn {
  align-self: flex-start;
  padding: 0.65rem 1.5rem;
  font-size: 0.95rem;
}

/* Response section */
.response-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.response-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.word-count {
  font-size: 0.8rem;
  color: var(--muted);
  transition: color 0.2s;
}
.word-count.warning { color: var(--neutral); }
.word-count.over    { color: var(--negative); }

.draft-area {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.7;
  padding: 1rem 1.25rem;
  resize: vertical;
  min-height: 140px;
  outline: none;
  transition: border-color 0.15s;
}
.draft-area:focus { border-color: var(--brand); }

.action-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.copy-btn.copied {
  background: rgba(52, 211, 153, 0.15);
  color: var(--positive);
  border-color: var(--positive);
}

/* Error message */
.error-msg {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--negative);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(2, 6, 23, 0.3);
  border-top-color: #020617;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   SKIP LINK (accessibility)
   ============================================================ */
.skip-link {
  position: absolute;
  top: -999px;
  left: 0;
  background: var(--brand);
  color: #020617;
  padding: 0.5rem 1rem;
  font-weight: 700;
  z-index: 9999;
}
.skip-link:focus { top: 0; }

/* ============================================================
   RESPONSIVE — mobile
   ============================================================ */
@media (max-width: 768px) {
  body { overflow: auto; }

  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: calc(100vh - var(--topbar-h));
    overflow: visible;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
    overflow-y: auto;
  }

  .main-panel {
    padding: 1.25rem;
    overflow: visible;
  }

  .empty-state { min-height: 50vh; }

  .tone-group { flex-wrap: wrap; }
  .tone-btn { flex: 1 1 calc(50% - 0.25rem); }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
