/* Spectrum Studio Client Portal */
:root {
  --bg: #0C0C0A;
  --surface: #151514;
  --surface2: #1e1e1c;
  --surface3: #262624;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --accent: #D96B2E;
  --accent-dim: rgba(217,107,46,0.15);
  --accent-hover: #e8783c;
  --text: #f0f0ee;
  --muted: #888884;
  --muted2: #5a5a56;
  --success: #3db87a;
  --warning: #e8b84b;
  --danger: #e05555;
  --info: #5b9bd5;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Loading ── */
#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  flex-direction: column;
  gap: 16px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth screen ── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.auth-box {
  width: 100%;
  max-width: 420px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}
.auth-brand svg {
  color: var(--accent);
}
.auth-brand h1 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 12px;
}
.auth-brand p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ── App shell ── */
#app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--text);
}
.topbar-brand .logo-mark {
  width: 28px; height: 28px;
  position: relative;
  flex-shrink: 0;
}
.topbar-brand .logo-mark svg { width: 28px; height: 28px; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.topbar-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
}
.topbar-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.badge-admin {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.btn-signout {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-signout:hover {
  color: var(--text);
  border-color: var(--border2);
  background: var(--surface2);
}

/* ── Sidebar ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar-section {
  padding: 8px 16px 4px;
}
.sidebar-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted2);
  padding: 0 4px;
  margin-bottom: 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.875rem;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--text); background: var(--accent-dim); }
.nav-link.active svg { opacity: 1; color: var(--accent); }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── Main content ── */
.main {
  overflow-y: auto;
  padding: 28px 32px;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.page-subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.stat-value.accent { color: var(--accent); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
}
.card-body {
  padding: 20px;
}

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.row-link { cursor: pointer; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { background: var(--surface3); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-danger {
  background: rgba(224,85,85,0.15);
  color: var(--danger);
  border: 1px solid rgba(224,85,85,0.3);
}
.btn-danger:hover { background: rgba(224,85,85,0.25); }
.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Status badges ── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-active { color: var(--success); background: rgba(61,184,122,0.12); }
.status-pending { color: var(--warning); background: rgba(232,184,75,0.12); }
.status-approved { color: var(--success); background: rgba(61,184,122,0.12); }
.status-changes_requested { color: var(--danger); background: rgba(224,85,85,0.12); }
.status-in_progress { color: var(--info); background: rgba(91,155,213,0.12); }
.status-complete { color: var(--muted); background: var(--surface2); }
.status-on_hold { color: var(--muted); background: var(--surface2); }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Forms ── */
.form-group {
  margin-bottom: 18px;
}
label {
  display: block;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}
input[type=text], input[type=email], select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 90px; }
select { cursor: pointer; }
select option { background: var(--surface2); }
.form-hint {
  font-size: 0.78rem;
  color: var(--muted2);
  margin-top: 5px;
}
.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 5px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slide-up 0.2s ease;
}
@keyframes slide-up { from { transform: translateY(12px); opacity: 0; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }

/* ── Comment thread ── */
.comments { display: flex; flex-direction: column; gap: 12px; }
.comment {
  display: flex;
  gap: 10px;
}
.comment-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}
.comment-body {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.comment-author { font-size: 0.8rem; font-weight: 600; }
.comment-time { font-size: 0.75rem; color: var(--muted2); }
.comment-text { font-size: 0.875rem; color: var(--text); }
.comment-form {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  align-items: flex-end;
}
.comment-form textarea { min-height: 60px; }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty svg { opacity: 0.3; margin-bottom: 12px; }
.empty h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 0.875rem; }

/* ── Concept card ── */
.concepts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.concept-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.concept-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.concept-thumb {
  height: 160px;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.concept-thumb img { width: 100%; height: 100%; object-fit: cover; }
.concept-thumb-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted2);
  font-size: 0.78rem;
}
.concept-info { padding: 14px; }
.concept-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.concept-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 8px; }

/* ── Alert ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}
.alert-info { background: rgba(91,155,213,0.1); border: 1px solid rgba(91,155,213,0.25); color: var(--info); }
.alert-success { background: rgba(61,184,122,0.1); border: 1px solid rgba(61,184,122,0.25); color: var(--success); }
.alert-warning { background: rgba(232,184,75,0.1); border: 1px solid rgba(232,184,75,0.25); color: var(--warning); }
.alert-danger { background: rgba(224,85,85,0.1); border: 1px solid rgba(224,85,85,0.25); color: var(--danger); }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  animation: slide-toast 0.2s ease;
  pointer-events: auto;
  min-width: 240px;
  max-width: 320px;
}
@keyframes slide-toast { from { transform: translateX(20px); opacity: 0; } }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }

/* ── Util ── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 0.825rem; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Responsive ── */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
  }
  .sidebar {
    display: none;
  }
  .main {
    padding: 20px 16px;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
