/* forum look, ported from the claude design canvas (direction a).
   group tiles carry the tokens too: terokai/jemputan/arkib render outside .forum */
.forum, .fx-icon-tile {
  --fx-card: var(--bs-body-bg);
  --fx-raised: var(--bs-gray-100);
  --fx-line: var(--bs-border-color);
  --fx-line2: var(--bs-gray-300);
  --fx-text: var(--bs-gray-900);
  --fx-text2: var(--bs-gray-800);
  --fx-muted: #4B5675;
  --fx-primary: #0083CF; --fx-primary-soft: var(--bs-primary-light);
  --fx-success: #178A4F; --fx-success-soft: var(--bs-success-light);
  --fx-info: #7239EA;    --fx-info-soft: var(--bs-info-light);
  --fx-warning: #9A5B00; --fx-warning-soft: var(--bs-warning-light);
  --fx-danger: #C8174A;  --fx-danger-soft: var(--bs-danger-light);
  color: var(--fx-text);
}
/* brighter accents in dark so small text clears 4.5:1 on #1e1e2d */
[data-bs-theme=dark] .forum, [data-bs-theme=dark] .fx-icon-tile {
  --fx-card: #1E1E2D;
  --fx-raised: #24243a;
  --fx-muted: #A3A9D6;
  --fx-primary: #009EF7; --fx-success: #50CD89; --fx-info: #A27BFA;
  --fx-warning: #F0A23A; --fx-danger: #F1416C;
}

.fx-tone-primary { --tone: var(--fx-primary); --tone-soft: var(--fx-primary-soft); }
.fx-tone-success { --tone: var(--fx-success); --tone-soft: var(--fx-success-soft); }
.fx-tone-info    { --tone: var(--fx-info);    --tone-soft: var(--fx-info-soft); }
.fx-tone-warning { --tone: var(--fx-warning); --tone-soft: var(--fx-warning-soft); }
.fx-tone-danger  { --tone: var(--fx-danger);  --tone-soft: var(--fx-danger-soft); }
.forum .fx-c-primary { color: var(--fx-primary) !important; }
.forum .fx-c-success { color: var(--fx-success) !important; }
.forum .fx-c-warning { color: var(--fx-warning) !important; }
.forum .fx-c-danger  { color: var(--fx-danger) !important; }
.forum .fx-c-muted   { color: var(--fx-muted) !important; }

/* shell: the thread page drops the left nav on desktop, the drawer still works on phones */
@media (min-width: 992px) {
  #forum-shell:has(#forum-page[data-layout="thread"]) > #forum-side { display: none; }
}

/* metronic adds .drawer while the sidebar is an off-canvas drawer (phones) */
#forum_sidebar.drawer { background: var(--fx-card); }

/* metronic paints every fontawesome icon text-muted (#565674, too dim in dark) at 1rem;
   forum icons take their container's color instead */
.forum i[class*=" fa-"] { color: inherit; }
.fx-icon-tile i { color: inherit; font-size: inherit; }
.forum .fx-group-icon i { font-size: 28px; }

/* building blocks */
.forum .fx-card { background: var(--fx-card); border: 1px solid var(--fx-line); border-radius: 16px; }
.forum .fx-card.is-pinned { border-color: var(--fx-warning); }
.forum .fx-post { padding: 18px 20px 8px; }
.fx-av { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; background: var(--tone-soft); color: var(--tone); }
.fx-av img { width: 100%; height: 100%; object-fit: cover; }
.fx-av-sm { width: 34px; height: 34px; font-size: 12px; }
.fx-chip { flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--tone-soft); color: var(--tone); white-space: nowrap; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; }
.forum a.fx-chip:hover { color: var(--tone); filter: brightness(1.15); }
.fx-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 6px; background: var(--tone-soft); color: var(--tone); }
.fx-pill-neutral { background: var(--fx-raised); color: var(--fx-text2); border: 1px solid var(--fx-line2); }
.fx-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); flex-shrink: 0; }
.fx-meta { font-size: 12.5px; color: var(--fx-muted); }
.fx-edited { color: var(--fx-warning); font-weight: 600; }
.fx-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fx-muted); }
.forum .fx-page-title { font-size: 24px; font-weight: 700; letter-spacing: -.01em; color: var(--fx-text); margin: 0; }
.forum .fx-title { display: block; font-size: 17px; font-weight: 650; line-height: 1.35; color: var(--fx-text); overflow-wrap: anywhere; }
.forum .fx-title:hover { color: var(--fx-primary); }
.fx-excerpt { margin: 6px 0 0; color: var(--fx-text2); line-height: 1.55; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fx-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 14px;
  padding-top: 8px; border-top: 1px solid var(--fx-line); }
.fx-box { padding: 12px 14px; border-radius: 12px; background: var(--fx-raised); border: 1px solid var(--fx-line2); }
.fx-progress { height: 6px; border-radius: 3px; background: var(--fx-line2); overflow: hidden; }
.fx-progress > div { height: 100%; border-radius: 3px; background: var(--tone, var(--fx-primary)); }
.fx-icon-tile { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: inline-flex; font-size: 1rem;
  align-items: center; justify-content: center; background: var(--tone-soft); color: var(--tone); }

/* feed: the newest reply, and what this reader hasn't seen */
.fx-lastreply { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.fx-lastreply.is-unread { padding: 8px 12px; border-radius: 10px; background: var(--fx-primary-soft); }
.fx-lastreply-text { flex: 1; min-width: 0; font-size: 12.5px; color: var(--fx-muted); overflow-wrap: anywhere; }
.fx-lastreply-text b { font-weight: 600; color: var(--fx-text2); }
.fx-lastreply.is-unread .fx-lastreply-text b { color: var(--fx-text); }
.fx-unread { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--fx-primary); }
.fx-unread::before, .fx-pill-new::before, .fx-title.has-unread::before { content: ''; width: 8px; height: 8px;
  border-radius: 50%; background: var(--fx-primary); flex-shrink: 0; }
.fx-title.has-unread::before { display: inline-block; margin-right: 8px; vertical-align: middle; }
.forum-action.is-unread { color: var(--fx-primary); font-weight: 600; }

/* nav + search */
.forum .fx-nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--fx-text2); min-width: 0; }
.forum .fx-nav-link:hover { background: var(--fx-raised); color: var(--fx-text); }
.forum .fx-nav-link.active { background: var(--fx-primary-soft); color: var(--fx-primary); font-weight: 600; }
.fx-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; background: var(--fx-danger); color: #fff; }
.fx-search { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px; border-radius: 22px;
  background: var(--fx-raised); border: 1px solid var(--fx-line2); color: var(--fx-muted); min-width: 0; }
.fx-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fx-text); outline: none; font: inherit; }
.fx-search input::placeholder { color: var(--fx-muted); }
.forum .fx-btn-round { height: 44px; padding: 0 20px; border-radius: 22px; display: inline-flex; align-items: center; }

/* post actions: existing hook classes, new look */
.forum-action { background: none; border: 0; height: 36px; padding: 0 12px; border-radius: 8px; color: var(--fx-muted);
  font-size: 13px; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.forum-action:hover { background: var(--fx-raised); color: var(--fx-primary); }
.forum-action.is-liked { background: var(--fx-primary-soft); color: var(--fx-primary); font-weight: 600; }
.forum-action-danger, .forum-action-danger:hover { color: var(--fx-danger); }
.forum-action-success, .forum-action-success:hover { color: var(--fx-success); font-weight: 600; }
span.forum-action { cursor: default; }
span.forum-action:hover { background: none; color: var(--fx-muted); }
.fx-like { display: inline-flex; align-items: center; gap: 2px; }
.forum-action.fx-like-count { padding: 0 10px; font-weight: 600; }
.fx-likers { width: 280px; max-height: 320px; overflow-y: auto; padding: 6px 10px; }
.fx-liker { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.fx-liker + .fx-liker { border-top: 1px solid var(--fx-line); }
.fx-liker-name { font-size: 13px; font-weight: 600; color: var(--fx-text); overflow-wrap: anywhere; }

/* pagination */
.fx-pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; padding-top: 4px; }
.forum .fx-pager-num, .forum .fx-pager-arrow { min-width: 40px; height: 40px; border-radius: 20px; color: var(--fx-text2);
  display: inline-flex; align-items: center; justify-content: center; }
.forum .fx-pager-arrow { border: 1px solid var(--fx-line2); }
.forum .fx-pager-num:hover, .forum .fx-pager-arrow:hover { background: var(--fx-raised); color: var(--fx-text); }
.fx-pager-num.is-current { background: var(--fx-primary); color: #fff; font-weight: 600; }
.fx-pager-gap { min-width: 24px; text-align: center; color: var(--fx-muted); }

/* thread page */
.forum .fx-thread-title { font-size: 24px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; color: var(--fx-text); overflow-wrap: anywhere; }
.forum .fx-verified { border: 1.5px solid var(--fx-success); overflow: hidden; }
.fx-verified-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 20px;
  background: var(--fx-success-soft); color: var(--fx-success); font-size: 13px; font-weight: 600; }
.fx-quote { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--fx-raised); font-size: 13.5px; color: var(--fx-text2); }
.fx-divider { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.fx-divider::after { content: ''; flex: 1; height: 1px; background: var(--fx-line); }
.forum .fx-rail-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--fx-text2); text-align: left; }
.forum .fx-rail-btn:hover { background: var(--fx-raised); color: var(--fx-text); }
.fx-dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.fx-dl dt { color: var(--fx-muted); font-weight: 400; }
.fx-dl dd { margin: 0; text-align: right; color: var(--fx-text2); }
.fx-replybar { position: sticky; bottom: 0; z-index: 5; padding: 10px 0 14px; background: var(--bs-app-bg-color, var(--fx-card)); }
.forum .fx-menu .menu-link { color: var(--fx-text2); }

/* group page */
.fx-banner { height: 88px; background: var(--tone-soft); }
.fx-banner.has-cover { height: clamp(120px, 22vw, 220px); }
.fx-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fx-group-icon { width: 76px; height: 76px; margin-top: -36px; border-radius: 20px; border: 4px solid var(--fx-card);
  background: var(--tone); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; }
/* uploaded group logo in place of the icon; white so transparent logos stay readable in dark mode */
.fx-icon-tile, .fx-group-icon { overflow: hidden; }
.fx-icon-tile.has-logo, .fx-group-icon.has-logo { background: #fff; }
.fx-logo-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fx-image-preview { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; border: 1px solid var(--fx-line); }
.fx-image-preview.is-wide { width: 192px; }

/* poll */
.fx-poll-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--fx-line2); overflow: hidden; }
.fx-poll-row.is-mine { border-color: var(--fx-info); }
.fx-poll-bar { position: absolute; inset: 0 auto 0 0; background: var(--fx-info-soft); }
.fx-poll-label, .fx-poll-count { position: relative; }
.fx-poll-label { flex: 1; font-weight: 500; color: var(--fx-text); }
.fx-poll-label i { color: var(--fx-info); margin-right: 8px; }
.fx-poll-count { font-size: 13px; color: var(--fx-muted); white-space: nowrap; }
.fx-poll-count b { color: var(--fx-text); }
.fx-poll-choice { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--fx-line2); cursor: pointer; color: var(--fx-text); }
.fx-poll-choice:has(input:checked) { border-color: var(--fx-info); background: var(--fx-info-soft); }
.fx-poll-choice input { width: 18px; height: 18px; accent-color: var(--fx-info); margin: 0; }

/* signup table: own class, metronic's .table resets cell color */
.fx-table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--fx-line); border-radius: 12px; }
.fx-table { width: 100%; min-width: 420px; border-collapse: collapse; font-size: 13.5px; }
.fx-table th { background: var(--fx-raised); color: var(--fx-muted); font-weight: 600; text-align: left; padding: 10px 14px; }
.fx-table td { padding: 10px 14px; border-top: 1px solid var(--fx-line); color: var(--fx-text2); }
.fx-table tr.is-mine td { background: var(--fx-primary-soft); color: var(--fx-primary); font-weight: 600; }
.fx-table.is-collapsed .fx-more { display: none; }

/* post bodies (kept from before) */
.forum-body { color: var(--fx-text2); font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.forum-body p:last-child { margin-bottom: 0; }
.forum-body blockquote { border-left: 3px solid var(--fx-line2); padding-left: .75rem; color: var(--fx-muted); }
/* @mentions: in posts, in the editor, and the picker (ckeditor renders the picker outside .forum) */
.forum-body .mention, .forum-editor .ck-content .mention { color: var(--fx-primary, var(--bs-primary)); font-weight: 600; }
.fx-mention-item { display: flex; flex-direction: column; line-height: 1.3; padding: 2px 0; }
.ck .ck-mentions .fx-mention-name { font-weight: 600; }
.ck .ck-mentions .fx-mention-klinik { font-size: 12px; color: var(--bs-info); }
.forum-body img { max-width: 100%; height: auto; border-radius: .475rem; }
/* table layout makes the caption as wide as the image, same as inside ckeditor */
.forum-body figure.image { display: table; margin: 1rem auto; text-align: center; }
.forum-body figure.image img { display: block; margin: 0 auto; }
.forum-body figcaption { display: table-caption; caption-side: bottom; color: var(--fx-muted); font-size: .925rem; margin-top: .5rem; }
.forum-body a[data-fslightbox] { cursor: zoom-in; }
/* ckeditor's own caption is dark text on a light box, unreadable in dark mode */
.forum-editor .ck-content .image > figcaption { background: transparent; color: var(--bs-info); }
/* on desktop a post image fits a 512px box; click opens the full size in the lightbox */
@media (min-width: 768px) {
  .forum-body img,
  .forum-editor .ck-content img,
  .forum-editor .ck-content .image img { max-width: min(100%, 512px); max-height: 512px; width: auto; height: auto; min-width: 0; }
}
/* lets the toolbar shrink on phones so ckeditor folds extra buttons into its ⋮ menu */
.forum-editor-toolbar { min-width: 0; }
/* real red: the theme "danger" (#f1416c) reads as pink */
.forum-hit { background: transparent; color: #ff0000; font-weight: 700; padding: 0; }

/* ckeditor ships a light-only theme on :root; balloons render on body, so retheme there */
html[data-bs-theme=dark] {
  --ck-color-base-background: var(--bs-body-bg);
  --ck-color-base-foreground: var(--bs-gray-100);
  --ck-color-base-border: var(--bs-border-color);
  --ck-color-base-text: var(--bs-body-color);
  --ck-color-text: var(--bs-body-color);
  --ck-color-shadow-drop: rgba(0, 0, 0, .5);
  --ck-color-shadow-inner: rgba(0, 0, 0, .3);
  --ck-color-toolbar-background: var(--bs-gray-100);
  --ck-color-toolbar-border: var(--bs-border-color);
  --ck-color-panel-background: var(--bs-gray-100);
  --ck-color-panel-border: var(--bs-border-color);
  --ck-color-dropdown-panel-background: var(--bs-gray-100);
  --ck-color-dropdown-panel-border: var(--bs-border-color);
  --ck-color-list-background: var(--bs-gray-100);
  --ck-color-list-button-hover-background: var(--bs-gray-200);
  --ck-color-button-default-hover-background: var(--bs-gray-200);
  --ck-color-button-default-active-background: var(--bs-gray-300);
  --ck-color-button-on-background: var(--bs-gray-300);
  --ck-color-button-on-hover-background: var(--bs-gray-300);
  --ck-color-button-on-active-background: var(--bs-gray-300);
  --ck-color-input-background: var(--bs-body-bg);
  --ck-color-input-border: var(--bs-border-color);
  --ck-color-input-text: var(--bs-body-color);
  --ck-color-labeled-field-label-background: var(--bs-gray-100);
  --ck-color-tooltip-background: var(--bs-gray-300);
  --ck-color-tooltip-text: var(--bs-body-color);
  --ck-powered-by-background: var(--bs-gray-100);
  --ck-powered-by-border-color: var(--bs-border-color);
  --ck-powered-by-text-color: var(--bs-body-color);
}
html[data-bs-theme=dark] .ck-powered-by svg path { fill: var(--bs-body-color); }
.ck .ck-mentions .ck-button.ck-on, .ck .ck-mentions .ck-button.ck-on * { color: #fff; }
/* ckeditor tooltips are dark chips by default; keep them light in light mode */
html:root:not([data-bs-theme=dark]) { --ck-color-tooltip-background: var(--bs-body-bg); --ck-color-tooltip-text: var(--bs-body-color); }
.ck.ck-balloon-panel.ck-tooltip { border: 1px solid var(--bs-border-color); box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
