/* ==========================================================
   FORUM
========================================================== */

#forumView {
    background: var(--navy);
    color: var(--text-primary);
}

.forum-container {
    max-width: 1200px;
    margin: auto;
}

.forum-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.forum-thread-search {
    display: block;
    margin-bottom: 20px;
}

.forum-thread-search input {
    width: 100%;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text-primary);
    font: inherit;
}

.forum-thread-search input:focus {
    border-color: var(--gold-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(78, 143, 255, .16);
}

.forum-thread-search input::placeholder {
    color: var(--text-muted);
}

.forum-heading-row h2 {
    margin: 5px 0 0;
}

.forum-primary-button {
    padding: 11px 17px;
    border: 1px solid var(--gold-light);
    border-radius: 12px;
    background: var(--gold);
    color: #ffffff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.forum-primary-button:hover {
    background: var(--gold-light);
    transform: translateY(-1px);
}

.forum-heading-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.forum-secondary-button {
    padding: 11px 17px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-3);
    color: var(--text-secondary);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.forum-secondary-button:hover {
    border-color: var(--gold-light);
    color: var(--text-primary);
}

.forum-secondary-button.active {
    border-color: var(--gold);
    background: var(--gold);
    color: #ffffff;
}

.new-thread-box {
    margin-bottom: 24px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    box-shadow: var(--shadow-sm);
}

.new-thread-box[hidden] {
    display: none;
}

.forum-field {
    display: block;
    margin-bottom: 15px;
}

.forum-mention-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.forum-mention-grid select[multiple] {
    min-height: 130px;
}

.forum-field small {
    color: var(--text-muted);
    font-size: .76rem;
    line-height: 1.4;
}

.forum-field-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.forum-mention-all {
    padding: 5px 8px;
    border: 1px solid var(--gold-light);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--gold-light);
    font: inherit;
    font-size: .72rem;
    font-weight: 800;
    cursor: pointer;
}

.forum-mention-all:hover {
    background: var(--surface-4);
    color: var(--text-primary);
}

.thread-mentions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 12px;
}

.thread-mentions span {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-4);
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 800;
}

.forum-field span,
.reply-box label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 800;
}

.forum-field input,
.forum-field select,
.forum-field textarea,
.reply-box textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    outline: none;
    background: var(--surface-1);
    color: var(--text-primary);
    font: inherit;
}

.forum-field textarea,
.reply-box textarea {
    min-height: 115px;
    resize: vertical;
}

.forum-field input:focus,
.forum-field select:focus,
.forum-field textarea:focus,
.reply-box textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(78, 143, 255, 0.16);
}

.forum-message {
    min-height: 20px;
    color: var(--danger);
    font-size: 0.88rem;
}

.forum-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: start;
    gap: 24px;
}

.thread-list {
    display: grid;
    gap: 14px;
}

.thread-card {
    width: 100%;
    margin: 0;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-2);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

.thread-card:hover {
    border-color: var(--gold);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.thread-tag {
    display: inline-block;
    margin-bottom: 10px;
    padding: 5px 9px;
    border-radius: var(--radius-pill);
    background: var(--surface-4);
    color: var(--gold-light);
    font-size: 0.75rem;
    font-weight: 900;
}

.thread-title {
    margin: 0 0 9px;
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.thread-card-shell {
    position: relative;
}

.thread-card-shell .thread-card {
    width: 100%;
}

.forum-admin-actions {
    display: flex;
    gap: 7px;
}

.forum-admin-actions button {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-3);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
}

.forum-admin-actions button:hover {
    border-color: var(--gold-light);
}

.forum-admin-actions button:last-child {
    border-color: var(--danger);
    color: var(--danger);
}

.forum-card-actions {
    display: flex;
    gap: 7px;
}

.thread-card-shell {
    position: relative;
}

.thread-card-shell > .forum-card-actions {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
}

.forum-card-actions button {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-3);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
}

.forum-card-actions button:hover {
    border-color: var(--gold-light);
}

.forum-card-actions [data-admin-delete-thread] {
    border-color: var(--danger);
    color: var(--danger);
}

.forum-card-actions button.thread-star {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.forum-card-actions button.thread-star.starred {
    border-color: var(--gold);
    color: var(--gold);
}

.forum-post-admin {
    justify-content: flex-end;
    margin-top: 14px;
}

.forum-post-edited {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-style: italic;
}

.forum-post-user-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.forum-post-user-actions button {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-3);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
}

.forum-post-user-actions button:hover {
    border-color: var(--gold-light);
}

.thread-snippet {
    margin: 0 0 16px;
    overflow-wrap: anywhere;
    color: var(--text-secondary);
    line-height: 1.55;
}

.thread-meta {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.forum-empty {
    color: var(--text-muted);
    cursor: default;
    text-align: center;
}

.forum-filter-panel {
    position: sticky;
    top: 22px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-2);
}

.forum-filter-panel h3 {
    margin: 0 0 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.forum-filter-panel h3:not(:first-child) {
    margin-top: 20px;
}

.forum-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.forum-filter-chip {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.forum-filter-chip:hover,
.forum-filter-chip.active {
    border-color: var(--gold);
    background: var(--surface-4);
    color: var(--text-primary);
}

.forum-local-note {
    margin: 20px 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

.thread-detail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2100;
    background: rgba(0, 0, 0, 0.68);
}

.thread-detail-backdrop[hidden],
.thread-detail[hidden] {
    display: none;
}

.thread-detail {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 2200;
    display: flex;
    box-sizing: border-box;
    width: min(620px, 94vw);
    height: 100vh;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--surface-1);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
}

.thread-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.thread-detail-header p {
    margin: 0 0 5px;
    color: var(--gold-light);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.thread-detail-header h2 {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 1.4rem;
}

.thread-detail-close {
    display: grid;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-primary);
    font: inherit;
    font-size: 1.3rem;
    cursor: pointer;
}

.thread-detail-body {
    flex: 1;
    padding: 22px;
    overflow-y: auto;
}

.forum-post {
    margin-bottom: 15px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface-2);
}

.forum-post.original {
    border-left: 4px solid var(--gold);
}

.forum-post-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.forum-post-heading strong {
    overflow-wrap: anywhere;
    color: var(--text-primary);
}

.forum-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: var(--gold);
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 900;
}

.forum-post p {
    margin: 14px 0 0;
    overflow-wrap: anywhere;
    color: var(--text-secondary);
    line-height: 1.6;
}

.forum-no-replies {
    padding: 18px;
    color: var(--text-muted);
    text-align: center;
}

.reply-box {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.reply-box textarea {
    min-height: 88px;
    margin-bottom: 6px;
}

.forum-char-count {
    display: block;
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: right;
}

.forum-char-count-limit {
    color: var(--danger);
    font-weight: 800;
}

body.thread-detail-open {
    overflow: hidden;
}

@media (max-width: 800px) {
    .forum-layout {
        grid-template-columns: 1fr;
    }

    .forum-filter-panel {
        position: static;
        grid-row: 1;
    }
}

@media (max-width: 520px) {
    .forum-heading-row {
        align-items: stretch;
        flex-direction: column;
    }

    .forum-heading-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .thread-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .new-thread-box {
        padding: 18px;
    }

    .forum-mention-grid {
        grid-template-columns: 1fr;
    }
}
