/**
 * Editor Extras — Bootstrap Icons Toolbar + UI Enhancements
 * Replaces famfamfam.png sprite icons with Bootstrap Icons.
 * Requires Bootstrap Icons CSS to be loaded in the page.
 */

/* ==========================================================================
   BOOTSTRAP ICONS TOOLBAR REPLACEMENT
   ========================================================================== */

/* Hide the sprite background on all toolbar buttons */
.ee-bi-icons .sceditor-button div {
    background-image: none !important;
    background-position: unset !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 0 !important;       /* hide any text inside the div */
    overflow: hidden;
    color: #555;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* All icons render via ::before only */
.ee-bi-icons .sceditor-button div::before {
    font-family: 'bootstrap-icons' !important;
    font-size: 15px;
    line-height: 18px;
    display: block;
    text-align: center;
    color: inherit;
}

.ee-bi-icons .sceditor-button {
    width: 18px;
    height: 22px;
    padding: 4px 5px;
}

:root.ee-bi-icons[data-bs-theme="dark"] .sceditor-button div {
    color: #aaa;
}

:root.ee-bi-icons .sceditor-button:hover div {
    color: var(--ms-accent, #0d9488);
}

/* --- Icon Mappings (Bootstrap Icons unicode codepoints) --- */
.ee-bi-icons .sceditor-button-bold div::before         { content: "\f5f0"; }
.ee-bi-icons .sceditor-button-italic div::before        { content: "\f5f4"; }
.ee-bi-icons .sceditor-button-underline div::before     { content: "\f5f6"; }
.ee-bi-icons .sceditor-button-strike div::before        { content: "\f5f5"; }
.ee-bi-icons .sceditor-button-subscript div::before     { content: "\f5f7"; }
.ee-bi-icons .sceditor-button-superscript div::before   { content: "\f5f7"; }
.ee-bi-icons .sceditor-button-left div::before          { content: "\f5c7"; }
.ee-bi-icons .sceditor-button-center div::before        { content: "\f5c4"; }
.ee-bi-icons .sceditor-button-right div::before         { content: "\f5c9"; }
.ee-bi-icons .sceditor-button-justify div::before       { content: "\f44b"; }
.ee-bi-icons .sceditor-button-font div::before          { content: "\f3da"; }
.ee-bi-icons .sceditor-button-size div::before          { content: "\f5f7"; } /* type */
.ee-bi-icons .sceditor-button-color div::before         { content: "\f4b1"; } /* palette */
.ee-bi-icons .sceditor-button-removeformat div::before  { content: "\f331"; } /* eraser */
.ee-bi-icons .sceditor-button-bulletlist div::before    { content: "\f478"; }
.ee-bi-icons .sceditor-button-orderedlist div::before   { content: "\f475"; }
.ee-bi-icons .sceditor-button-indent div::before        { content: "\f5c5"; }
.ee-bi-icons .sceditor-button-outdent div::before       { content: "\f5c6"; }
.ee-bi-icons .sceditor-button-table div::before         { content: "\f5aa"; }
.ee-bi-icons .sceditor-button-code div::before          { content: "\f2c6"; } /* code-slash */
.ee-bi-icons .sceditor-button-quote div::before         { content: "\f255"; } /* chat-quote */
.ee-bi-icons .sceditor-button-horizontalrule div::before{ content: "\f63b"; } /* dash-lg */
.ee-bi-icons .sceditor-button-image div::before         { content: "\f42a"; }
.ee-bi-icons .sceditor-button-email div::before         { content: "\f32f"; } /* envelope */
.ee-bi-icons .sceditor-button-link div::before          { content: "\f470"; } /* link-45deg */
.ee-bi-icons .sceditor-button-link.ee-has-link div::before { color: #dc3545; }

/* Hide unlink button — link button handles both states */
/* Hide php button — code button with syntax highlighting covers all languages */
.ee-bi-icons .sceditor-button-unlink,
.ee-bi-icons .sceditor-button-php { display: none !important; }
.ee-bi-icons .sceditor-button-video div::before         { content: "\f21f"; } /* camera-video */
.ee-bi-icons .sceditor-button-youtube div::before       { content: "\f62b"; }
.ee-bi-icons .sceditor-button-emoticon div::before      { content: "\f327"; } /* emoji-smile */
.ee-bi-icons .sceditor-button-maximize div::before      { content: "\f14d"; } /* arrows-fullscreen */
.ee-bi-icons .sceditor-button-source div::before        { content: "\f1c9"; } /* braces { } */
.ee-bi-icons .sceditor-button-date div::before          { content: "\f1f6"; } /* calendar */
.ee-bi-icons .sceditor-button-time div::before          { content: "\f293"; } /* clock */
.ee-bi-icons .sceditor-button-print div::before         { content: "\f501"; }
.ee-bi-icons .sceditor-button-cut div::before           { content: "\f528"; } /* scissors */
.ee-bi-icons .sceditor-button-copy div::before          { content: "\f290"; } /* clipboard */
.ee-bi-icons .sceditor-button-paste div::before         { content: "\f290"; }
.ee-bi-icons .sceditor-button-pastetext div::before     { content: "\f290"; }
.ee-bi-icons .sceditor-button-ltr div::before           { content: "\f5c7"; }
.ee-bi-icons .sceditor-button-rtl div::before           { content: "\f5c9"; }
.ee-bi-icons .sceditor-button-format div::before        { content: "\f5c8"; } /* text-paragraph */

/* Custom buttons added by Editor Extras */
.ee-bi-icons .sceditor-button-emoji div::before         { content: "\f327"; } /* emoji-smile */
.ee-bi-icons .sceditor-button-gif div::before           { content: "GIF"; font-family: Arial, sans-serif !important; font-size: 9px; font-weight: 900; letter-spacing: -0.5px; } /* text-based GIF label */
.ee-bi-icons .sceditor-button-spoiler div::before       { content: "\f340"; } /* eye-slash */
.ee-bi-icons .sceditor-button-biicon div::before        { content: "\f53a"; font-size: 13px; } /* stars */

/* Subscript / Superscript distinct icons */
.ee-bi-icons .sceditor-button-subscript div::before     { content: "₂"; font-family: inherit !important; font-weight: 700; }
.ee-bi-icons .sceditor-button-superscript div::before   { content: "²"; font-family: inherit !important; font-weight: 700; }

/* Grip handle */
.ee-bi-icons div.sceditor-grip {
    background-image: none !important;
}
.ee-bi-icons div.sceditor-grip::before {
    content: "\f3fd";
    font-family: 'bootstrap-icons' !important;
    font-size: 10px;
    color: #aaa;
}

/* ==========================================================================
   EDITOR CONTAINER GLASS MORPHISM THEME
   ========================================================================== */

.ee-themed .sceditor-container {
    border: 1px solid var(--ms-glass-border, rgba(255,255,255,0.18));
    background: var(--ms-glass-bg, rgba(255,255,255,0.08));
    backdrop-filter: blur(8px) saturate(1.2);
    -webkit-backdrop-filter: blur(8px) saturate(1.2);
    border-radius: .5rem;
}

/* Keep the actual editing area opaque and readable */
.ee-themed .sceditor-container iframe,
.ee-themed .sceditor-container textarea {
    background: var(--ms-editor-bg, var(--bs-body-bg, #fff)) !important;
    color: var(--ms-editor-text, var(--bs-body-color, #212529)) !important;
}

.ee-themed div.sceditor-toolbar {
    background: var(--ms-glass-bg-heavy, rgba(255,255,255,0.12));
    border-bottom: 1px solid var(--ms-glass-border, rgba(255,255,255,0.18));
    border-radius: .5rem .5rem 0 0;
    padding: 4px 6px 3px;
}

.ee-themed div.sceditor-group {
    background: transparent;
    border-bottom: none;
    margin: 1px 3px 1px 0;
}

.ee-themed .sceditor-button:hover {
    background: var(--ms-accent-subtle, rgba(13,148,136,0.1));
    border-radius: 4px;
}

/* ==========================================================================
   EMOJI PICKER
   ========================================================================== */

.ee-emoji-picker {
    position: absolute;
    z-index: 5000;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--ms-glass-border, #ddd);
    border-radius: .5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    width: 320px;
    max-height: 360px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ee-emoji-picker-search {
    border: none;
    border-bottom: 1px solid var(--ms-glass-border, #ddd);
    padding: 8px 12px;
    width: 100%;
    font-size: 14px;
    outline: none;
    background: transparent;
    color: var(--bs-body-color, #333);
}

.ee-emoji-picker-categories {
    display: flex;
    border-bottom: 1px solid var(--ms-glass-border, #ddd);
    padding: 4px 6px;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.ee-emoji-picker-categories button {
    background: none;
    border: none;
    font-size: 18px;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 4px;
    line-height: 1;
}

.ee-emoji-picker-categories button:hover,
.ee-emoji-picker-categories button.active {
    background: var(--ms-glass-bg-heavy, #eee);
}

.ee-emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    max-height: 260px;
}

.ee-emoji-picker-grid span {
    font-size: 22px;
    text-align: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1.2;
}

.ee-emoji-picker-grid span:hover {
    background: var(--ms-glass-bg-heavy, #eee);
}

/* ==========================================================================
   GIF PICKER
   ========================================================================== */

.ee-gif-picker {
    position: absolute;
    z-index: 5000;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--ms-glass-border, #ddd);
    border-radius: .5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    width: 380px;
    max-height: 420px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ee-gif-picker-search {
    border: none;
    border-bottom: 1px solid var(--ms-glass-border, #ddd);
    padding: 8px 12px;
    width: 100%;
    font-size: 14px;
    outline: none;
    background: transparent;
    color: var(--bs-body-color, #333);
}

.ee-gif-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    max-height: 360px;
}

.ee-gif-picker-grid img {
    width: 100%;
    border-radius: 4px;
    cursor: pointer;
    display: block;
}

.ee-gif-picker-grid img:hover {
    opacity: 0.8;
}

.ee-gif-picker .ee-gif-loading {
    text-align: center;
    padding: 20px;
    color: #888;
}

.ee-gif-picker .ee-gif-attribution {
    text-align: center;
    padding: 4px;
    font-size: 11px;
    color: #999;
    border-top: 1px solid var(--ms-glass-border, #ddd);
}

/* ==========================================================================
   @MENTION AUTOCOMPLETE
   ========================================================================== */

.ee-mention-dropdown {
    position: absolute;
    z-index: 5000;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--ms-glass-border, #ddd);
    border-radius: .375rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    min-width: 180px;
    max-height: 200px;
    overflow-y: auto;
}

.ee-mention-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--bs-body-color, #333);
}

.ee-mention-item:hover,
.ee-mention-item.active {
    background: var(--ms-glass-bg-heavy, #eee);
    color: var(--ms-accent, #0d9488);
}

/* ==========================================================================
   IMAGE UPLOAD OVERLAY
   ========================================================================== */

.ee-upload-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--ms-accent-subtle, rgba(13,148,136,0.15));
    border: 3px dashed var(--ms-accent, #0d9488);
    border-radius: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.ee-upload-overlay span {
    background: var(--ms-accent, #0d9488);
    color: var(--ms-text-inv, #fff);
    padding: 8px 20px;
    border-radius: .375rem;
    font-size: 14px;
    font-weight: 600;
}

/* ==========================================================================
   IMAGE RESIZE — attachment row (hidden record for form association)
   ========================================================================== */

.ee-attachment-row { display: none; }

/* ==========================================================================
   CODE BLOCK ENHANCEMENTS — Line Numbers + Copy Button
   ========================================================================== */

/* Title bar: flex layout for label + copy button */
.codeblock .title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Copy button */
.ee-code-copy {
    background: none;
    border: 1px solid var(--ms-glass-border, rgba(255,255,255,0.18));
    border-radius: .25rem;
    color: var(--bs-body-color, #666);
    cursor: pointer;
    padding: 2px 8px;
    font-size: 13px;
    line-height: 1.4;
    transition: color .15s, background .15s, border-color .15s;
    display: inline-flex;
    align-items: center;
    margin-left: auto;
}

.ee-code-copy:hover {
    color: var(--ms-accent, #0d9488);
    background: var(--ms-glass-bg, rgba(255,255,255,0.08));
    border-color: var(--ms-accent, #0d9488);
}

/* Line numbers — table-based layout */
.ee-code-table {
    width: 100%;
    border-collapse: collapse;
    line-height: 1.5;
}

.ee-code-table td {
    padding: 0;
    /* Baseline, not top: the numbers are a smaller font, so top-aligned they sat a few px high */
    vertical-align: baseline;
    border: none;
    background: none;
}

td.ee-line-num {
    width: 3em;
    min-width: 3em;
    max-width: 3em;
    text-align: right;
    padding-right: .75em !important;
    color: #8b949e;
    border-right: 1px solid #d1d9e0;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
    white-space: nowrap;
    font-size: .8em;
}

td.ee-line-code {
    padding-left: .75em !important;
    white-space: pre-wrap;
    word-break: break-all;
}

[data-bs-theme="dark"] td.ee-line-num {
    color: #6e7681;
    border-right-color: #30363d;
}

/* ==========================================================================
   TABLE BBCODE RENDERING
   ========================================================================== */
.mycode_table_wrapper {
    overflow-x: auto;
    margin: .75em 0;
}

/* Width, alignment and the border vars come from the [table] tag (inline style, server-whitelisted);
   --ee-tb-c falls back to the palette's border colour */
.mycode_table {
    --ee-tb-c-def: var(--ms-border, #dee2e6);
    border-collapse: collapse;
    width: 100%;
    min-width: 200px;
}

/* Specific on purpose: posts sit inside .tborder, and MyBB's css3.css (.tborder tbody tr:last-child > td)
   and theme section rules strip the last row's bottom border; the table's own border must win */
.mycode_table_wrapper .mycode_table.mycode_table tr > th,
.mycode_table_wrapper .mycode_table.mycode_table tr > td,
.mycode_table th,
.mycode_table td {
    border: var(--ee-tb-w, 1px) var(--ee-tb-s, solid) var(--ee-tb-c, var(--ee-tb-c-def));
    padding: 6px 12px;
    text-align: left;
    vertical-align: top;
}

.mycode_table th {
    background: var(--ms-heading-bg, #f1f3f5);
    font-weight: 600;
    color: var(--ms-text-inv, #333);
}

/* [table striped=1]: every second body row (the header row is in <thead>) */
.mycode_table.ee-striped tbody tr:nth-child(even) td {
    background: var(--ms-glass-bg, rgba(0,0,0,.02));
}

/* [table numbers=1]: the numbered first column */
.mycode_table .ee-num {
    width: 1%;
    white-space: nowrap;
    text-align: right;
    color: var(--ms-muted, #6c757d);
    font-variant-numeric: tabular-nums;
}

[data-bs-theme="dark"] .mycode_table {
    --ee-tb-c-def: #30363d;
}
[data-bs-theme="dark"] .mycode_table th {
    background: rgba(255,255,255,.06);
    color: #e6edf3;
}
[data-bs-theme="dark"] .mycode_table.ee-striped tbody tr:nth-child(even) td {
    background: rgba(255,255,255,.02);
}

/* [icode] inline code */
code.ee-icode {
    font-family: SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: .875em;
    padding: .1em .4em;
    border-radius: 4px;
    background: color-mix(in srgb, currentColor 10%, transparent);
    color: inherit;
    white-space: break-spaces;
    word-break: break-word;
}

/* Font colour dropdown: SCEditor's swatches have white borders, and the custom colour row */
[data-bs-theme="dark"] .sceditor-color-option { border-color: transparent; }
.sceditor-color-picker .ee-color-custom {
    clear: both;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-top: 6px;
    margin-top: 4px;
    border-top: 1px solid var(--ms-border, #dee2e6);
}
.ee-color-custom input[type="color"] {
    width: 28px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--ms-border, #ced4da);
    border-radius: 4px;
    background: none;
    cursor: pointer;
}
.ee-color-custom input[type="text"] {
    width: 74px;
    font: 12px/1.4 SFMono-Regular, Menlo, Consolas, monospace;
    padding: 2px 4px;
    border: 1px solid var(--ms-border, #ced4da);
    border-radius: 4px;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #333);
}
.ee-color-custom button {
    font-size: 12px;
    padding: 2px 8px;
    border: 0;
    border-radius: 4px;
    background: var(--ms-accent, #0d9488);
    color: #fff;
    cursor: pointer;
}
.ee-color-custom input.ee-bad { border-color: #dc3545; }

/* Inline code button */
.ee-bi-icons .sceditor-button-icode div::before { content: "\f2c8"; } /* code */
html:not(.ee-bi-icons) .sceditor-button-icode div { background: none; text-align: center; }
html:not(.ee-bi-icons) .sceditor-button-icode div::before { content: "</>"; font: 700 8px/16px monospace; }

/* Language label in a code block's title ([code=lang]) */
.codeblock .ee-code-lang {
    font-weight: 500;
    font-size: .8em;
    padding: 1px 8px;
    margin-left: 6px;
    border-radius: 999px;
    border: 1px solid var(--ms-border, #dee2e6);
    opacity: .85;
}

/* ==========================================================================
   TABLE PICKER (INSERT TABLE DROPDOWN)
   ========================================================================== */
.ee-table-picker {
    position: absolute;
    z-index: 5000;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--ms-glass-border, #ddd);
    border-radius: .5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    padding: 8px;
    min-width: 200px;
}

.ee-table-picker-label {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--bs-body-color, #333);
}

.ee-table-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 22px);
    grid-template-rows: repeat(8, 22px);
    gap: 2px;
    justify-content: center;
}

.ee-table-picker-cell {
    width: 22px;
    height: 22px;
    border: 1px solid var(--ms-border, #ced4da);
    border-radius: 2px;
    cursor: pointer;
    transition: background .1s, border-color .1s;
}

.ee-table-picker-cell.highlight {
    background: var(--ms-accent, #0d9488);
    border-color: var(--ms-accent, #0d9488);
    opacity: .7;
}

.ee-table-picker-cell:hover {
    border-color: var(--ms-accent, #0d9488);
}

/* ==========================================================================
   ICON PICKER (INSERT BOOTSTRAP ICON DROPDOWN)
   ========================================================================== */
.ee-icon-picker {
    position: absolute;
    z-index: 5000;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--ms-glass-border, #ddd);
    border-radius: .5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    width: 320px;
    max-height: 360px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ee-icon-picker-search {
    border: none;
    border-bottom: 1px solid var(--ms-glass-border, #ddd);
    padding: 8px 12px;
    width: 100%;
    font-size: 14px;
    outline: none;
    background: transparent;
    color: var(--bs-body-color, #333);
}

.ee-icon-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 8px;
    overflow-y: auto;
    max-height: 280px;
}

.ee-icon-picker-item {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--bs-body-color, #333);
    transition: background .15s, border-color .15s, color .15s;
    padding: 0;
}

.ee-icon-picker-item:hover {
    background: var(--ms-glass-bg, rgba(0,0,0,.04));
    border-color: var(--ms-accent, #0d9488);
    color: var(--ms-accent, #0d9488);
}

.ee-icon-picker-empty {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
    width: 100%;
}

/* ==========================================================================
   TABLE OPTIONS (insert picker + Table Properties)
   ========================================================================== */
.ee-tbl-opts {
    font-size: 13px;
    color: var(--bs-body-color, #333);
    width: 210px;
}

/* Insert picker: grid left, options right; stacked on phones */
.ee-table-picker.ee-has-opts {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.ee-has-opts .ee-tbl-opts {
    border-left: 1px solid var(--ms-border, #dee2e6);
    padding-left: 12px;
}

.ee-tbl-props .ee-tbl-opts { margin-top: 4px; }

.ee-tbl-row,
.ee-tbl-check { text-transform: none; }

@media (max-width: 575px) {
    .ee-table-picker.ee-has-opts { flex-direction: column; }
    .ee-has-opts .ee-tbl-opts { border-left: 0; padding-left: 0; border-top: 1px solid var(--ms-border, #dee2e6); padding-top: 8px; }
}

.ee-tbl-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 6px;
}

.ee-tbl-row > span:first-child {
    flex: 0 0 64px;
    color: var(--ms-muted, #6c757d);
}

.ee-tbl-row select,
.ee-tbl-row input[type="number"] {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    padding: 2px 4px;
    border: 1px solid var(--ms-border, #ced4da);
    border-radius: 4px;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #333);
}

.ee-tbl-row input[type="color"] {
    width: 32px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--ms-border, #ced4da);
    border-radius: 4px;
    background: none;
}

.ee-tbl-row input[type="color"]:disabled { opacity: .4; }

.ee-tbl-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.ee-tbl-preview {
    border-collapse: collapse;
    margin: 4px auto 0;
    font-size: 11px;
}

.ee-tbl-preview th,
.ee-tbl-preview td {
    border: var(--ee-tb-w, 1px) var(--ee-tb-s, solid) var(--ee-tb-c, var(--ms-border, #ced4da));
    padding: 2px 14px;
}

.ee-tbl-preview.ee-tbl-none th,
.ee-tbl-preview.ee-tbl-none td { outline: 1px dashed rgba(127,127,127,.35); outline-offset: -1px; }

.ee-tbl-preview.ee-striped tr:nth-child(odd) td { background: color-mix(in srgb, currentColor 8%, transparent); }
.ee-tbl-preview .ee-num { display: none; color: var(--ms-muted, #6c757d); }
.ee-tbl-preview.ee-nohead th { font-weight: normal; }
.ee-tbl-preview.ee-numbered .ee-num { display: table-cell; }

.ee-tbl-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
}

/* ==========================================================================
   CODE DIALOG (CodeMirror)
   ========================================================================== */
.ee-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 6000;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.ee-modal {
    width: min(860px, 100%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--ms-surface, var(--bs-body-bg, #fff));
    color: var(--bs-body-color, #333);
    border: 1px solid var(--ms-border, #dee2e6);
    border-radius: .75rem;
    box-shadow: 0 16px 48px rgba(0,0,0,.35);
    overflow: hidden;
}

.ee-modal-head,
.ee-modal-bar,
.ee-modal-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
}

.ee-modal-head { border-bottom: 1px solid var(--ms-border, #dee2e6); font-size: 15px; }
.ee-modal-head strong { flex: 1; }
.ee-modal-bar { font-size: 13px; flex-wrap: wrap; }
.ee-modal-foot { border-top: 1px solid var(--ms-border, #dee2e6); justify-content: flex-end; flex-wrap: wrap; }
.ee-modal-foot .ee-modal-hint { margin-right: auto; }

.ee-modal-hint {
    font-size: 12px;
    color: var(--ms-muted, #6c757d);
}

.ee-modal-close {
    border: 0;
    background: none;
    color: inherit;
    font-size: 22px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    opacity: .7;
}

.ee-modal-close:hover { opacity: 1; }

.ee-code-lang-select {
    margin-left: 6px;
    font-size: 13px;
    padding: 3px 6px;
    border: 1px solid var(--ms-border, #ced4da);
    border-radius: 4px;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #333);
}

.ee-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 14px;
}

.ee-code-input,
.ee-modal .CodeMirror {
    width: 100%;
    height: min(55vh, 520px);
    font: 13px/1.5 Monaco, Consolas, 'Courier New', monospace;
    border: 1px solid var(--ms-border, #d1d9e0);
    border-radius: .375rem;
    box-sizing: border-box;
}

.ee-code-input { padding: 8px; resize: vertical; background: #f6f8fa; color: #1f2328; }

/* CodeMirror colours: GitHub-like, light and dark */
.ee-modal .CodeMirror { background: #f6f8fa; color: #1f2328; }
.ee-modal .CodeMirror-gutters { background: #f6f8fa; border-right: 1px solid #d1d9e0; }
.ee-modal .CodeMirror-linenumber { color: #8c959f; }
.ee-modal .CodeMirror-cursor { border-left-color: #1f2328; }
.ee-modal .CodeMirror-selected { background: #d0e4ff; }
.ee-modal .CodeMirror-focused .CodeMirror-selected { background: #b6d6fd; }
.ee-modal .CodeMirror-matchingbracket { color: inherit !important; background: rgba(46,160,67,.25); }
.ee-modal .cm-keyword, .ee-modal .cm-tag { color: #cf222e; }
.ee-modal .cm-def, .ee-modal .cm-variable-2 { color: #8250df; }
.ee-modal .cm-variable, .ee-modal .cm-property { color: #0550ae; }
.ee-modal .cm-attribute, .ee-modal .cm-qualifier { color: #116329; }
.ee-modal .cm-string, .ee-modal .cm-string-2 { color: #0a3069; }
.ee-modal .cm-number, .ee-modal .cm-atom, .ee-modal .cm-builtin { color: #0550ae; }
.ee-modal .cm-comment, .ee-modal .cm-meta { color: #6e7781; }
.ee-modal .cm-bracket, .ee-modal .cm-operator { color: inherit; }

[data-bs-theme="dark"] .ee-code-input,
[data-bs-theme="dark"] .ee-modal .CodeMirror,
[data-bs-theme="dark"] .ee-modal .CodeMirror-gutters { background: #161b22; color: #e6edf3; border-color: #30363d; }
[data-bs-theme="dark"] .ee-modal .CodeMirror-linenumber { color: #6e7681; }
[data-bs-theme="dark"] .ee-modal .CodeMirror-cursor { border-left-color: #e6edf3; }
[data-bs-theme="dark"] .ee-modal .CodeMirror-selected { background: #264f78; }
[data-bs-theme="dark"] .ee-modal .CodeMirror-focused .CodeMirror-selected { background: #2f5f8f; }
[data-bs-theme="dark"] .ee-modal .cm-keyword, [data-bs-theme="dark"] .ee-modal .cm-tag { color: #ff7b72; }
[data-bs-theme="dark"] .ee-modal .cm-def, [data-bs-theme="dark"] .ee-modal .cm-variable-2 { color: #d2a8ff; }
[data-bs-theme="dark"] .ee-modal .cm-variable, [data-bs-theme="dark"] .ee-modal .cm-property { color: #79c0ff; }
[data-bs-theme="dark"] .ee-modal .cm-attribute, [data-bs-theme="dark"] .ee-modal .cm-qualifier { color: #7ee787; }
[data-bs-theme="dark"] .ee-modal .cm-string, [data-bs-theme="dark"] .ee-modal .cm-string-2 { color: #a5d6ff; }
[data-bs-theme="dark"] .ee-modal .cm-number, [data-bs-theme="dark"] .ee-modal .cm-atom, [data-bs-theme="dark"] .ee-modal .cm-builtin { color: #79c0ff; }
[data-bs-theme="dark"] .ee-modal .cm-comment, [data-bs-theme="dark"] .ee-modal .cm-meta { color: #8b949e; }

@media (max-width: 575px) {
    .ee-modal-backdrop { padding: 0; }
    .ee-modal { border-radius: 0; max-height: 100vh; height: 100%; }
    .ee-code-input, .ee-modal .CodeMirror { height: calc(100vh - 190px); }
}
