/* =================================================================
   Forum module — classic forum layout (category/forum node list,
   thread table, postbit-style thread view). Built on the shared
   design tokens (see themes/*/default/style.css).
   ================================================================= */

.fo-head-bar {
    display: flex !important; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; flex-wrap: nowrap;
    padding: .3rem .7rem !important; background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--radius, 5px);
}
.fo-head-bar h1 { margin: 0; font-size: .95rem; }

/* Icon-only add button, right-aligned with the page title */
.page-add-btn {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: var(--indigo); text-decoration: none; font-size: .82rem;
    box-shadow: 0 3px 10px -3px rgba(0,0,0,.3);
    transition: background .12s ease, transform .1s ease;
}
.page-add-btn:hover { background: var(--indigo-deep); }
.page-add-btn:active { transform: scale(.94); }

/* ---------- Compact category list — the forum home page ------------------ */
.fo-panel { margin-bottom: 1.5rem; }
.fo-panel:last-child { margin-bottom: 1rem; }

.fo-cat-list {
    display: flex; flex-direction: column; margin-bottom: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden; box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));
}
.fo-cat-row {
    display: flex; align-items: center; gap: .55rem;
    padding: .45rem .75rem; border-top: 1px solid var(--border);
}
.fo-cat-list .fo-cat-row:first-child { border-top: none; }
.fo-cat-icon {
    flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--indigo-soft, var(--paper)); font-size: 1.4rem; color: var(--indigo);
}
.fo-cat-main { flex: 1; min-width: 0; }
.fo-cat-name { font-weight: 800; font-size: .85rem; color: var(--ink); text-decoration: none; }
.fo-cat-name:hover { color: var(--indigo); }
.fo-cat-desc {
    margin: 0; font-size: .72rem; color: var(--ink-soft);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fo-cat-meta {
    margin: .1rem 0 0; font-size: .68rem; color: var(--ink-soft); line-height: 1.35;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fo-cat-meta a { color: var(--indigo); font-weight: 600; text-decoration: none; }
.fo-cat-meta a:hover { text-decoration: underline; }
.fo-cat-meta-empty { font-style: italic; }

/* ---------- Compact recent-topics list — icon, title, author -------------- */
.fo-recent-titles {
    display: flex; flex-direction: column; margin-bottom: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden; box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));
}
.fo-recent-title-row {
    display: flex; align-items: center; gap: .5rem;
    padding: .55rem .9rem; border-top: 1px solid var(--border);
    color: var(--ink); text-decoration: none;
}
.fo-recent-titles .fo-recent-title-row:first-child { border-top: none; }
.fo-recent-title-row:hover { background: var(--paper); }
.fo-recent-title-icon { flex-shrink: 0; font-size: .85rem; color: var(--indigo); }
.fo-recent-title-text {
    flex: 1; min-width: 0; font-size: .85rem; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fo-recent-title-row:hover .fo-recent-title-text { color: var(--indigo); }
.fo-recent-title-text i { color: var(--marigold-deep); margin-right: .25rem; font-size: .78rem; }
.fo-recent-title-author { flex-shrink: 0; font-size: .72rem; color: var(--ink-soft); }

/* ---------- Sub-nav (All / New / Top / My) — matches the Members module ---------- */
.fo-subnav {
    display: flex; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius, 5px); margin-bottom: 1.25rem; overflow: hidden;
}
.fo-subnav a {
    flex: 1; text-align: center; padding: .4rem .3rem; text-decoration: none;
    color: var(--ink-soft); font-weight: 600; font-size: .72rem; position: relative;
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.fo-subnav a.is-active { color: var(--indigo); border-bottom-color: var(--indigo); background: var(--indigo-soft, var(--paper)); }
.fo-subnav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 16px; padding: 0 .28rem; margin-left: .2rem;
    background: var(--success); color: #fff; border-radius: 999px; font-size: .64rem; font-weight: 700;
}
.fo-subnav-badge-neutral { background: var(--indigo); }

.fo-section-head {
    font-family: var(--font-display); font-weight: 800; font-size: .95rem; margin: 0;
    padding: .3rem .7rem; background: var(--surface); border: 1px solid var(--border); border-bottom: none;
    border-radius: var(--radius, 5px) var(--radius, 5px) 0 0;
}

/* ---------- Badges (sticky / closed) -------------------------------- */
.fo-badge { display: inline-flex; align-items: center; font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; white-space: nowrap; gap: .25rem; }
.fo-badge-sticky { background: rgba(244,163,0,.16); color: var(--marigold-deep); }
.fo-badge-closed { background: rgba(214,69,90,.1); color: var(--danger); }
.fo-category-badge {
    font-size: .7rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px;
    background: var(--indigo-soft, var(--paper)); color: var(--indigo);
}

/* ---------- Thread list — compact single-line-plus-meta rows ------------- */
.fo-thread-table {
    display: flex; flex-direction: column; margin-bottom: 1.5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));
}
.fo-thread-row {
    display: flex; align-items: flex-start; gap: .55rem;
    padding: .5rem .8rem; border-top: 1px solid var(--border); transition: background .12s ease;
}
.fo-thread-table .fo-thread-row:first-child { border-top: none; }
.fo-thread-row:hover { background: var(--paper); }
.fo-thread-row.is-sticky { background: rgba(244,163,0,.045); }
.fo-thread-row.is-sticky:hover { background: rgba(244,163,0,.08); }

.fo-thread-icon { flex-shrink: 0; width: 20px; text-align: center; font-size: .95rem; color: var(--ink-soft); margin-top: .15rem; }
.fo-thread-icon .fa-thumbtack { color: var(--marigold-deep); }
.fo-thread-icon .fa-lock { color: var(--danger); }

.fo-thread-main { flex: 1; min-width: 0; }
.fo-thread-title {
    font-weight: 700; font-size: .85rem; color: var(--ink); text-decoration: none;
}
.fo-thread-title:hover { color: var(--indigo); text-decoration: underline; }
.fo-thread-meta {
    margin: .12rem 0 0; font-size: .68rem; color: var(--ink-soft);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fo-thread-meta a { color: var(--indigo); font-weight: 600; text-decoration: none; }
.fo-thread-meta a:hover { text-decoration: underline; }

/* ---------- Breadcrumb ------------------------------------------------ */
.fo-breadcrumb {
    font-size: .68rem; line-height: 1.2; color: var(--ink-soft); margin-bottom: .4rem;
    padding: .35rem .6rem; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius);
}
.fo-breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.fo-breadcrumb a:hover { color: var(--indigo); }
.fo-breadcrumb span { color: var(--ink); font-weight: 700; }

/* ---------- Single topic (thread view) ------------------------------------ */
.fo-topic {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.1rem 0; box-shadow: var(--shadow);
}
.fo-topic-badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .3rem; }
.fo-topic-title-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .55rem; padding-bottom: .55rem; border-bottom: 1px solid var(--border); }
.fo-topic-title-row .fo-topic-title { flex: 1; min-width: 0; margin-bottom: 0; font-size: 1.05rem; line-height: 1.3; }

/* ---------- Postbit — avatar/username sidebar + content, forum-style ------ */
.fo-post { display: flex; gap: 1.2rem; padding-bottom: 1.25rem; }
.fo-post-side { flex-shrink: 0; align-self: flex-start; width: 108px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .4rem; }
.fo-post-avatar {
    width: 68px; height: 68px; border-radius: 50%; overflow: hidden;
    background: var(--indigo); color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.6rem; text-decoration: none;
}
.fo-post-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fo-post-username { font-weight: 800; font-size: .88rem; color: var(--ink); text-decoration: none; line-height: 1.25; }
.fo-post-username:hover { color: var(--indigo); }
.fo-post-role {
    font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    color: var(--indigo); background: var(--indigo-soft, var(--paper)); padding: .1rem .5rem; border-radius: 999px;
}

.fo-post-main { flex: 1; min-width: 0; }
.fo-post-meta { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-size: .78rem; color: var(--ink-soft); margin-bottom: .85rem; }
.fo-post-number { font-weight: 700; color: var(--ink-soft); }
.fo-post-number::before { content: '#'; }

.fo-topic-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; margin-bottom: 1.2rem; }
.fo-topic-gallery[data-count="1"] { grid-template-columns: 1fr; }
.fo-topic-gallery-item { display: block; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; background: var(--paper); }
.fo-topic-gallery[data-count="1"] .fo-topic-gallery-item { aspect-ratio: 16/9; }
.fo-topic-gallery-item img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .2s ease; }
.fo-topic-gallery-item:hover img { transform: scale(1.04); }

.fo-topic-body { font-size: .98rem; line-height: 1.7; white-space: pre-wrap; margin-bottom: 1rem; }

/* ---------- BBCode elements (shared visual language with blog-v2.css) --- */
.bbcode-quote {
    border-left: 3px solid var(--indigo); background: var(--paper);
    padding: .6rem .9rem; margin: .75rem 0; border-radius: 0 6px 6px 0;
    font-style: italic; color: var(--ink-soft); white-space: normal;
}
.bbcode-quote cite {
    display: block; font-style: normal; font-weight: 700; font-size: .8rem;
    color: var(--indigo); margin-bottom: .3rem;
}
.bbcode-list { margin: .5rem 0; padding-left: 1.4rem; white-space: normal; }
.bbcode-list li { margin-bottom: .3rem; }
.bbcode-img { max-width: 100%; border-radius: 8px; margin: .5rem 0; display: block; }
.bbcode-table-wrap { overflow-x: auto; margin: .75rem 0; border: 1px solid var(--border); border-radius: 8px; }
.bbcode-table { width: 100%; border-collapse: collapse; font-size: .88rem; white-space: normal; }
.bbcode-table td { padding: .5rem .75rem; border: 1px solid var(--border); }
.bbcode-table tr:first-child td { background: var(--paper); font-weight: 700; }
.bbcode-code {
    margin: .75rem 0; padding: 1rem; border-radius: 8px; white-space: pre;
    background: #1e1e2e !important; overflow-x: auto; font-size: .85rem; line-height: 1.6;
}
.bbcode-code code {
    font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace !important;
    background: none !important; white-space: pre !important;
}

.fo-topic-files { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; }
.fo-topic-file {
    display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem;
    background: var(--paper); border-radius: 5px; text-decoration: none; color: inherit;
    transition: background .12s ease;
}
.fo-topic-file:hover { background: var(--border); }
.fo-topic-file-icon { font-size: 1.3rem; flex-shrink: 0; }
.fo-topic-file-name { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fo-topic-file-size { font-size: .78rem; color: var(--ink-soft); flex-shrink: 0; }

/* ---------- Topic action kebab menu (Edit / Stick / Close / Move / Delete) ------ */
.fo-menu { position: relative; margin-left: auto; flex-shrink: 0; }
.fo-menu-btn {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%; border: none; background: none;
    color: var(--ink-soft); font-size: 1.1rem; font-weight: 800; line-height: 1;
    cursor: pointer; transition: background .12s ease, color .12s ease;
}
.fo-menu-btn:hover, .fo-menu.is-open .fo-menu-btn { background: var(--paper); color: var(--ink); }
.fo-menu-dropdown {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 60;
    min-width: 190px; padding: .35rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
    box-shadow: 0 10px 28px -12px rgba(0,0,0,.25);
}
.fo-menu-dropdown a, .fo-menu-dropdown button, .fo-menu-dropdown form > button { display: flex; align-items: center; gap: .5rem; width: 100%; margin: 0; box-sizing: border-box; }
.fo-menu-dropdown a, .fo-menu-dropdown button {
    padding: .55rem .6rem; border-radius: 5px; border: none; background: none;
    font-family: inherit; font-size: .86rem; font-weight: 600; text-align: left;
    color: var(--ink); text-decoration: none; cursor: pointer;
}
.fo-menu-dropdown a:hover, .fo-menu-dropdown button:hover { background: var(--paper); }
.fo-menu-danger { color: var(--danger) !important; }
.fo-menu-danger:hover { background: rgba(214,69,90,.1) !important; }
.fo-menu-divider { height: 1px; margin: .3rem .2rem; background: var(--border); }
.fo-menu-move { padding: .4rem .6rem .5rem; }
.fo-menu-move-label { display: block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); margin-bottom: .35rem; }
.fo-menu-move select {
    width: 100%; padding: .4rem .5rem; margin-bottom: .4rem; box-sizing: border-box;
    border: 1px solid var(--border); border-radius: 5px; background: var(--paper); font-family: inherit; font-size: .82rem;
}
.fo-menu-move button { justify-content: center; background: var(--paper); box-sizing: border-box; }
.fo-menu-move button:hover { background: var(--border); }

/* ---------- Forms (create / edit) --------------------------------------- */
.fo-form { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; padding: 1.1rem; }
.fo-form h3 { margin-bottom: .35rem; }
.fo-form label { font-size: .82rem; font-weight: 600; margin-top: .55rem; }
.fo-form input[type=text], .fo-form input[type=file], .fo-form textarea, .fo-form select {
    padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 5px;
    background: var(--paper); font-family: inherit; font-size: .9rem; resize: vertical;
}
.fo-form textarea { line-height: 1.6; }
.fo-form-hint { font-size: .76rem; color: var(--ink-soft); margin: .2rem 0 0; }

.fo-edit-file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: .6rem; }
.fo-edit-file { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 1/1; background: var(--paper); }
.fo-edit-file img { width: 100%; height: 100%; object-fit: contain; display: block; }
.fo-edit-file-generic {
    width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .2rem; padding: .4rem; text-align: center;
}
.fo-edit-file-generic span { font-size: 1.6rem; }
.fo-edit-file-generic small { font-size: .66rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.fo-edit-file form { position: absolute; top: .3rem; right: .3rem; margin: 0; }
.fo-edit-file button {
    width: 24px; height: 24px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; line-height: 1;
}
.fo-edit-file button:hover { background: var(--danger); }

/* ---------- Responsive -------------------------------------------------- */
@media (max-width: 640px) {
    .fo-topic { padding: .8rem .9rem 0; }
    .fo-topic-title-row { margin-bottom: .4rem; padding-bottom: .4rem; }
    .fo-topic-title-row .fo-topic-title { font-size: .98rem; }

    .fo-post { flex-direction: column; gap: .6rem; }
    .fo-post-side { width: auto; align-self: stretch; flex-direction: row; text-align: left; gap: .6rem; align-items: center; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
    .fo-post-avatar { width: 40px; height: 40px; font-size: 1rem; }

    .fo-recent-title-author { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Shared BBCode help disclosure (public/_bbcode_help.php) ---- */
.bbcode-help { margin: .5rem 0 1rem; border: 1px solid var(--border); border-radius: 6px; padding: .5rem .75rem; }
.bbcode-help summary { cursor: pointer; font-size: .82rem; font-weight: 700; color: var(--ink-soft); list-style: none; }
.bbcode-help summary::-webkit-details-marker { display: none; }
.bbcode-help[open] summary { margin-bottom: .5rem; }
.bbcode-help-grid { display: grid; gap: .35rem; font-size: .78rem; color: var(--ink-soft); }
.bbcode-help-grid code { background: var(--paper); padding: .1rem .35rem; border-radius: 4px; font-size: .76rem; }

/* ---------- Shared BBCode toolbar (public/_bbcode_toolbar.php) --------- */
.bbcode-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .15rem;
    padding: .25rem; border: 1px solid var(--border); border-bottom: none;
    border-radius: 6px 6px 0 0; background: var(--paper);
}
.bbcode-toolbar button {
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
    border: none; background: none; border-radius: 4px; color: var(--ink-soft);
    cursor: pointer; font-size: .74rem; transition: background .12s ease, color .12s ease;
}
.bbcode-toolbar button:hover { background: var(--surface); color: var(--indigo); }
.bbcode-toolbar-sep { width: 1px; height: 15px; background: var(--border); margin: 0 .1rem; }
.bbcode-toolbar-code { display: flex; align-items: center; gap: .15rem; }
.bbcode-lang-select {
    font-size: .68rem; padding: .15rem .25rem; border-radius: 4px; height: 24px;
    border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft);
}

/* The rich editing surface (public/assets/bbcode-toolbar.js) — a
   contenteditable div that replaces the textarea as what's actually typed
   into, so a pasted table/list/image shows as the real thing immediately
   instead of bracket text. Reuses the exact same .bbcode-* classes the
   published post display uses (quote/list/table/img/code below), since
   BBCode::render() output is literally what gets loaded into it on the
   edit page — what's shown here already matches what publishing produces. */
.bbcode-rich-editor {
    min-height: 220px; max-height: 480px; overflow-y: auto;
    padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 0 0 6px 6px;
    background: var(--surface); font-size: .92rem; line-height: 1.6;
}
.bbcode-rich-editor:focus { outline: 2px solid var(--indigo); outline-offset: -1px; }
.bbcode-rich-editor img { max-width: 100%; border-radius: 8px; margin: .35rem 0; display: block; }
.bbcode-upload-placeholder { color: var(--ink-soft); font-style: italic; }
editor-youtube-embed {
    display: block; padding: .5rem .75rem; margin: .5rem 0; border-radius: 6px;
    background: var(--paper); border: 1px dashed var(--border); color: var(--ink-soft); font-size: .85rem;
    user-select: none;
}

.bbcode-youtube {
    position: relative; width: 100%; max-width: 560px; aspect-ratio: 16/9;
    margin: .75rem 0; border-radius: 8px; overflow: hidden; background: #000;
}
.bbcode-youtube iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* Touch theme: scroll the toolbar horizontally instead of wrapping to a
   second row — keeps it to one tidy strip you can swipe through, since a
   phone-width screen can't fit every icon side by side otherwise. */
body.touch-theme .bbcode-toolbar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
body.touch-theme .bbcode-toolbar::-webkit-scrollbar { display: none; }
body.touch-theme .bbcode-toolbar button,
body.touch-theme .bbcode-toolbar-sep,
body.touch-theme .bbcode-toolbar-code { flex-shrink: 0; }
