/* =====================================================================
   Diễn Đàn AI Cộng Đồng - Custom stylesheet (nền Bootstrap 5)
   ===================================================================== */

:root {
  --brand-900: #0b1120;
  --brand-800: #111827;
  --brand-700: #1e1b4b;
  --brand-600: #4338ca;
  --brand-500: #6366f1;
  --brand-400: #818cf8;
  --accent-500: #22d3ee;
  --accent-400: #67e8f9;
  --surface-0: #f6f7fb;
  --surface-1: #ffffff;
  --ink-900: #0f172a;
  --ink-600: #475569;
  --ink-400: #94a3b8;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-soft: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
  --shadow-hover: 0 16px 40px -14px rgba(76, 29, 149, 0.35);
}

* { scrollbar-width: thin; }

body {
  background: var(--surface-0);
  color: var(--ink-900);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
}

a { text-decoration: none; }

.text-gradient {
  background: linear-gradient(90deg, var(--brand-500), var(--accent-500));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------------------------------------------------------------------
   Navbar
--------------------------------------------------------------------- */
.navbar-ai {
  background: linear-gradient(100deg, var(--brand-900), var(--brand-700) 60%, var(--brand-600));
  box-shadow: 0 2px 20px rgba(0,0,0,.25);
}
.navbar-ai .navbar-brand {
  font-weight: 800;
  letter-spacing: .3px;
  color: #fff !important;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar-ai .navbar-brand .logo-badge {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px rgba(255,255,255,.08);
}
.navbar-ai .nav-link {
  color: rgba(255,255,255,.85) !important;
  font-weight: 500;
  transition: color .15s ease;
}
.navbar-ai .nav-link:hover,
.navbar-ai .nav-link.active { color: #fff !important; }
.navbar-ai .nav-link.active { position: relative; }
.navbar-ai .nav-link.active::after {
  content: ""; position: absolute; left: .75rem; right: .75rem; bottom: -2px; height: 2px;
  background: var(--accent-500); border-radius: 2px;
}
.navbar-search { max-width: 320px; }
.navbar-search .form-control {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); color: #fff;
}
.navbar-search .form-control::placeholder { color: rgba(255,255,255,.55); }
.navbar-search .form-control:focus {
  background: rgba(255,255,255,.14); box-shadow: 0 0 0 .2rem rgba(99,102,241,.35); color: #fff;
}
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-md { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.avatar-xl { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
  color: #fff; font-weight: 700; border-radius: 50%;
}

/* ---------------------------------------------------------------------
   Hero / Banner slider
--------------------------------------------------------------------- */
.hero-slider { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-soft); }
.hero-slide {
  position: relative; min-height: 320px; display: flex; align-items: center;
  background-size: cover; background-position: center;
}
.hero-slide::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, rgba(11,17,32,.92) 10%, rgba(67,56,202,.55) 60%, rgba(34,211,238,.25));
}
.hero-slide .hero-content { position: relative; z-index: 2; color: #fff; padding: 2.5rem 3rem; max-width: 640px; }
.hero-slide .hero-content h2 { font-weight: 800; font-size: 2rem; }
.hero-slide .hero-content p { color: rgba(255,255,255,.85); }
.hero-badge {
  display: inline-flex; align-items: center; gap: .4rem; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25); padding: .3rem .8rem; border-radius: 50px; font-size: .8rem; margin-bottom: .75rem;
}
.carousel-indicators [data-bs-target] { background-color: rgba(255,255,255,.5); }
.carousel-indicators .active { background-color: var(--accent-500); }

/* ---------------------------------------------------------------------
   Card / Widget
--------------------------------------------------------------------- */
.card-ai {
  background: var(--surface-1); border: 1px solid #eef0f6; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft); transition: transform .18s ease, box-shadow .18s ease;
}
.card-ai:hover { box-shadow: var(--shadow-hover); }
.widget-title {
  font-weight: 700; font-size: .95rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--brand-700); display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem;
}
.widget-title i { color: var(--brand-500); }

/* ---------------------------------------------------------------------
   Danh sách bài mới (trang chủ)
--------------------------------------------------------------------- */
.latest-thread-item {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .25rem; border-radius: var(--radius-md);
  transition: background .15s ease;
}
.latest-thread-item:hover { background: #f1f2fb; }
.latest-thread-item .title { font-weight: 600; color: var(--ink-900); }
.latest-thread-item .meta { font-size: .8rem; color: var(--ink-400); }

/* ---------------------------------------------------------------------
   Cây chuyên mục / forum (giống nhịp khối dembuon.vn)
--------------------------------------------------------------------- */
.category-block { margin-bottom: 1.75rem; }
.category-header {
  background: linear-gradient(90deg, var(--brand-700), var(--brand-600));
  color: #fff; padding: .75rem 1.25rem; border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: .5rem;
}
.forum-row {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; background: var(--surface-1);
  border-left: 1px solid #eef0f6; border-right: 1px solid #eef0f6; border-bottom: 1px solid #eef0f6;
  transition: background .15s ease;
}
.category-block .forum-row:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.forum-row:hover { background: #f9fafe; }
.forum-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md); flex-shrink: 0;
  background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(34,211,238,.14));
  color: var(--brand-600); display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.forum-row .forum-name { font-weight: 700; color: var(--ink-900); }
.forum-row .forum-desc { font-size: .85rem; color: var(--ink-400); }
.forum-stats { text-align: center; min-width: 84px; color: var(--ink-600); font-size: .82rem; }
.forum-stats strong { display: block; font-size: 1.05rem; color: var(--ink-900); }
.forum-lastpost { min-width: 220px; font-size: .82rem; color: var(--ink-600); display: none; }
@media (min-width: 992px) { .forum-lastpost { display: block; } }

/* Bootstrap 5 KHÔNG có sẵn utility ".min-w-0" (dễ nhầm với Tailwind) - tự định nghĩa
   để các cột flex-grow bên trong forum-row/thread-row/latest-thread-item... có thể
   co nhỏ hơn kích thước nội dung của nó, nếu không toàn bộ hàng sẽ tràn ra ngoài
   màn hình hẹp (vỡ khung) vì flex item mặc định có min-width:auto. */
.min-w-0 { min-width: 0 !important; }

@media (max-width: 575.98px) {
  .forum-row, .thread-row { flex-wrap: wrap; row-gap: .5rem; }
  .forum-row .flex-grow-1, .thread-row .flex-grow-1 { flex-basis: 100%; order: 1; }
  .forum-row .forum-icon, .thread-row .avatar-sm, .thread-row .avatar-placeholder { order: 0; }
  .forum-row .forum-stats, .thread-row .forum-stats { order: 2; min-width: 0; flex: 1 1 auto; }
  .forum-lastpost { display: none !important; }
}

/* ---------------------------------------------------------------------
   Danh sách chủ đề trong forum
--------------------------------------------------------------------- */
.thread-row {
  display: flex; align-items: center; gap: 1rem; padding: .9rem 1.1rem; background: var(--surface-1);
  border-bottom: 1px solid #f0f1f7; transition: background .15s ease;
}
.thread-row:hover { background: #f9fafe; }
.thread-row:last-child { border-bottom: none; }
.thread-title { font-weight: 600; color: var(--ink-900); }
.thread-title:hover { color: var(--brand-600); }
.badge-pin { background: var(--accent-500); color: #04333c; }
.badge-lock { background: #fee2e2; color: #b91c1c; }

/* ---------------------------------------------------------------------
   Post / thread detail
--------------------------------------------------------------------- */
.post-card { border-radius: var(--radius-md); overflow: hidden; }
.post-author {
  background: #fafbff; border-right: 1px solid #eef0f6; padding: 1.25rem; text-align: center;
}
.post-body { padding: 1.25rem 1.5rem; }
.post-content { white-space: pre-line; line-height: 1.7; color: #1e2330; }
.post-first { border-left: 4px solid var(--brand-500); }
.like-btn.liked { color: #e11d48; }
.like-btn.liked i::before { content: "\f415"; } /* filled heart when liked (bootstrap-icons heart-fill) */

.attachment-thumb {
  display: block; width: 120px; height: 120px; border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid #eef0f6; box-shadow: var(--shadow-soft);
}
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.attachment-thumb:hover img { transform: scale(1.06); }

.attach-preview-item {
  display: flex; align-items: center; gap: .4rem; background: #f1f2fb; border-radius: var(--radius-md);
  padding: .3rem .6rem; font-size: .8rem; color: var(--ink-600);
}
.attach-preview-item img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; }

/* ---------------------------------------------------------------------
   Breadcrumb / pagination
--------------------------------------------------------------------- */
.breadcrumb-ai { background: transparent; padding: 0; margin: 0 0 1rem; font-size: .9rem; }
.breadcrumb-ai a { color: var(--brand-600); }
.pagination .page-link { color: var(--brand-600); border-radius: 8px !important; margin: 0 2px; border: none; }
.pagination .page-item.active .page-link { background: var(--brand-600); color: #fff; }

/* ---------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------- */
.btn-gradient {
  background: linear-gradient(90deg, var(--brand-600), var(--brand-500));
  border: none; color: #fff; font-weight: 600; transition: transform .15s ease, box-shadow .15s ease;
}
.btn-gradient:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 10px 22px -8px rgba(79,70,229,.55); }
.btn-outline-ai { border: 1.5px solid var(--brand-500); color: var(--brand-600); font-weight: 600; }
.btn-outline-ai:hover { background: var(--brand-500); color: #fff; }

/* ---------------------------------------------------------------------
   Stat pill (sidebar)
--------------------------------------------------------------------- */
.stat-pill { text-align: center; padding: .75rem .5rem; border-radius: var(--radius-md); background: #f5f6fc; }
.stat-pill strong { display: block; font-size: 1.15rem; color: var(--brand-700); }
.stat-pill span { font-size: .78rem; color: var(--ink-400); }

.online-user-chip {
  display: inline-flex; align-items: center; gap: .35rem; background: #f1f2fb; padding: .25rem .6rem;
  border-radius: 50px; font-size: .8rem; color: var(--ink-600); margin: .15rem;
}
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; }

/* ---------------------------------------------------------------------
   Auth pages
--------------------------------------------------------------------- */
.auth-wrapper {
  min-height: calc(100vh - 260px); display: flex; align-items: center; justify-content: center; padding: 2rem 0;
}
.auth-card { max-width: 440px; width: 100%; }

/* ---------------------------------------------------------------------
   Footer
--------------------------------------------------------------------- */
.footer-ai { background: var(--brand-900); color: rgba(255,255,255,.75); }
.footer-ai a { color: rgba(255,255,255,.75); }
.footer-ai a:hover { color: #fff; }

/* ---------------------------------------------------------------------
   Admin layout
--------------------------------------------------------------------- */
.admin-sidebar {
  background: var(--brand-900); min-height: 100vh; color: rgba(255,255,255,.85);
}
.admin-sidebar .brand { padding: 1.1rem 1.25rem; font-weight: 800; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.admin-sidebar .nav-link {
  color: rgba(255,255,255,.7); padding: .6rem 1.25rem; border-radius: 0; display: flex; gap: .6rem; align-items: center;
}
.admin-sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-sidebar .nav-link.active { background: linear-gradient(90deg, rgba(99,102,241,.35), transparent); color: #fff; border-left: 3px solid var(--accent-500); }
.admin-topbar { background: #fff; border-bottom: 1px solid #eef0f6; }
.admin-content { padding: 1.5rem; }
.stat-card {
  border-radius: var(--radius-lg); padding: 1.25rem; color: #fff; box-shadow: var(--shadow-soft);
}
.stat-card i { font-size: 1.6rem; opacity: .85; }
.stat-card .num { font-size: 1.8rem; font-weight: 800; }

/* ---------------------------------------------------------------------
   Utilities / animation nhẹ
--------------------------------------------------------------------- */
.fade-in-up { animation: fadeInUp .5s ease both; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.hover-lift { transition: transform .18s ease, box-shadow .18s ease; }
.hover-lift:hover { transform: translateY(-3px); }

@media (prefers-color-scheme: dark) {
  body.theme-auto {
    background: #0b1120; color: #e2e8f0;
  }
}
