/* WYSIWYG editor (phineas) */

.wysiwyg-wrapper {
    display: flex;
    flex-direction: column;
}

.wysiwyg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem;
    padding: 0.3rem;
    border: 1px solid #212529;
    border-bottom: none;
    border-top-left-radius: 0.4rem;
    border-top-right-radius: 0.4rem;
    background-color: #212529;
}

.wysiwyg-toolbar .wysiwyg-btn,
.wysiwyg-bubble .wysiwyg-btn {
    background: transparent;
    border: none;
    color: #f8f9fa;
    padding: 0.35rem 0.55rem;
    border-radius: 0.3rem;
    cursor: pointer;
    line-height: 1;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wysiwyg-toolbar .wysiwyg-btn .bi,
.wysiwyg-bubble .wysiwyg-btn .bi {
    font-size: 1.05rem;
}

.wysiwyg-toolbar .wysiwyg-btn:hover,
.wysiwyg-bubble .wysiwyg-btn:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.wysiwyg-style-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.wysiwyg-style-wrap .wysiwyg-caret {
    font-size: 0.7em;
    margin-left: 0.15rem;
    opacity: 0.75;
}

.wysiwyg-style-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 170px;
    background-color: #2d3338;
    border: 1px solid #495057;
    border-radius: 0.3rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    z-index: 1082;
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
}

.wysiwyg-style-menu[hidden] {
    display: none;
}

.wysiwyg-style-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: #f8f9fa;
    padding: 0.4rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.2;
}

.wysiwyg-style-item:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.wysiwyg-style-item.active {
    background-color: var(--bs-primary, #0d6efd);
    color: #fff;
}

/* Preview the style of each option in its menu label */
.wysiwyg-style-item-h1 { font-size: 1.4rem; font-weight: 700; }
.wysiwyg-style-item-h2 { font-size: 1.25rem; font-weight: 700; }
.wysiwyg-style-item-h3 { font-size: 1.1rem; font-weight: 700; }
.wysiwyg-style-item-h4 { font-size: 1rem; font-weight: 700; }
.wysiwyg-style-item-h5 { font-size: 0.95rem; font-weight: 700; }
.wysiwyg-style-item-h6 { font-size: 0.9rem; font-weight: 700; }
.wysiwyg-style-item-quote { font-style: italic; padding-left: 1rem; border-left: 3px solid #6c757d; margin-left: 0.25rem; }

/* Header rendering inside the editor */
.wysiwyg-editor h1,
.wysiwyg-editor h2,
.wysiwyg-editor h3,
.wysiwyg-editor h4,
.wysiwyg-editor h5,
.wysiwyg-editor h6 {
    font-weight: 700;
    margin: 0 0 0.5em 0;
    line-height: 1.25;
}
.wysiwyg-editor h1 { font-size: 1.8em; }
.wysiwyg-editor h2 { font-size: 1.5em; }
.wysiwyg-editor h3 { font-size: 1.25em; }
.wysiwyg-editor h4 { font-size: 1.1em; }
.wysiwyg-editor h5 { font-size: 1em; }
.wysiwyg-editor h6 { font-size: 0.9em; color: var(--bs-secondary-color, #6c757d); }

.wysiwyg-toolbar-sep {
    display: inline-block;
    width: 1px;
    align-self: stretch;
    margin: 0.15rem 0.25rem;
    background-color: rgba(255, 255, 255, 0.18);
}

.wysiwyg-toolbar .wysiwyg-btn.active,
.wysiwyg-toolbar .wysiwyg-btn.active:hover,
.wysiwyg-toolbar .wysiwyg-btn.active:focus,
.wysiwyg-bubble .wysiwyg-btn.active,
.wysiwyg-bubble .wysiwyg-btn.active:hover,
.wysiwyg-bubble .wysiwyg-btn.active:focus {
    background-color: var(--bs-primary, #0d6efd);
    color: #fff;
}

.wysiwyg-editor {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    min-height: 6em;
    outline: none;
    overflow-y: auto;
    cursor: text;
    background-color: var(--bs-body-bg, #fff);
}

.wysiwyg-editor:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.wysiwyg-editor p {
    margin: 0 0 0.75em 0;
}

.wysiwyg-editor p:last-child {
    margin-bottom: 0;
}

.wysiwyg-editor ul,
.wysiwyg-editor ol {
    margin: 0 0 0.75em 1.5em;
    padding-left: 0;
}

.wysiwyg-editor blockquote {
    margin: 0 0 0.75em 0;
    padding: 0.25em 0.75em;
    border-left: 3px solid var(--bs-border-color, #dee2e6);
    color: var(--bs-secondary-color, #6c757d);
}

.wysiwyg-editor pre {
    background-color: var(--bs-secondary-bg, #f8f9fa);
    padding: 0.5em 0.75em;
    border-radius: 0.25em;
    margin: 0 0 0.75em 0;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.875em;
    white-space: pre-wrap;
}

.wysiwyg-editor code {
    background-color: var(--bs-secondary-bg, #f8f9fa);
    padding: 0.1em 0.3em;
    border-radius: 0.2em;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.875em;
}

.wysiwyg-editor a {
    color: var(--bs-link-color, #0d6efd);
    text-decoration: underline;
}

.wysiwyg-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--bs-secondary-color, #6c757d);
    pointer-events: none;
}

/* Floating bubble toolbar */
.wysiwyg-bubble {
    position: absolute;
    display: flex;
    gap: 0.125rem;
    padding: 0.3rem;
    background-color: #212529;
    border-radius: 0.4rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 1080;
}

.wysiwyg-bubble[hidden] {
    display: none;
}

.wysiwyg-bubble-btn {
    background: transparent;
    border: none;
    color: #f8f9fa;
    padding: 0.35rem 0.55rem;
    border-radius: 0.3rem;
    cursor: pointer;
    line-height: 1;
    font-size: 1rem;
}

.wysiwyg-bubble-btn .bi {
    font-size: 1.05rem;
}

.wysiwyg-bubble-btn:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.wysiwyg-bubble-btn.active,
.wysiwyg-bubble-btn.active:hover,
.wysiwyg-bubble-btn.active:focus {
    background-color: var(--bs-primary, #0d6efd);
    color: #fff;
}

/* Link bubble (URL editor) */
.wysiwyg-link-bubble {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem;
    background-color: #212529;
    border-radius: 0.4rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 1081;
}

.wysiwyg-link-bubble[hidden] {
    display: none;
}

.wysiwyg-link-input {
    background-color: #2d3338;
    color: #f8f9fa;
    border: 1px solid #495057;
    border-radius: 0.25rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.875rem;
    width: 240px;
    line-height: 1.4;
}

.wysiwyg-link-input:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.wysiwyg-link-input.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.wysiwyg-link-btn {
    background: transparent;
    border: none;
    color: #f8f9fa;
    padding: 0.3rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    line-height: 1;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wysiwyg-link-btn:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.wysiwyg-link-btn .bi {
    font-size: 1.05rem;
}

.wysiwyg-link-unlink {
    color: #ff8585;
}

/* Dark theme */
[data-bs-theme="dark"] .wysiwyg-toolbar {
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .wysiwyg-editor {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}
