/* ═══════════════════════════════════════
   BBCode Rendered Content Styles
   Used in post bodies, profile about/signature
   ═══════════════════════════════════════ */

/* Quote */
.bbcode-quote {
    border-left: 3px solid var(--color-primary-500);
    background: var(--color-surface-raised, rgba(99, 102, 241, 0.04));
    padding: 0.5rem 0.75rem;
    margin: 0.35rem 0;
    border-radius: 0 0.375rem 0.375rem 0;
    font-style: normal;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Hide stray <br> after quote blocks */
.bbcode-quote+br {
    display: none;
}

.bbcode-quote+br+br {
    display: none;
}

.dark .bbcode-quote {
    background: var(--color-dark-elevated, rgba(99, 102, 241, 0.06));
}

.bbcode-quote .bbcode-quote-author {
    font-size: 0.75rem;
    font-weight: 600;
    font-style: normal;
    color: var(--color-primary-500);
    margin-bottom: 0.2rem;
}

.bbcode-quote cite {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    font-style: normal;
    color: var(--color-primary-500);
    margin-bottom: 0.2rem;
}

/* Code Block Wrapper */
.bbcode-code-wrap {
    margin: 0.5rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--color-border-dark, rgba(255, 255, 255, 0.08));
    background: #0d1117;
}

/* Code Header (language + copy) */
.bbcode-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bbcode-code-lang {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-primary-400, #818cf8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bbcode-code-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.bbcode-code-copy:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.08);
}

.bbcode-code-copy.copied {
    color: #22c55e;
}

/* Code Block */
.bbcode-code {
    background: #0d1117;
    color: #e0e0e0;
    padding: 0.75rem;
    margin: 0;
    overflow-x: auto;
    font-size: 0.8rem;
    line-height: 1.6;
    display: flex;
    gap: 0.75rem;
}

.bbcode-code code {
    background: transparent;
    color: inherit;
    font-size: inherit;
    padding: 0;
    flex: 1;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* Line Numbers */
.bbcode-code-lines {
    display: flex;
    flex-direction: column;
    text-align: right;
    user-select: none;
    min-width: 2rem;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding-right: 0.75rem;
}

.bbcode-code-ln {
    font-size: 0.7rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.2);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Light Mode: Code Blocks ── */
[data-theme="light"] .bbcode-code-wrap {
    background: #f8f9fc !important;
    border-color: #e2e8f0 !important;
}

[data-theme="light"] .bbcode-code-header {
    background: #f1f5f9 !important;
    border-bottom-color: #e2e8f0 !important;
}

[data-theme="light"] .bbcode-code-lang {
    color: var(--color-primary-600, #4f46e5) !important;
}

[data-theme="light"] .bbcode-code-copy {
    color: #64748b !important;
}

[data-theme="light"] .bbcode-code-copy:hover {
    color: #1e293b !important;
    background: rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .bbcode-code {
    background: #f8f9fc !important;
    color: #334155 !important;
}

[data-theme="light"] .bbcode-code code {
    color: #334155 !important;
    background: transparent !important;
}

[data-theme="light"] .bbcode-code-lines {
    border-right-color: #e2e8f0 !important;
}

[data-theme="light"] .bbcode-code-ln {
    color: #94a3b8 !important;
}

/* Inline code */
.bbcode-icode {
    background: var(--color-surface-raised, rgba(99, 102, 241, 0.08));
    color: var(--color-primary-600, #6366f1);
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.85em;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.dark .bbcode-icode {
    background: rgba(99, 102, 241, 0.12);
    color: var(--color-primary-400);
}

/* Spoiler */
.bbcode-spoiler {
    margin: 0.5rem 0;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
    border-radius: 0.5rem;
    overflow: hidden;
}

.dark .bbcode-spoiler {
    border-color: var(--color-border-dark, rgba(255, 255, 255, 0.08));
}

.bbcode-spoiler>summary {
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--color-surface-raised, rgba(0, 0, 0, 0.02));
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dark .bbcode-spoiler>summary {
    background: var(--color-dark-elevated, rgba(255, 255, 255, 0.03));
}

.bbcode-spoiler>summary::before {
    content: '▶';
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.bbcode-spoiler[open]>summary::before {
    transform: rotate(90deg);
}

.bbcode-spoiler> :not(summary) {
    padding: 0.75rem;
}

/* Inline spoiler */
.bbcode-ispoiler {
    background: var(--color-on-surface, #333);
    color: transparent;
    padding: 0.1em 0.3em;
    border-radius: 0.2rem;
    cursor: pointer;
    transition: color 0.2s;
    user-select: none;
}

.bbcode-ispoiler:hover,
.bbcode-ispoiler:focus,
.bbcode-ispoiler.revealed {
    color: inherit;
    background: var(--color-surface-raised, rgba(0, 0, 0, 0.06));
}

.dark .bbcode-ispoiler {
    background: rgba(255, 255, 255, 0.15);
}

.dark .bbcode-ispoiler:hover,
.dark .bbcode-ispoiler.revealed {
    background: rgba(255, 255, 255, 0.06);
}

/* List */
.bbcode-list {
    padding-left: 1.5rem;
    margin: 0.25rem 0;
    list-style-type: disc;
}

/* WYSIWYG editor list styles — !important to override CSS resets */
.wysiwyg-editor ul,
.wysiwyg-editor ol {
    padding-left: 1.5rem !important;
    margin: 0.25rem 0 !important;
    display: block !important;
}

.wysiwyg-editor ul {
    list-style-type: disc !important;
}

.wysiwyg-editor ol {
    list-style-type: decimal !important;
}

.wysiwyg-editor li {
    margin: 0.15rem 0;
    display: list-item !important;
}

/* Table */
.bbcode-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.85rem;
}

.bbcode-th,
.bbcode-td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    text-align: left;
}

.dark .bbcode-th,
.dark .bbcode-td {
    border-color: var(--color-border-dark, rgba(255, 255, 255, 0.08));
}

.bbcode-th {
    font-weight: 600;
    background: var(--color-surface-raised, rgba(0, 0, 0, 0.03));
}

.dark .bbcode-th {
    background: var(--color-dark-elevated, rgba(255, 255, 255, 0.04));
}

/* Indent */
.bbcode-indent {
    margin: 0.25rem 0;
}

/* Heading */
.bbcode-heading {
    margin: 0.5rem 0 0.25rem;
    font-weight: 700;
}

/* Horizontal Rule */
.bbcode-hr {
    border: none;
    border-top: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    margin: 0.75rem 0;
}

.dark .bbcode-hr {
    border-color: var(--color-border-dark, rgba(255, 255, 255, 0.08));
}

/* PHP/HTML code blocks */
.bbcode-php,
.bbcode-html {
    background: #0d1117;
    color: #e0e0e0;
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-size: 0.8rem;
    border: 1px solid var(--color-border-dark, rgba(255, 255, 255, 0.08));
}

/* ── Light Mode: PHP/HTML blocks ── */
[data-theme="light"] .bbcode-php,
[data-theme="light"] .bbcode-html {
    background: #f8f9fc;
    color: #334155;
    border-color: #e2e8f0;
}

/* Mention */
.bbcode-mention {
    font-weight: 600;
    color: var(--color-primary-500);
    cursor: pointer;
}

.bbcode-mention:hover {
    text-decoration: underline;
}

/* Embed */
.bbcode-embed {
    max-width: 100%;
    margin: 0.5rem 0;
}

.bbcode-embed iframe {
    max-width: 100%;
    border-radius: 0.5rem;
}

/* Attachment placeholder */
.bbcode-attach {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--color-surface-raised, rgba(99, 102, 241, 0.06));
    border-radius: 0.25rem;
    font-size: 0.8rem;
    color: var(--color-primary-500);
    text-decoration: none;
}

.bbcode-attach:hover {
    text-decoration: underline;
}

/* Inline spoiler click handler */
.bbcode-ispoiler {
    cursor: pointer;
}