/* Forum Styles - Clean Rebuild */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-soft: #1f2430;
  --surface-strong: #131a27;
  --text: #e7ebf2;
  --muted: #a4adbd;
  --line: #2e3544;
  --primary: #18478f;
  --primary-soft: #1b2a43;
  --primary-hover: #1f53a3;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
}

body.theme-light {
  --bg: #f2f5fb;
  --surface: #ffffff;
  --surface-soft: #eef2f8;
  --surface-strong: #f5f8fd;
  --text: #0f172a;
  --muted: #475569;
  --line: #dbe4f0;
  --primary: #1d4ed8;
  --primary-soft: #dbeafe;
  --primary-hover: #1e40af;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
}

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

html,
body {
  background:
    radial-gradient(950px 420px at 100% -20%, rgba(24, 71, 143, 0.18), transparent 60%),
    radial-gradient(850px 360px at -10% -30%, rgba(24, 71, 143, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: #95b6ff;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #bdd1ff;
}

.container {
  width: min(1180px, 92vw);
  margin: 0 auto;
}

main {
  padding: 28px 0 54px;
  min-height: calc(100vh - 210px);
}

/* Header */
.forum-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(23, 26, 33, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.forum-logo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.forum-logo .logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.logo-subtitle {
  color: var(--muted);
  font-size: 0.78rem;
}

.forum-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.forum-nav a,
.nav-dropdown summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 600;
  transition: all 0.2s ease;
}

.forum-nav a:hover,
.nav-dropdown summary:hover,
.forum-nav a.active {
  color: var(--text);
  border-color: #4f648b;
  background: var(--primary-soft);
}

.nav-dropdown summary::-webkit-details-marker {
  display: none;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown[open] .nav-dropdown-menu {
  display: flex;
}

.nav-dropdown-menu {
  position: absolute;
  right: 0;
  top: 40px;
  min-width: 184px;
  display: none;
  flex-direction: column;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 20;
}

.nav-dropdown-menu a {
  border-radius: 8px;
  padding: 8px 10px;
}

.profile-corner {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 188px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.profile-corner-avatar,
.profile-avatar,
.member-card-avatar,
.author-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border-radius: 50%;
  overflow: hidden;
}

.profile-corner-avatar {
  width: 34px;
  height: 34px;
}

.profile-corner-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.profile-corner-meta .text-muted {
  margin-left: 0;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Global blocks */
.section-title {
  font-size: 1.35rem;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 18px;
}

.breadcrumb {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--text);
}

.text-muted {
  color: var(--muted);
  font-size: 0.86rem;
}

/* Stats */
.forum-stats,
.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat-box,
.profile-stat-box {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0)), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 4px;
}

/* Lists and cards */
.category-list,
.topic-list,
.admin-table,
.profile-section,
.reply-form,
.auth-form,
.admin-form,
.chat-shell,
.application-item,
.notification-item,
.member-card,
.conversation-item,
.pm-item,
.ticket-reply,
.post-item {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0)), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.category-list,
.topic-list,
.admin-table {
  overflow: hidden;
}

.category-item {
  display: grid;
  grid-template-columns: 1fr 140px 220px;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.category-item:last-child {
  border-bottom: none;
}

.category-item:hover,
.topic-item:hover,
.member-card:hover,
.conversation-item-active {
  background: var(--surface-soft);
}

.category-main,
.topic-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.category-icon,
.topic-icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--muted);
}

.category-info h3,
.topic-info h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.category-info p,
.topic-meta,
.category-last,
.topic-last {
  color: var(--muted);
  font-size: 0.86rem;
}

.category-stats,
.topic-stats {
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.category-stats span,
.topic-stats span {
  display: block;
}

.last-topic {
  color: var(--text);
  display: block;
}

.no-posts {
  font-style: italic;
}

.topic-list-header,
.topic-item {
  display: grid;
  grid-template-columns: 1fr 90px 190px;
  gap: 14px;
  align-items: center;
}

.topic-list-header {
  padding: 11px 16px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
}

.topic-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.topic-item:last-child {
  border-bottom: none;
}

.topic-item.pinned {
  background: rgba(24, 71, 143, 0.16);
}

.topic-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0;
}

.topic-tag,
.badge,
.rank-badge,
.ticket-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 9px;
}

.topic-tag {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
}

.badge {
  color: #fff;
}

.badge-owner {
  background: #ef4444;
}

.badge-admin {
  background: #f97316;
}

.badge-moderator {
  background: #2563eb;
}

.badge-pinned {
  background: #1d4ed8;
}

.badge-locked {
  background: #d97706;
}

.rank-badge {
  border: 1px solid currentColor;
  background: transparent;
}

.ticket-status-open {
  background: rgba(34, 197, 94, 0.2);
  color: #9ef7bc;
}

.ticket-status-in_progress {
  background: rgba(37, 99, 235, 0.2);
  color: #a4c5ff;
}

.ticket-status-closed {
  background: rgba(148, 163, 184, 0.2);
  color: #d8e0ec;
}

/* Post layout */
.post-list {
  margin-bottom: 22px;
}

.post-item {
  display: flex;
  margin-bottom: 14px;
  overflow: hidden;
}

.post-sidebar {
  width: 210px;
  flex-shrink: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface-strong);
}

.post-author {
  text-align: center;
}

.author-avatar {
  width: 62px;
  height: 62px;
  margin: 0 auto 10px;
}

.author-name {
  display: block;
  font-weight: 700;
}

.author-posts {
  color: var(--muted);
  font-size: 0.82rem;
}

.author-rank-wrap {
  margin-top: 7px;
}

.post-content {
  flex: 1;
  min-width: 0;
  padding: 18px;
}

.post-header,
.pm-head,
.chat-header,
.application-head,
.ticket-reply-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.post-header {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.post-date,
.post-permalink,
.post-edited,
.page-info {
  color: var(--muted);
  font-size: 0.84rem;
}

.post-meta-actions,
.topic-actions,
.status-form-inline,
.inline-user-form,
.members-search,
.edit-profile-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.post-body,
.pm-content,
.ticket-reply-body {
  line-height: 1.72;
  word-break: break-word;
}

.post-edited {
  margin-top: 12px;
  font-style: italic;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select,
.members-search input,
.chat-form input,
.inline-user-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.chat-form input:focus,
.members-search input:focus {
  outline: none;
  border-color: #4e77be;
  box-shadow: 0 0 0 3px rgba(24, 71, 143, 0.24);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  color: #fff;
  border-color: #375f9f;
  background: linear-gradient(180deg, #2156a8, #18478f);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  color: var(--text);
  border-color: #44536f;
  background: var(--surface-soft);
}

.btn-secondary:hover {
  border-color: #60718f;
  background: #26344d;
}

.btn-danger {
  color: #fff;
  border-color: #b91c1c;
  background: #dc2626;
}

.btn-danger:hover {
  filter: brightness(1.05);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
}

/* Alerts */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.alert-error {
  border: 1px solid #dc2626;
  background: rgba(220, 38, 38, 0.16);
  color: #fecaca;
}

.alert-success {
  border: 1px solid #16a34a;
  background: rgba(22, 163, 74, 0.16);
  color: #bbf7d0;
}

/* Auth */
.auth-form {
  max-width: 520px;
  margin: 24px auto;
  padding: 24px;
}

.auth-form h1 {
  margin-bottom: 14px;
}

.auth-link {
  margin-top: 14px;
  color: var(--muted);
  text-align: center;
}

.otp-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  max-width: 360px;
}

.otp-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.otp-input:focus {
  border-color: #4e77be;
  box-shadow: 0 0 0 3px rgba(24, 71, 143, 0.24);
}

/* Pagination */
.pagination {
  margin: 20px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Profile */
.profile {
  max-width: 1080px;
  margin: 0 auto;
}

.profile-cover {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(24, 71, 143, 0.24), rgba(24, 71, 143, 0.08) 45%, rgba(23, 26, 33, 0.96));
  border: 1px solid #36507a;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  padding: 22px;
}

.profile-cover-glow {
  position: absolute;
  width: 320px;
  height: 320px;
  right: -120px;
  top: -180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(110, 158, 238, 0.3), transparent 70%);
  pointer-events: none;
}

.profile-cover-grid {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar-xl {
  width: 102px;
  height: 102px;
  border: 2px solid #4f6e9f;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.profile-kv {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-kv span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(110, 134, 173, 0.45);
  background: rgba(16, 24, 39, 0.62);
  color: #d7e3fa;
  font-size: 0.78rem;
  padding: 5px 10px;
}

.profile-highlights {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.profile-highlight-card {
  border: 1px solid rgba(110, 134, 173, 0.45);
  border-radius: 12px;
  background: rgba(11, 17, 30, 0.58);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.highlight-label {
  color: #9eb2d3;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.highlight-value {
  color: #f4f8ff;
  font-size: 1rem;
  font-weight: 700;
}

.profile-progress {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(115, 136, 172, 0.25);
}

.profile-progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3a77dd, #7da8ee);
}

.profile-header,
.profile-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 92px;
  height: 92px;
  flex-shrink: 0;
}

.profile-info h1 {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.profile-info p {
  color: var(--muted);
  margin-top: 3px;
}

.profile-hero-actions {
  min-width: 220px;
  display: grid;
  gap: 10px;
}

.profile-layout-clean {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.profile-content,
.profile-sidebar-clean,
.quick-actions,
.notification-list,
.conversation-list,
.ticket-replies,
.application-list {
  display: grid;
  gap: 12px;
}

.profile-section {
  padding: 20px;
}

.profile-section h2 {
  font-size: 1.08rem;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.profile-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.profile-section-head h2 {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.profile-list {
  list-style: none;
}

.profile-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.profile-list-rich li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-list-main {
  display: grid;
  gap: 2px;
}

.profile-list-time {
  white-space: nowrap;
}

.profile-list li:last-child {
  border-bottom: none;
}

.edit-profile-shell {
  max-width: 860px;
  margin: 0 auto;
}

.edit-profile-avatar-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

/* Messages and chat */
.messages-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 14px;
}

.conversation-item,
.pm-item,
.notification-item,
.application-item,
.ticket-reply {
  border-radius: var(--radius-sm);
  padding: 12px;
}

.notification-unread,
.conversation-item-active,
.ticket-reply-staff,
.pm-item-self {
  border-color: #4e77be;
  background: rgba(24, 71, 143, 0.17);
}

.pm-thread,
.chat-messages {
  max-height: 520px;
  overflow-y: auto;
}

.chat-shell {
  max-width: 880px;
  margin: 10px auto 0;
  overflow: hidden;
}

.chat-header {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  background: var(--surface-strong);
}

.chat-messages {
  height: 430px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-row {
  display: flex;
}

.chat-row-user {
  justify-content: flex-end;
}

.chat-row-bot {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 76%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 10px 12px;
}

.chat-row-user .chat-bubble {
  border-color: #4870b3;
  background: #22395f;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 12px;
}

/* Admin */
.admin-tabs {
  margin-top: 16px;
}

.tab-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.tab-btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 11px 14px;
  cursor: pointer;
}

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

.tab-btn:hover:not(.active) {
  color: var(--text);
  background: var(--surface-soft);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.admin-form {
  padding: 20px;
  margin-bottom: 16px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.admin-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-strong);
}

.admin-table .actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.inline-action {
  display: inline;
}

.topic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.category-header {
  margin-bottom: 14px;
}

.category-desc {
  color: var(--muted);
}

.settings-logout-wrap {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.forum-footer {
  margin-top: 30px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  padding: 22px 0 28px;
  font-size: 0.86rem;
}

.forum-footer p {
  margin-bottom: 4px;
}

/* Responsive */
@media (max-width: 980px) {
  .profile-cover-grid {
    flex-direction: column;
  }

  .profile-highlights {
    grid-template-columns: 1fr;
  }

  .messages-layout,
  .profile-layout-clean {
    grid-template-columns: 1fr;
  }

  .profile-sidebar-clean {
    order: -1;
  }

  .forum-stats,
  .profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-item {
    grid-template-columns: 1fr;
  }

  .category-stats,
  .category-last {
    padding-left: 44px;
  }

  .topic-list-header {
    display: none;
  }

  .topic-item {
    grid-template-columns: 1fr;
  }

  .topic-stats,
  .topic-last,
  .topic-stats-col,
  .topic-last-col {
    display: none;
  }

  .post-item {
    flex-direction: column;
  }

  .post-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 768px) {
  .profile-identity {
    align-items: flex-start;
  }

  .profile-avatar-xl {
    width: 88px;
    height: 88px;
  }

  .header-inner,
  .header-right {
    flex-direction: column;
    align-items: stretch;
  }

  .forum-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .profile-corner {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .tab-nav {
    flex-direction: column;
  }

  .chat-bubble {
    max-width: 90%;
  }

  .chat-messages {
    height: 360px;
  }

  .auth-form,
  .profile-section,
  .admin-form,
  .reply-form {
    padding: 16px;
  }

  .admin-table th,
  .admin-table td {
    padding: 8px;
  }
}
