/* ── Dashboard Styles ─────────────────────────────────────────── */

:root {
  --primary: #e8503a;
  --primary-dark: #d03a25;
  --primary-light: #fef0ee;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --bg-white: #ffffff;
  --bg-light: #faf8f6;
  --bg-subtle: #f3f0ed;
  --border: #e8e2dc;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --status-new: #3b82f6;
  --status-responded: #22c55e;
  --status-flagged: #f97316;
  --status-published: #a855f7;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-dark);
  background: var(--bg-light);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Auth ────────────────────────────────────────────────────────── */

.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--bg-light) 0%, #fef0ee 100%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 2rem;
  color: var(--text-dark);
}

.auth-brand svg { width: 32px; height: 32px; }

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-align: center;
}

.auth-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-form .field { margin-bottom: 1rem; }

.auth-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.auth-form input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text-dark);
  background: var(--bg-white);
  transition: border-color 0.15s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,80,58,0.1);
}

.auth-error {
  color: #dc2626;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}

.auth-error.visible { display: block; }

.auth-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0.5rem;
}

.auth-btn:hover { background: var(--primary-dark); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.auth-footer a:hover { text-decoration: underline; }

/* ── Dashboard Shell ─────────────────────────────────────────────── */

.dash-shell { display: flex; min-height: 100vh; }

.dash-sidebar {
  width: 220px;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.dash-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border);
}

.dash-sidebar-brand svg { width: 28px; height: 28px; }

.dash-nav { list-style: none; padding: 0.75rem 0; flex: 1; }

.dash-nav li {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dash-nav li:hover { background: var(--bg-subtle); color: var(--text-dark); }
.dash-nav li.active { background: var(--primary-light); color: var(--primary); }

.dash-sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dash-sidebar-footer .user-email {
  display: block;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s;
  width: 100%;
}

.dash-logout-btn:hover { background: var(--bg-subtle); }

.dash-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  min-width: 0;
}

/* ── Top bar (mobile) ────────────────────────────────────────────── */

.dash-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
}

.dash-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
}

.dash-topbar-brand svg { width: 24px; height: 24px; }

.dash-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dark);
  padding: 0.25rem;
}

/* ── Metrics ─────────────────────────────────────────────────────── */

.metrics-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

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

.metric-card .metric-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-top: 0.25rem;
  line-height: 1.2;
}

/* ── Filter Tabs ─────────────────────────────────────────────────── */

.filter-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-white);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}

.filter-tab:hover { border-color: var(--primary); color: var(--primary); }

.filter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Review List ─────────────────────────────────────────────────── */

.reviews-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.review-list { display: flex; flex-direction: column; gap: 0.5rem; }

.review-item {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.review-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.review-item.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(232,80,58,0.15); }

.review-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.review-item-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-dark);
}

.review-item-time {
  font-size: 0.78rem;
  color: var(--text-light);
  white-space: nowrap;
}

.review-item-stars { color: #f59e0b; font-size: 0.85rem; letter-spacing: 1px; }

.review-item-excerpt {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Status Badge ────────────────────────────────────────────────── */

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
}

.status-badge.new { background: var(--status-new); }
.status-badge.responded { background: var(--status-responded); }
.status-badge.flagged { background: var(--status-flagged); }
.status-badge.published { background: var(--status-published); }

/* ── Review Detail ───────────────────────────────────────────────── */

.review-detail {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.review-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-light);
  font-size: 0.95rem;
}

.detail-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.detail-header-left { display: flex; align-items: center; gap: 0.75rem; }

.detail-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.detail-stars { color: #f59e0b; font-size: 1rem; }

.detail-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.detail-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  color: var(--text-dark);
}

.detail-btn:hover { border-color: var(--primary); color: var(--primary); }

.detail-btn.flag-btn:hover { border-color: var(--status-flagged); color: var(--status-flagged); }

.detail-btn.wall-active {
  background: var(--status-published);
  color: #fff;
  border-color: var(--status-published);
}

.detail-body { padding: 1.5rem; }

.detail-section { margin-bottom: 1.5rem; }
.detail-section:last-child { margin-bottom: 0; }

.detail-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.detail-transcript {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-dark);
}

.detail-audio { width: 100%; margin-top: 0.5rem; }
.detail-audio audio { width: 100%; border-radius: var(--radius-sm); }

/* ── Analysis Cards ──────────────────────────────────────────────── */

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.analysis-item {
  padding: 0.85rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}

.analysis-item.full-width { grid-column: 1 / -1; }

.analysis-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.analysis-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-dark);
}

.analysis-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.topic-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ── Response Editor ─────────────────────────────────────────────── */

.response-editor textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text-dark);
  resize: vertical;
  line-height: 1.6;
}

.response-editor textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,80,58,0.1);
}

.response-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.generate-btn {
  padding: 0.55rem 1.2rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.generate-btn:hover { background: var(--primary-dark); }
.generate-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.response-audio { margin-top: 0.75rem; }
.response-audio audio { width: 100%; border-radius: var(--radius-sm); }

/* ── Settings ────────────────────────────────────────────────────── */

.settings-view { max-width: 700px; }

.settings-section {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-dark);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.settings-row:last-child { margin-bottom: 0; }

.settings-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

.settings-value {
  font-size: 0.92rem;
  font-weight: 600;
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--text-dark);
}

.settings-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  color: var(--text-dark);
}

.settings-btn:hover { border-color: var(--primary); color: var(--primary); }

.settings-btn.danger { color: #dc2626; }
.settings-btn.danger:hover { border-color: #dc2626; }

.snippet-box {
  position: relative;
  margin-top: 0.5rem;
}

.snippet-code {
  display: block;
  width: 100%;
  padding: 0.85rem;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.snippet-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.3rem 0.6rem;
  background: rgba(255,255,255,0.15);
  color: #e2e8f0;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}

.snippet-copy:hover { background: rgba(255,255,255,0.25); }

.usage-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.usage-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s;
}

/* ── Empty / Loading ─────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.hidden { display: none !important; }

/* ── Toast ───────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--text-dark);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .reviews-layout { grid-template-columns: 1fr; }
  .metrics-bar { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .dash-sidebar { display: none; }
  .dash-sidebar.open { display: flex; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; box-shadow: var(--shadow-md); }
  .dash-topbar { display: flex; }
  .dash-main { padding: 1rem; }
  .metrics-bar { grid-template-columns: 1fr 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
  .detail-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .metrics-bar { grid-template-columns: 1fr; }
}

/* ── Onboarding Guide ───────────────────────────────────────────── */

.onboarding {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 0;
}

.onboarding-header {
  text-align: center;
  margin-bottom: 2rem;
}

.onboarding-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.onboarding-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.onboarding-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.step-number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.step-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.4rem;
}

.step-content p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.step-content p:last-child { margin-bottom: 0; }

.step-content ul {
  margin: 0.4rem 0 0.5rem 1.2rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.step-content a {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

.step-note {
  font-size: 0.82rem !important;
  color: var(--text-light) !important;
}

.onboarding-code {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  overflow-x: auto;
}

.onboarding-code code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-dark);
  white-space: pre;
  line-height: 1.6;
}

.onboarding-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.onboarding-btn:hover { background: var(--primary-dark); }

@media (max-width: 640px) {
  .onboarding-step { flex-direction: column; gap: 0.75rem; }
  .onboarding-code code { font-size: 0.7rem; }
}
