/* Forum styles on top of the site theme (Bootstrap 4 / material-kit). */
.forum-wrap { padding-top: 10px; padding-bottom: 40px; }
.forum-wrap .flex-grow-1 { flex-grow: 1; }
.forum-wrap .d-flex > .btn, .forum-wrap .d-flex > a.btn { margin: 0 0 0 12px; align-self: flex-start; }
.forum-wrap #main { padding: 0 15px; }
.forum-nav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 10px 0 20px; border-bottom: 1px solid #00000014; margin-bottom: 20px; }
.forum-nav a, .forum-nav .btn-link { color: #02324a; font-weight: 600; text-decoration: none; }
.forum-nav a:hover, .forum-nav .btn-link:hover { color: #377856; }
.forum-nav-spacer { flex: 1; }
.forum-user { color: #377856; font-weight: 600; }
.forum-wrap h1, .forum-wrap h2, .forum-wrap h3, .forum-wrap h4 { color: #02324a; }
.forum-wrap .card { border: 1px solid #00000014; border-radius: 6px; margin-bottom: 1em; box-shadow: none; }
.forum-wrap .btn-primary { background: #377856; border-color: #377856; }
.forum-wrap .btn-primary:hover { background: #2c6046; border-color: #2c6046; }
.forum-wrap textarea { min-height: 200px; }
.forum-wrap table tr td { white-space: nowrap; }
.forum-wrap .deleted { opacity: .65; }
.forum-wrap .timestamp { border-bottom: 1px dotted #999; cursor: help; }
.forum-wrap .form-select { display: block; width: 100%; height: calc(1.5em + .75rem + 2px); padding: .375rem .75rem; border: 1px solid #ced4da; border-radius: .25rem; background: #fff; }
.forum-wrap .btn-close { float: inline-end; border: 0; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.forum-wrap .btn-close::before { content: "\00d7"; }

/* Restore plain form controls inside the forum (the site theme restyles them). */
.forum-wrap label { position: static !important; transform: none !important; display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: #02324a; text-transform: none; pointer-events: auto; text-align: start; }
.forum-wrap .form-control, .forum-wrap textarea.form-control, .forum-wrap select.form-control {
    display: block; width: 100%; height: auto; padding: 8px 12px; background: #fff !important; background-image: none !important;
    border: 1px solid #ced4da !important; border-radius: 4px; box-shadow: none !important; color: #333; font-size: 15px; text-align: start;
}
.forum-wrap .form-control:focus { border-color: #377856 !important; outline: 0; }
.forum-wrap .form-group, .forum-wrap .mb-3 { margin-bottom: 16px; padding-bottom: 0; }
.forum-wrap .form-check { display: flex; align-items: center; gap: 8px; padding: 0; margin: 0 0 8px; }
.forum-wrap .form-check label, .forum-wrap .form-check-label { display: inline; margin: 0; padding: 0 !important; font-weight: 400; cursor: pointer; text-align: start; }
.forum-wrap input[type=checkbox], .forum-wrap .form-check-input {
    position: static !important; opacity: 1 !important; visibility: visible !important; width: auto; height: auto;
    pointer-events: auto !important; z-index: auto !important; cursor: pointer; flex: 0 0 auto;
    margin: 0 !important; appearance: auto; -webkit-appearance: checkbox; vertical-align: middle;
}
.forum-wrap input[type=color].form-control { padding: 2px; height: 38px; width: 90px; }

/* Modals (own markup, independent of the site theme). */
.fm-modal { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.45); overflow-y: auto; }
.fm-modal.show { display: block; }
.fm-dialog { text-align: start; max-width: 520px; width: calc(100% - 30px); margin: 8vh auto; background: #fff; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.fm-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #00000014; }
.fm-title { margin: 0; font-size: 18px; color: #02324a; }
.fm-close { border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: #666; padding: 0 4px; }
.fm-body { padding: 20px; }
.fm-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid #00000014; }
.fm-footer .btn { margin: 0; }

/* Thread list / badges (moved out of the views: the site's Vue 2 app would try to compile inline <style>). */
.forum-wrap .list-group.threads .list-group-item { border-left-width: 2px; }
.forum-wrap .list-group.threads .list-group-item.locked { border-left-color: #ffc107; }
.forum-wrap .list-group.threads .list-group-item.pinned { border-left-color: #17a2b8; }
.forum-wrap .list-group.threads .list-group-item.deleted { border-left-color: #dc3545; opacity: .5; }


/* Post/card headers: undo the theme's floating, shadowed header look. */
.forum-wrap .card-header { margin: 0 !important; box-shadow: none !important; background: #f1f4f6 !important; color: #02324a; border-bottom: 1px solid #00000014; border-radius: 6px 6px 0 0 !important; padding: 10px 15px !important; }
.forum-wrap .card-body { padding: 15px; }
.forum-wrap .post.card { overflow: hidden; }

/* Category / thread list rows (own layout; the preset targets Bootstrap 5 grid classes). */
.forum-wrap .list-group-item { padding: 16px 20px; border: 1px solid #00000014; background: #fff; }
.forum-wrap .fm-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 150px minmax(0, 1fr); gap: 24px; align-items: center; }
.forum-wrap .fm-col-main { min-width: 0; text-align: start; }
.forum-wrap .fm-col-stats { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; font-size: 14px; color: #555; }
.forum-wrap .fm-col-last { font-size: 14px; color: #777; text-align: end; line-height: 1.5; }
.forum-wrap .fm-col-last > div { margin-bottom: 2px; }
.forum-wrap .timestamp { white-space: nowrap; }
@media (max-width: 767px) {
    .forum-wrap .fm-row { grid-template-columns: 1fr; gap: 8px; }
    .forum-wrap .fm-col-last { text-align: start; }
}
.forum-wrap .fm-stat strong { color: #02324a; margin-inline-end: 4px; }
.forum-wrap h5.card-title { margin: 0 0 4px; font-size: 19px; }
.forum-wrap .card-text { margin: 0; }
.forum-wrap .lead { font-size: 18px; }
.forum-wrap .fm-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; line-height: 1.6; color: #fff; text-transform: none; vertical-align: middle; margin: 0 2px; background: #377856; }
.forum-wrap .fm-badge-info { background: #17a2b8; }
.forum-wrap .fm-badge-warning { background: #d39e00; }
.forum-wrap .fm-badge-success { background: #28a745; }
.forum-wrap .fm-badge-danger { background: #dc3545; }
.forum-wrap .subcategories { border-top: 1px solid #00000010; background: #fafbfc; }

/* Nav row: make the user name and the log-out button sit on the same baseline. */
.forum-nav { align-items: center; }
.forum-nav > a, .forum-nav > span, .forum-nav form { line-height: 1.4; }
.forum-nav form { margin: 0; display: flex; align-items: center; }
.forum-nav .btn, .forum-nav .btn-link {
    padding: 0 !important; margin: 0 !important; min-height: 0; height: auto; background: transparent !important; box-shadow: none !important;
    font-size: inherit; font-weight: 600; line-height: 1.4; text-transform: none; letter-spacing: normal; color: #02324a; vertical-align: baseline;
}
.forum-nav .btn:hover, .forum-nav .btn-link:hover { color: #377856; }
.forum-wrap .fm-row { width: 100%; box-sizing: border-box; }

/* Avatars, profile, search, nav search. */
.forum-wrap .fm-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; vertical-align: middle; flex: 0 0 auto; }
.forum-wrap .fm-avatar-sm { width: 24px; height: 24px; font-size: 12px; margin-inline-end: 4px; }
.forum-wrap .fm-avatar-lg { width: 72px; height: 72px; font-size: 32px; }
.forum-wrap .fm-author { color: inherit; font-weight: 600; text-decoration: none; }
.forum-wrap .fm-author:hover { color: #377856; }
.forum-wrap .fm-profile-head { display: flex; align-items: center; gap: 20px; margin: 10px 0 20px; }
.forum-wrap .fm-check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.forum-wrap .fm-check input { width: auto; position: static; opacity: 1; margin: 0; }
.forum-wrap .fm-search-form { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.forum-wrap .fm-search-form .btn { margin: 0; }
.forum-wrap .fm-result .lead { display: block; margin-bottom: 4px; }
.forum-nav .fm-nav-search { margin: 0; }
.forum-nav .fm-nav-search input { height: 34px; padding: 4px 12px; border: 1px solid #ced4da; border-radius: 17px; background: #fff; font-size: 14px; width: 170px; }
.forum-nav .forum-user { display: inline-flex; align-items: center; }
@media (max-width: 767px) {
    .forum-nav { gap: 12px; }
    .forum-nav .fm-nav-search { order: 10; flex: 1 1 100%; }
    .forum-nav .fm-nav-search input { width: 100%; }
    .forum-nav-spacer { display: none; }
}

/* Mobile: let action button groups wrap instead of overflowing. */
.forum-wrap .btn-group { flex-wrap: wrap; max-width: 100%; }
@media (max-width: 767px) {
    .forum-wrap .btn-group .btn, .forum-wrap .btn-group > a.btn { padding: 8px 12px; font-size: 12px; margin: 2px; }
    .forum-wrap .d-flex > .btn, .forum-wrap .d-flex > a.btn { margin: 0 0 8px 0; }
    .forum-wrap .card-header { padding: 8px 10px !important; }
}

/* RTL-safe replacements for the preset's physical left/right helpers. */
.forum-wrap .float-right, .forum-wrap .float-end { float: inline-end !important; }
.forum-wrap .mr-3 { margin-right: 0 !important; margin-inline-end: 1rem !important; }
.forum-wrap .pull-right { float: none; }

/* Text starts from the reading side (right in Arabic, left in English). :where() keeps specificity at
   zero for the tag list so the explicit rules above (e.g. .fm-col-last { text-align: end }) still win. */
.forum-wrap { text-align: start; }
.forum-wrap :where(h1, h2, h3, h4, h5, h6, p, li, td, th, div, span, small, label, a, blockquote, pre, dd, dt) { text-align: start; }
.forum-wrap .card-title, .forum-wrap .card-text { text-align: start; }
.forum-wrap .page-head, .forum-wrap .d-flex.justify-content-between { gap: 12px; align-items: center; }
.forum-wrap ul, .forum-wrap ol { padding-inline-start: 1.5em; padding-inline-end: 0; }
.forum-wrap .breadcrumb { padding-inline-start: 16px; }
.forum-wrap .btn-group > .btn:not(:first-child) { margin-inline-start: -1px; }

/* Alerts: message starts from the reading side, close button sits at the opposite end (RTL-safe). */
.forum-wrap .alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px !important; margin: 0 0 14px; text-align: start; }
.forum-wrap .alert .message { order: 1; flex: 1 1 auto; margin: 0 !important; padding: 0 !important; text-align: start; }
.forum-wrap .alert .btn-close { order: 2; float: none !important; flex: 0 0 auto; margin: 0; padding: 0 4px; color: inherit; opacity: .8; }
.forum-wrap .alert .message a { text-decoration: underline; }
.forum-wrap .breadcrumb { display: flex; flex-wrap: wrap; align-items: center; text-align: start; }

/* List rows: main + stats start from the reading side, the last-post column ends at the opposite edge.
   (The generic start rule above resets child divs, so the children are listed explicitly.) */
.forum-wrap .fm-col-last,
.forum-wrap .fm-col-last :where(div, span, a, br) { text-align: end; }
.forum-wrap .fm-col-last > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 8px; }
.forum-wrap .fm-col-main, .forum-wrap .fm-col-main :where(h5, p, a) { text-align: start; }

/* Category / thread pages: action row and bottom row follow the page direction. */
.forum-wrap #category > .clearfix { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.forum-wrap #category > .clearfix > .btn-group { order: 1; }
.forum-wrap #category > .clearfix > .btn { order: 2; float: none !important; margin-inline-start: auto; }
.forum-wrap .text-end { text-align: end !important; }
.forum-wrap .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-inline: 0; }
.forum-wrap .row > .col { flex: 1 1 auto; width: auto; max-width: none; padding-inline: 0; }
.forum-wrap h2 small { font-size: 60%; color: #777; font-weight: 400; }
.forum-wrap .fm-col-last > a { display: inline-block; }

/* Arabic keeps the same sizes/weights as English inside the forum (the site's [dir=rtl] rules bump
   paragraphs to 16px/500 and form fields to 15px/500; only the font family should change). */
[dir="rtl"] .forum-wrap p { font-size: 14px; font-weight: 300; }
[dir="rtl"] .forum-wrap .form-control { font-size: 15px; font-weight: 400; }

/* Comfortable, identical line spacing in both languages (the theme sets line-height equal to the font size on
   some of these, which makes Arabic glyphs, the 24px avatar and the text sit unevenly). */
.forum-wrap p, .forum-wrap .fm-stat, .forum-wrap .fm-col-main, .forum-wrap .fm-col-last, .forum-wrap .fm-col-stats { line-height: 1.6; }
.forum-wrap .card-text { margin: 0 0 4px; }
.forum-wrap .fm-author { display: inline-flex; align-items: center; vertical-align: middle; }

/* Material Kit adds `.list-group-item :first-child { margin-right: 2rem }`, which pushed titles, links and
   stat numbers 32px away from the edge (visible in Arabic). Not wanted inside the forum. */
.forum-wrap .list-group-item :first-child { margin-right: 0; }
