/* ============================================================
   ALGEBRIX — Forum CSS
   ============================================================ */

/* ── LAYOUT ───────────────────────────────────────────────── */
.forum-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  margin-top: var(--nav-h);
}

.forum-view { display: none; }
.forum-view.active { display: block; }

/* ── BREADCRUMB ───────────────────────────────────────────── */
.f-breadcrumb {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--c-text);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.f-breadcrumb a {
  color: var(--c-mid);
  text-decoration: none;
  font-weight: 500;
}
.f-breadcrumb a:hover { text-decoration: underline; }
.f-breadcrumb .sep { color: var(--c-text); }
.f-breadcrumb .cur { color: var(--c-deep); font-weight: 600; }

/* ── HERO ─────────────────────────────────────────────────── */
.forum-hero {
  background: linear-gradient(135deg, var(--c-navy), var(--c-main));
  border-radius: 20px;
  padding: 2.5rem 2rem;
  margin-bottom: 2rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.forum-hero::before {
  content: '💬';
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 5rem;
  opacity: .12;
}
.forum-hero h1 {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 .4rem;
  color: #fff;
}
.forum-hero p {
  font-size: .95rem;
  opacity: .8;
  margin: 0 0 1.25rem;
}
.forum-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.forum-stat {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.forum-stat .fs-num {
  font-family: 'Syne', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}
.forum-stat .fs-lbl {
  font-size: .75rem;
  opacity: .7;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── CATEGORIES GRID ──────────────────────────────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.cat-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.cat-card:hover {
  box-shadow: 0 6px 24px rgba(37,88,176,.1);
  transform: translateY(-2px);
}
.cat-card-header {
  padding: .9rem 1.2rem;
  display: flex;
  align-items: center;
  gap: .7rem;
}
.cat-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cat-card-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: .95rem;
  font-weight: 700;
  margin: 0 0 .15rem;
  color: #fff;
}
.cat-card-header p {
  font-size: .75rem;
  margin: 0;
  color: rgba(255,255,255,.75);
}
.cat-subcats {
  padding: .5rem 0;
}
.cat-subcat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 1.2rem;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  color: var(--c-deep);
}
.cat-subcat-item:hover { background: var(--c-bg); }
.cat-subcat-name {
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-deep);
}
.cat-subcat-desc {
  font-size: .75rem;
  color: var(--c-text);
  margin-top: .1rem;
}
.cat-subcat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .1rem;
}
.cat-subcat-count {
  font-size: .72rem;
  font-weight: 600;
  color: var(--c-mid);
  background: var(--c-accent);
  border-radius: 6px;
  padding: .1rem .45rem;
  white-space: nowrap;
}
.cat-subcat-last {
  font-size: .68rem;
  color: var(--c-text);
}

/* ── FORUM VIEW HEADER ────────────────────────────────────── */
.forum-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.forum-view-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-deep);
  margin: 0;
}
.forum-view-header p {
  font-size: .8rem;
  color: var(--c-text);
  margin: .2rem 0 0;
}

/* ── TOPICS LIST ──────────────────────────────────────────── */
.topics-list {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  overflow: hidden;
}
.topics-list-head {
  display: grid;
  grid-template-columns: 1fr 100px 80px 100px;
  padding: .7rem 1.25rem;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  font-size: .72rem;
  font-weight: 600;
  color: var(--c-text);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.topic-row {
  display: grid;
  grid-template-columns: 1fr 100px 80px 100px;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
  align-items: center;
  transition: background .15s;
  cursor: pointer;
}
.topic-row:last-child { border-bottom: none; }
.topic-row:hover { background: var(--c-bg); }
.topic-row.pinned { background: #fffbeb; }
.topic-title-wrap { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.topic-badges { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .2rem; }
.t-badge {
  font-size: .65rem;
  font-weight: 700;
  border-radius: 5px;
  padding: .1rem .45rem;
  white-space: nowrap;
}
.t-badge.solved  { background: var(--c-green-bg);  color: var(--c-green);  }
.t-badge.pinned  { background: var(--c-gold-bg);   color: var(--c-gold);   }
.t-badge.locked  { background: var(--c-red-bg);    color: var(--c-red);    }
.topic-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--c-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topic-author-line {
  font-size: .72rem;
  color: var(--c-text);
}
.t-stat {
  font-size: .82rem;
  font-weight: 600;
  color: var(--c-deep);
  text-align: center;
}
.t-stat small { display: block; font-size: .65rem; font-weight: 400; color: var(--c-text); }
.t-date {
  font-size: .75rem;
  color: var(--c-text);
  text-align: right;
}
.topics-empty {
  padding: 3rem;
  text-align: center;
  color: var(--c-text);
}
.topics-empty .te-icon { font-size: 2rem; margin-bottom: .5rem; }

/* ── TOPIC DETAIL ─────────────────────────────────────────── */
.thread-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  align-items: start;
}
.thread-main {}
.thread-sidebar {
  position: sticky;
  top: 80px;
}

.thread-title-bar {
  margin-bottom: 1.25rem;
}
.thread-title-bar h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--c-deep);
  margin: 0 0 .5rem;
  line-height: 1.3;
}
.thread-badges { display: flex; gap: .4rem; margin-bottom: .5rem; flex-wrap: wrap; }

/* Post / Reply cards */
.thread-post, .thread-reply {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: .75rem;
}
.thread-post { border-left: 4px solid var(--c-mid); }
.thread-reply.solution {
  border-left: 4px solid var(--c-green);
  background: var(--c-green-bg);
}
.thread-reply.nested {
  margin-left: 2.5rem;
  margin-top: .5rem;
  background: var(--c-bg);
  border-radius: 10px;
  padding: 1rem;
}

.post-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .9rem;
}
.post-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--c-mid);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}
.post-avatar.sm { width: 30px; height: 30px; font-size: .72rem; }
.post-meta { flex: 1; min-width: 0; }
.post-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--c-deep);
}
.post-date { font-size: .72rem; color: var(--c-text); }
.post-content {
  font-size: .9rem;
  color: var(--c-text2);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.post-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .85rem;
  flex-wrap: wrap;
}
.pa-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .75rem;
  font-weight: 500;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: .3rem .7rem;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.pa-btn:hover { background: var(--c-accent); color: var(--c-mid); border-color: var(--c-mid); }
.pa-btn.liked  { background: var(--c-accent); color: var(--c-mid); border-color: var(--c-mid); font-weight: 700; }
.pa-btn.danger:hover { background: var(--c-red-bg); color: var(--c-red); border-color: var(--c-red); }
.pa-btn.solution-btn { color: var(--c-green); border-color: var(--c-green-bg); background: var(--c-green-bg); }

.solution-tag {
  font-size: .72rem;
  font-weight: 700;
  color: var(--c-green);
  background: var(--c-green-bg);
  border-radius: 6px;
  padding: .25rem .6rem;
  margin-left: auto;
}

/* Reply form */
.reply-form-wrap {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-top: 1rem;
}
.reply-form-wrap h4 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--c-deep);
  margin: 0 0 .75rem;
}
.reply-textarea {
  width: 100%;
  min-height: 110px;
  padding: .75rem 1rem;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--c-deep);
  background: var(--c-bg);
  resize: vertical;
  transition: border .2s;
  box-sizing: border-box;
}
.reply-textarea:focus {
  outline: none;
  border-color: var(--c-mid);
  background: #fff;
}
.reply-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .75rem;
  gap: .5rem;
  flex-wrap: wrap;
}
.reply-context {
  font-size: .78rem;
  color: var(--c-mid);
  background: var(--c-accent);
  border-radius: 6px;
  padding: .25rem .6rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.reply-context .close-ctx {
  cursor: pointer;
  font-size: .9rem;
  opacity: .6;
}
.reply-context .close-ctx:hover { opacity: 1; }

/* Sidebar */
.f-sidebar-box {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.f-sidebar-box h4 {
  font-size: .82rem;
  font-weight: 700;
  color: var(--c-text);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 .75rem;
}
.f-sb-stat { display: flex; justify-content: space-between; align-items: center; padding: .3rem 0; font-size: .85rem; }
.f-sb-stat strong { color: var(--c-deep); font-weight: 700; }
.f-sb-stat span { color: var(--c-text); }

/* New topic modal */
.forum-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,30,64,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.forum-modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  overflow: hidden;
}
.fm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--c-border);
}
.fm-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--c-deep);
}
.fm-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--c-text);
  padding: .2rem;
}
.fm-close:hover { color: var(--c-red); }
.fm-body {
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.fm-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--c-deep);
  display: block;
  margin-bottom: .35rem;
}
.fm-input, .fm-select {
  width: 100%;
  padding: .65rem .9rem;
  border: 1px solid var(--c-border);
  border-radius: 9px;
  font-family: var(--font-body);
  font-size: .88rem;
  color: var(--c-deep);
  background: var(--c-bg);
  transition: border .2s;
  box-sizing: border-box;
}
.fm-input:focus, .fm-select:focus {
  outline: none;
  border-color: var(--c-mid);
  background: #fff;
}
.fm-textarea {
  min-height: 130px;
  resize: vertical;
}
.fm-footer {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--c-border);
}

/* Buttons */
.f-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
  font-weight: 600;
  border-radius: 9px;
  padding: .55rem 1.1rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.f-btn:active { transform: scale(.97); }
.f-btn-primary { background: var(--c-mid); color: #fff; }
.f-btn-primary:hover { background: var(--c-main); }
.f-btn-ghost { background: var(--c-bg); color: var(--c-deep); border-color: var(--c-border); }
.f-btn-ghost:hover { background: var(--c-accent); }
.f-btn-sm { font-size: .78rem; padding: .35rem .75rem; }

/* Auth notice */
.forum-auth-notice {
  background: var(--c-accent);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
  color: var(--c-deep);
  margin-top: 1rem;
}
.forum-auth-notice a {
  color: var(--c-mid);
  font-weight: 700;
  text-decoration: none;
}
.forum-auth-notice a:hover { text-decoration: underline; }

/* Loading spinner */
.f-loading {
  text-align: center;
  padding: 3rem;
  color: var(--c-text);
}
.f-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-mid);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto .75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.f-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--c-deep);
  color: #fff;
  border-radius: 10px;
  padding: .75rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  z-index: 2000;
  animation: slideInToast .3s ease;
  max-width: 320px;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .thread-layout { grid-template-columns: 1fr; }
  .thread-sidebar { display: none; }
  .topics-list-head { display: none; }
  .topic-row {
    grid-template-columns: 1fr;
    gap: .3rem;
  }
  .t-stat, .t-date { text-align: left; font-size: .8rem; }
  .cat-grid { grid-template-columns: 1fr; }
  .forum-hero h1 { font-size: 1.5rem; }
  .thread-reply.nested { margin-left: 1rem; }
}
