/* ==========================================================================
   AutomatorsX LMS — community
   Shared by the global forums, a course community and the community tab in
   the player, so a thread looks and behaves the same wherever it is read.
   ========================================================================== */

/* --- Page header --------------------------------------------------------- */
.fm-header { background: var(--surface-1); border-bottom: 1px solid var(--border); padding: 34px 0 28px; }
.fm-header h1 { font-family: var(--font-display); font-size: 2rem; letter-spacing: -.02em; margin-bottom: 8px; }
.fm-header p { color: var(--text-secondary); font-size: 14.5px; max-width: 620px; line-height: 1.6; }
.fm-crumbs { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }
.fm-crumbs a { color: var(--text-muted); }
.fm-crumbs a:hover { color: var(--primary); }

/* --- Forum cards --------------------------------------------------------- */
.fm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.fm-forum {
    display: flex; gap: 14px; align-items: flex-start;
    background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
    padding: 18px; transition: border-color .18s, transform .18s;
}
.fm-forum:hover { border-color: var(--primary); transform: translateY(-2px); }
.fm-forum-icon {
    width: 42px; height: 42px; border-radius: 11px; flex: none; display: grid; place-items: center;
    background: var(--surface-2); color: var(--primary); font-size: 16px;
}
.fm-forum h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.fm-forum p { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; margin-bottom: 8px; }
.fm-forum-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.fm-private { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: var(--surface-2); color: var(--text-secondary); }

/* --- Topic list ---------------------------------------------------------- */
.fm-topics { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; overflow: hidden; }
.fm-topic {
    display: flex; gap: 14px; align-items: center;
    padding: 15px 18px; border-bottom: 1px solid var(--border-light, var(--border));
}
.fm-topic:last-child { border-bottom: 0; }
.fm-topic:hover { background: var(--surface-1); }
.fm-topic-main { flex: 1; min-width: 0; }
.fm-topic-title { font-size: 14.5px; font-weight: 600; color: var(--text); display: block; margin-bottom: 4px; }
.fm-topic-title:hover { color: var(--primary); }
.fm-topic-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.fm-topic-stats { text-align: center; font-size: 12px; color: var(--text-muted); flex: none; min-width: 62px; }
.fm-topic-stats strong { display: block; font-size: 15px; color: var(--text); font-family: var(--font-display); }

.fm-flag { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 5px; margin-right: 6px; }
.fm-flag.pinned  { background: var(--info-bg, rgba(8,145,178,.1)); color: var(--info, #0891b2); }
.fm-flag.solved  { background: var(--success-bg, rgba(16,185,129,.12)); color: var(--success, #059669); }
.fm-flag.locked  { background: var(--surface-2); color: var(--text-muted); }

/* --- Avatars ------------------------------------------------------------- */
.fm-avatar {
    width: 38px; height: 38px; border-radius: 50%; flex: none; object-fit: cover;
    background: var(--surface-2); display: grid; place-items: center;
    font-weight: 700; font-size: 14px; color: var(--text-secondary);
}
.fm-avatar.sm { width: 30px; height: 30px; font-size: 12px; }

/* --- Thread -------------------------------------------------------------- */
.fm-post {
    background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
    padding: 20px; margin-bottom: 16px;
}
.fm-post-head { display: flex; gap: 11px; align-items: center; margin-bottom: 13px; }
.fm-post-author { font-size: 13.5px; font-weight: 600; }
.fm-post-when { font-size: 12px; color: var(--text-muted); }
.fm-badge-role { font-size: 10.5px; padding: 2px 7px; border-radius: 20px; background: var(--primary); color: #fff; font-weight: 700; }
.fm-badge-op { font-size: 10.5px; padding: 2px 7px; border-radius: 20px; background: var(--surface-2); color: var(--text-secondary); font-weight: 700; }

/* Member-supplied markup, already reduced to a safe subset by ForumService. */
.fm-body { font-size: 14px; color: var(--text-secondary); line-height: 1.7; overflow-wrap: anywhere; }
.fm-body p { margin-bottom: 11px; }
.fm-body p:last-child { margin-bottom: 0; }
.fm-body ul, .fm-body ol { margin: 0 0 11px 20px; }
.fm-body li { margin-bottom: 5px; }
.fm-body a { color: var(--primary); text-decoration: underline; }
.fm-body blockquote { border-left: 3px solid var(--border); padding-left: 13px; color: var(--text-muted); margin-bottom: 11px; }
.fm-body pre { background: var(--surface-2); padding: 13px; border-radius: 9px; overflow-x: auto; margin-bottom: 11px; font-size: 12.5px; }
.fm-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.fm-body h3, .fm-body h4 { font-weight: 700; color: var(--text); margin-bottom: 8px; }

.fm-post-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.fm-act {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: 1px solid var(--border); border-radius: 20px;
    padding: 5px 12px; font: inherit; font-size: 12px; color: var(--text-muted); cursor: pointer;
}
.fm-act:hover { border-color: var(--primary); color: var(--primary); }
.fm-act.on { border-color: var(--primary); color: var(--primary); background: rgba(255,0,0,.05); }
.fm-act.solution { border-color: var(--success, #059669); color: var(--success, #059669); }

/* --- Replies ------------------------------------------------------------- */
.fm-reply { border-top: 1px solid var(--border-light, var(--border)); padding: 16px 0; }
.fm-reply:first-child { border-top: 0; }
.fm-reply.is-solution { background: var(--success-bg, rgba(16,185,129,.06)); border-radius: 11px; padding: 16px; border-top: 0; margin-bottom: 10px; }
.fm-children { margin-left: 42px; margin-top: 12px; padding-left: 14px; border-left: 2px solid var(--border); }

/* --- Composer ------------------------------------------------------------ */
.fm-composer {
    background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
    padding: 18px; margin-bottom: 20px;
}
.fm-composer h3 { font-size: 14.5px; font-weight: 700; margin-bottom: 12px; }
.fm-composer input[type=text],
.fm-composer textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface-1); color: var(--text); font: inherit; font-size: 13.5px; margin-bottom: 10px;
}
.fm-composer textarea { resize: vertical; line-height: 1.65; min-height: 96px; }
.fm-composer input:focus, .fm-composer textarea:focus { outline: 0; border-color: var(--primary); background: var(--surface); }
.fm-composer-note { font-size: 12px; color: var(--text-muted); margin-left: 10px; }
.fm-image-upload { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin: 0 0 13px; color: var(--text-secondary); font-size: 13px; }
.fm-image-upload > i { color: var(--primary); font-size: 16px; }
.fm-image-upload-copy { min-width: 170px; }
.fm-image-upload-copy strong { display: block; color: var(--text); font-size: 13px; }
.fm-image-upload small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.fm-image-picker { position: relative; display: inline-flex; align-items: center; justify-content: center; padding: 7px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-full, 20px); background: var(--surface); color: var(--text);
    font-size: 12px; font-weight: 700; cursor: pointer; transition: border-color .15s ease, color .15s ease; }
.fm-image-picker:hover { border-color: var(--primary); color: var(--primary); }
.fm-image-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.fm-image-picker:focus-within { outline: 2px solid var(--primary-glow); outline-offset: 2px; }
.fm-image-file-name { color: var(--text-muted); font-size: 12px; }
.fm-attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 9px; margin-top: 14px; }
.fm-attachments a { display: block; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface-1); }
.fm-attachments img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform .18s ease; }
.fm-attachments a:hover img { transform: scale(1.03); }
.fm-image-lightbox { display: none; position: fixed; inset: 0; z-index: 310; padding: 16px; background: rgba(8,10,16,.92); }
.fm-image-lightbox.open { display: flex; flex-direction: column; }
.fm-image-lightbox-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1200px; width: 100%; margin: 0 auto 12px; color: #fff; font-size: 13px; }
.fm-image-lightbox-toolbar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-image-lightbox-toolbar > div { display: flex; gap: 7px; flex: none; }
.fm-image-lightbox-toolbar button { width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.28); border-radius: 8px; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; }
.fm-image-lightbox-toolbar button:hover { background: var(--primary); border-color: var(--primary); }
.fm-image-lightbox-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; cursor: zoom-in; }
.fm-image-lightbox-stage img { display: block; max-width: min(100%, 1180px); max-height: calc(100vh - 90px); object-fit: contain; transform-origin: center; transition: transform .15s ease; }
@media (max-width: 520px) { .fm-image-lightbox { padding: 10px; } .fm-image-lightbox-toolbar { margin-bottom: 8px; } }

.fm-notice {
    background: var(--surface-1); border: 1px dashed var(--border); border-radius: 11px;
    padding: 16px 18px; font-size: 13.5px; color: var(--text-secondary); margin-bottom: 20px;
    display: flex; gap: 11px; align-items: flex-start;
}
.fm-notice i { color: var(--text-muted); margin-top: 2px; }

.fm-empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.fm-empty i { font-size: 34px; opacity: .4; margin-bottom: 12px; display: block; }

/* --- Report dialog ------------------------------------------------------- */
.fm-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; padding: 20px; }
.fm-modal.open { display: grid; place-items: center; }
.fm-modal-box { background: var(--surface); border-radius: 14px; width: 100%; max-width: 420px; padding: 22px; }
.fm-modal-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.fm-modal-box p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.fm-modal-box textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface-1); color: var(--text); font: inherit; font-size: 13.5px; margin-bottom: 12px;
}
.fm-modal-foot { display: flex; justify-content: flex-end; gap: 9px; }

@media (max-width: 720px) {
    .fm-topic-stats { display: none; }
    .fm-children { margin-left: 0; padding-left: 11px; }
}

/* Homepage-aligned community layer -------------------------------------- */
.fm-header {
    position: relative;
    overflow: hidden;
    padding: 108px 0 56px;
    background: var(--bg-gradient);
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.fm-header::before {
    content: '';
    position: absolute;
    width: 340px;
    height: 340px;
    top: -185px;
    right: -125px;
    border-radius: 50%;
    background: var(--primary-surface);
    pointer-events: none;
}
.fm-header .container { position: relative; z-index: 1; }
.fm-header h1 { font-size: clamp(2.25rem, 5vw, 3.8rem); font-weight: 900; letter-spacing: -.055em; margin-bottom: 14px; }
.fm-header p { max-width: 660px; margin: 0 auto; font-size: 16px; line-height: 1.7; }
.fm-crumbs { text-align: left; max-width: 900px; margin-inline: auto; }
.fm-forum { padding: 22px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base); }
.fm-forum:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.fm-forum-icon { width: 48px; height: 48px; border-radius: var(--radius-md); background: var(--primary-surface); color: var(--primary); }
.fm-forum h3 { font-size: 16px; letter-spacing: -.01em; }
.fm-forum p { font-size: 13px; line-height: 1.6; }
.fm-private { background: var(--primary-surface); color: var(--primary); }
.fm-topics { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.fm-topic { padding: 18px 20px; transition: background var(--transition-fast); }
.fm-topic:hover { background: var(--surface-1); }
.fm-topic-title { font-size: 15px; font-weight: 700; }
.fm-avatar { background: var(--primary-surface); color: var(--primary); }
.fm-post, .fm-composer { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 24px; }
.fm-composer { background: var(--surface-2); }
.fm-composer input[type=text], .fm-composer textarea, .fm-modal-box textarea { border-radius: var(--radius-md); background: var(--surface-1); }
.fm-act { border-radius: var(--radius-full); }
.fm-notice { border-radius: var(--radius-md); background: var(--surface-1); }
.fm-empty { padding: 76px 20px; border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--surface-1); }
.fm-empty i { color: var(--primary); opacity: .8; }
.fm-modal-box { border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); }

@media (max-width: 720px) {
    .fm-header { padding: 94px 0 44px; text-align: left; }
    .fm-header p { margin-left: 0; }
    .fm-forum { padding: 18px; }
    .fm-post, .fm-composer { padding: 18px; }
}
