/* ═══════════════════════════════════════════════════
   DISCOURSE FORUM — Modern Dark Theme
   ═══════════════════════════════════════════════════ */

/* ── Reset & Base ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f1117;
  --bg-card:      #1a1d27;
  --bg-elevated:  #21242f;
  --bg-hover:     #262a36;
  --border:       #2a2e3a;
  --text:         #e1e4ec;
  --text-muted:   #8b8fa3;
  --text-dim:     #5c6072;
  --primary:      #6366f1;
  --primary-hover:#818cf8;
  --primary-bg:   rgba(99,102,241,0.12);
  --accent:       #22d3ee;
  --success:      #34d399;
  --warning:      #fbbf24;
  --danger:       #f87171;
  --danger-bg:    rgba(248,113,113,0.12);
  --pin-bg:       rgba(250,204,21,0.08);
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 4px 24px rgba(0,0,0,0.3);
  --font:         'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary-hover); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent); }

h1, h2, h3 { font-weight: 600; line-height: 1.3; color: #fff; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

p { margin-bottom: 0.75rem; }

small { font-size: 0.8rem; color: var(--text-muted); }

/* ── Layout ─────────────────────────────────── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.page-header {
  margin: 2rem 0 1.5rem;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

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

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { margin: 0 0.4rem; color: var(--text-dim); }

/* ── Navbar ─────────────────────────────────── */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 1rem;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff !important;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-form input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  width: 180px;
  transition: border-color 0.2s, width 0.2s;
}
.search-form input:focus {
  outline: none;
  border-color: var(--primary);
  width: 220px;
}
.search-form input::placeholder { color: var(--text-dim); }

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text) !important;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-outline:hover { color: var(--text); border-color: var(--text-dim); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Avatars ────────────────────────────────── */
.avatar-sm, .avatar-lg, .avatar-xl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-sm  { width: 32px; height: 32px; font-size: 0.8rem; }
.avatar-lg  { width: 48px; height: 48px; font-size: 1.15rem; }
.avatar-xl  { width: 72px; height: 72px; font-size: 1.75rem; }

/* ── Badges ─────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
}
.badge-admin {
  background: var(--primary-bg);
  color: var(--primary-hover);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-pin, .badge-lock { font-size: 0.9rem; }

/* ── Flash messages ─────────────────────────── */
.flash-container {
  max-width: 960px;
  margin: 0.75rem auto 0;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

.flash-success  { background: rgba(52,211,153,0.1);  border-color: rgba(52,211,153,0.3);  color: var(--success); }
.flash-error    { background: rgba(248,113,113,0.1);  border-color: rgba(248,113,113,0.3);  color: var(--danger); }
.flash-info     { background: rgba(99,102,241,0.1);   border-color: rgba(99,102,241,0.3);   color: var(--primary-hover); }

/* ── Categories Grid ────────────────────────── */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
  margin-bottom: 2.5rem;
}

.category-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  color: var(--text) !important;
}
.category-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.cat-icon { font-size: 1.8rem; margin-bottom: 0.5rem; }
.cat-info h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.cat-info p { color: var(--text-muted); font-size: 0.83rem; margin-bottom: 0.5rem; }

.cat-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.cat-latest {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.cat-latest .latest-title {
  color: var(--text);
  font-weight: 500;
  font-size: 0.82rem;
}

/* ── Topic List ─────────────────────────────── */
.topic-list { display: flex; flex-direction: column; gap: 2px; }

.topic-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s;
}
.topic-row:hover { background: var(--bg-hover); border-color: var(--text-dim); }
.topic-row.pinned { background: var(--pin-bg); border-color: rgba(250,204,21,0.18); }

.topic-main { flex: 1; min-width: 0; }
.topic-title-line { display: flex; align-items: center; gap: 0.35rem; }

.topic-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topic-title:hover { color: var(--primary-hover) !important; }

.topic-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.topic-meta a { color: var(--text-muted); }
.topic-meta a:hover { color: var(--text); }

.cat-tag {
  background: var(--bg-elevated);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--text-muted) !important;
}

.topic-replies {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}
.reply-count { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.topic-list.compact .topic-row { padding: 0.5rem 0.75rem; }

.recent-section { margin-top: 1rem; }
.recent-section h2 { margin-bottom: 0.75rem; }

/* ── Posts ──────────────────────────────────── */
.post-card {
  display: flex;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 0.6rem;
}

.original-post {
  border-left: 3px solid var(--primary);
}

.post-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 80px;
  max-width: 100px;
}

.post-username {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text) !important;
  text-align: center;
  word-break: break-word;
}

.post-body { flex: 1; min-width: 0; }

.post-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.post-meta a { color: var(--text-muted); }
.edited { font-style: italic; }

.post-content {
  font-size: 0.93rem;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.post-content p { margin-bottom: 0.75rem; }
.post-content p:last-child { margin-bottom: 0; }
.post-content code {
  background: var(--bg-elevated);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.post-content pre {
  background: #0d0f15;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
}
.post-content pre code {
  background: none;
  padding: 0;
}
.post-content strong { color: #fff; }

.post-actions {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* ── Reply Form ─────────────────────────────── */
.reply-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.5rem;
}
.reply-section h3 { margin-bottom: 0.75rem; }

.reply-form textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.2s;
}
.reply-form textarea:focus { outline: none; border-color: var(--primary); }
.reply-form textarea::placeholder { color: var(--text-dim); }

.reply-form .btn { margin-top: 0.75rem; }

.format-hint {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 0.6rem;
}

.locked-notice, .login-prompt {
  text-align: center;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1.5rem;
  color: var(--text-muted);
}

/* ── Topic Form ─────────────────────────────── */
.topic-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

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

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
  width: auto;
  accent-color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* ── Auth Pages ─────────────────────────────── */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 160px);
  padding: 2rem 0;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card h1 { text-align: center; margin-bottom: 0.25rem; }
.auth-card .subtitle { text-align: center; margin-bottom: 1.5rem; }

.auth-form { margin-top: 1rem; }
.auth-form .btn { margin-top: 0.5rem; }

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

/* ── Profile ────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.profile-info { flex: 1; }
.profile-info h1 { display: inline; margin-right: 0.5rem; }

.profile-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}
.profile-bio {
  margin-top: 0.6rem;
  color: var(--text);
  font-size: 0.9rem;
}

.profile-sections { display: flex; flex-direction: column; gap: 1.5rem; margin-top: 1.5rem; }
.profile-sections section h2 { margin-bottom: 0.6rem; }

/* ── Search ─────────────────────────────────── */
.search-snippet {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.5;
}

/* ── Pagination ─────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 0;
}
.page-info { color: var(--text-muted); font-size: 0.85rem; }

/* ── Error Page ─────────────────────────────── */
.error-page {
  text-align: center;
  padding: 4rem 0;
}
.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--primary);
  opacity: 0.3;
  line-height: 1;
}

/* ── Empty States ───────────────────────────── */
.empty, .empty-state {
  text-align: center;
  padding: 2.5rem;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state .btn { margin-top: 0.75rem; }

/* ── Footer ─────────────────────────────────── */
.footer {
  text-align: center;
  padding: 2rem 0;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
}

.footer-stats { margin-bottom: 0.4rem; }
.footer-stats .sep { margin: 0 0.4rem; }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
  .nav-inner { flex-wrap: wrap; height: auto; padding: 0.75rem 1rem; gap: 0.5rem; }
  .nav-links { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .search-form input { width: 120px; }
  .search-form input:focus { width: 150px; }

  .categories-grid { grid-template-columns: 1fr; }
  .post-card { flex-direction: column; }
  .post-sidebar { flex-direction: row; min-width: auto; max-width: none; gap: 0.6rem; }
  .profile-header { flex-direction: column; text-align: center; }
  .header-row { flex-direction: column; }
  .topic-replies { display: none; }
  .topic-meta { font-size: 0.72rem; }

  .auth-card { padding: 1.5rem; }
}
