/**
 * Fluger lightweight HTML editor (contenteditable toolbar)
 */
.htmeditor-root {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    /* visible so native <select> dropdown is not clipped */
    overflow: visible;
    margin-top: 4px;
}

.htmeditor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.htmeditor-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
}

.htmeditor-toolbar-sep {
    width: 1px;
    height: 22px;
    background: #cbd5e1;
    margin: 0 4px;
    flex-shrink: 0;
}

.htmeditor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #334155;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
}

.htmeditor-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.htmeditor-btn.htmeditor-btn-active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.htmeditor-select {
    height: 32px;
    padding: 0 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    font-size: 0.75rem;
    color: #334155;
    min-width: 8.5rem;
    max-width: 11rem;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.htmeditor-btn-icon {
    padding: 0 6px;
    min-width: 32px;
    color: #334155;
}

.htmeditor-btn-icon svg {
    display: block;
    pointer-events: none;
}

.htmeditor-btn-html {
    min-width: 3.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.02em;
}

.htmeditor-color-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
}

.htmeditor-color-wrap input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
}

.htmeditor-body {
    position: relative;
    min-height: 260px;
    overflow: hidden;
    border-radius: 0 0 8px 8px;
}

.htmeditor-wysiwyg {
    min-height: 260px;
    max-height: 420px;
    overflow-y: auto;
    padding: 12px 14px;
    outline: none;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #1e293b;
}

.htmeditor-wysiwyg:focus {
    box-shadow: inset 0 0 0 1px #3b82f6;
}

.htmeditor-code {
    display: none;
    width: 100%;
    min-height: 260px;
    max-height: 420px;
    padding: 12px 14px;
    border: 0;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8125rem;
    line-height: 1.45;
    resize: vertical;
    box-sizing: border-box;
    background: #0f172a;
    color: #e2e8f0;
}

.htmeditor-root.htmeditor-code-mode .htmeditor-wysiwyg {
    display: none;
}

.htmeditor-root.htmeditor-code-mode .htmeditor-code {
    display: block;
}

.htmeditor-root.htmeditor-code-mode .htmeditor-toolbar .htmeditor-btn:not([data-code-toggle]),
.htmeditor-root.htmeditor-code-mode .htmeditor-toolbar .htmeditor-select,
.htmeditor-root.htmeditor-code-mode .htmeditor-toolbar .htmeditor-color-wrap,
.htmeditor-root.htmeditor-code-mode .htmeditor-toolbar-sep {
    opacity: 0.45;
    pointer-events: none;
}

.htmeditor-root.htmeditor-code-mode .htmeditor-toolbar [data-code-toggle] {
    opacity: 1;
    pointer-events: auto;
}

/* Link modal (z above Bootstrap .modal 1055 and common admin dropdowns; below browser ext UI) */
.htmeditor-link-modal {
    position: fixed;
    inset: 0;
    z-index: 10600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    pointer-events: auto;
}

.htmeditor-link-modal-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(15, 23, 42, 0.55);
}

.htmeditor-link-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    padding: 20px;
    z-index: 1;
    pointer-events: auto;
}

.htmeditor-link-dialog h3 {
    margin: 0 0 16px;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}

.htmeditor-link-field {
    margin-bottom: 12px;
}

.htmeditor-link-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
}

.htmeditor-link-field input,
.htmeditor-link-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.htmeditor-link-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

.htmeditor-link-actions button {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #334155;
}

.htmeditor-link-actions button.htmeditor-link-primary {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.htmeditor-link-hidden {
    display: none !important;
}

/* Image insert dialog (reuses link modal shell) */
.htmeditor-img-dialog {
    max-width: min(520px, 96vw);
}

.htmeditor-img-source-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-bottom: 14px;
}

.htmeditor-img-source-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.htmeditor-img-source-label input {
    margin: 0;
}

.htmeditor-img-panel {
    min-height: 1.5rem;
}
