/* ──────────────────────────────────────────────────────────────────────────
 * CrnaBerza BBCode editor + rendered-post extras
 * Plain CSS (not Tailwind) so no rebuild of tailwind.css is needed.
 * ────────────────────────────────────────────────────────────────────────── */

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.bbcode-editor .bb-toolbar { position: relative; }

.bbcode-editor .bb-tools.bb-disabled {
    opacity: .35;
    pointer-events: none;
}

/* ── Write / Preview tabs ────────────────────────────────────────────── */
.bbcode-editor .bb-tabs {
    display: flex;
    gap: 2px;
    margin-left: auto;
    padding: 2px;
    background: #111827;               /* gray-900 */
    border: 1px solid #374151;         /* gray-700 */
    border-radius: 6px;
}
.bbcode-editor .bb-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    font-size: 12px;
    line-height: 1.4;
    color: #9ca3af;                    /* gray-400 */
    background: transparent;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.bbcode-editor .bb-tab:hover { color: #fff; }
.bbcode-editor .bb-tab.is-active {
    color: #fff;
    background: #065f46;               /* emerald-800 */
}

/* ── Preview pane ────────────────────────────────────────────────────── */
.bbcode-editor .bb-preview {
    padding: 12px 16px;
    font-size: 14px;
    background: rgba(17, 24, 39, .8);  /* gray-900/80 */
    border: 1px solid #374151;
    border-top: 0;
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
    word-wrap: break-word;
}
.bbcode-editor .bb-preview.hidden { display: none; }
.bbcode-editor .bb-preview-muted { color: #6b7280; font-style: italic; margin: 0; }
.bbcode-editor .bb-preview-error { color: #f87171; margin: 0; }

/* ── Emoji picker panel ──────────────────────────────────────────────── */
.bbcode-editor .bb-emoji-panel {
    border: 1px solid #374151;
    border-top: 0;
    background: #030712;               /* gray-950 */
}
.bbcode-editor .bb-emoji-panel.hidden { display: none; }
.bbcode-editor .bb-emoji-panel emoji-picker {
    width: 100%;
    height: 320px;
    --background: #030712;
    --border-color: #1f2937;
    --input-border-color: #374151;
    --input-font-color: #e5e7eb;
    --button-hover-background: #1f2937;
    --button-active-background: #374151;
    --indicator-color: #10b981;
    --outline-color: #10b981;
}

/* ── Dialog (link / image / YouTube) ─────────────────────────────────── */
.bb-dialog {
    width: min(420px, calc(100vw - 32px));
    padding: 0;
    color: #e5e7eb;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .6);
}
.bb-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.bb-dialog-form { padding: 18px; margin: 0; }
.bb-dialog-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 14px;
}
.bb-dialog-label { display: block; margin-bottom: 12px; }
.bb-dialog-label span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #9ca3af;
    margin-bottom: 6px;
}
.bb-dialog-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-size: 14px;
    color: #e5e7eb;
    background: #030712;
    border: 1px solid #374151;
    border-radius: 8px;
    outline: none;
}
.bb-dialog-input:focus {
    border-color: #059669;
    box-shadow: 0 0 0 1px rgba(5, 150, 105, .4);
}
.bb-dialog-error {
    font-size: 12px;
    color: #f87171;
    margin: -4px 0 10px;
}
.bb-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}
.bb-dialog-actions button {
    padding: 7px 16px;
    font-size: 13px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}
.bb-dialog-cancel { color: #d1d5db; background: #374151; }
.bb-dialog-cancel:hover { background: #4b5563; }
.bb-dialog-ok { color: #fff; background: #059669; font-weight: 600; }
.bb-dialog-ok:hover { background: #047857; }

/* ── Rendered posts: spoiler (click to reveal, works on mobile) ─────── */
.crna-spoiler {
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    color: transparent;
    background: #374151;
    transition: color .15s, background .15s;
    -webkit-user-select: none;
    user-select: none;
}
.crna-spoiler * { color: transparent !important; }
.crna-spoiler img, .crna-spoiler iframe { visibility: hidden; }
.crna-spoiler.is-open {
    color: inherit;
    background: rgba(55, 65, 81, .45);
    cursor: auto;
    -webkit-user-select: text;
    user-select: text;
}
.crna-spoiler.is-open * { color: inherit !important; }
.crna-spoiler.is-open img, .crna-spoiler.is-open iframe { visibility: visible; }
.crna-spoiler:focus-visible { outline: 2px solid #10b981; outline-offset: 1px; }

/* ── Rendered posts: [collapse] / [spoiler=Title] ───────────────────── */
.crna-collapse {
    border: 1px solid #1f2937;
    border-radius: 8px;
    background: rgba(3, 7, 18, .5);
}
.crna-collapse > summary {
    padding: 6px 12px;
    font-size: 13px;
    color: #d1d5db;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.crna-collapse > summary::-webkit-details-marker { display: none; }
.crna-collapse > summary::before {
    content: '\25B8';
    display: inline-block;
    margin-right: 8px;
    color: #10b981;
    transition: transform .15s;
}
.crna-collapse[open] > summary::before { transform: rotate(90deg); }
.crna-collapse > summary:hover { color: #fff; }
.crna-collapse-body {
    padding: 10px 12px;
    border-top: 1px solid #1f2937;
}

/* ── Light theme (html without .dark) ───────────────────────────────── */
html:not(.dark) .crna-spoiler { background: #d1d5db; }
html:not(.dark) .crna-spoiler.is-open { background: #e5e7eb; }
html:not(.dark) .crna-collapse { background: #f9fafb; border-color: #e5e7eb; }
html:not(.dark) .crna-collapse > summary { color: #374151; }
html:not(.dark) .crna-collapse-body { border-color: #e5e7eb; }
