/**
 * Quill Editor Custom Styling
 *
 * Anpassungen für den Quill WYSIWYG-Editor
 */

/* Hide textarea when Quill controller is active */
[data-controller="quill-editor"] textarea {
    display: none !important;
}

/* Wrapper contains toolbar + editor */
.quill-wrapper {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background: #fff;
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Editor Container - now inside wrapper */
.quill-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

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

/* Toolbar Styling - toolbar is sibling to editor container inside wrapper */
.quill-wrapper .ql-toolbar {
    border: none;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 0.375rem 0.375rem 0 0;
    padding: 8px;
    flex-shrink: 0;
}

.quill-wrapper .ql-toolbar button {
    margin: 0 2px;
}

.quill-wrapper .ql-toolbar button:hover {
    color: #0d6efd;
}

.quill-wrapper .ql-toolbar button.ql-active {
    color: #0d6efd;
}

/* Editor Content Area */
.quill-editor-container .ql-container {
    border: none;
    font-family: inherit;
    font-size: inherit;
    flex: 1; /* Take remaining space in flex container */
    overflow-y: auto; /* Scroll content if too large */
    min-height: 0; /* Allow flex shrinking */
}

.quill-editor-container .ql-editor {
    min-height: 120px;
    padding: 15px;
    line-height: 1.6;
}

.quill-editor-container .ql-editor.ql-blank::before {
    color: #6c757d;
    font-style: italic;
}

/* Error State */
.is-invalid + .quill-editor-container {
    border-color: #dc3545;
}

.is-invalid + .quill-editor-container:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* Valid State */
.is-valid + .quill-editor-container {
    border-color: #198754;
}

.is-valid + .quill-editor-container:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* Fix excessive spacing from Quill-generated paragraphs */
.quill-content p {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.quill-content p:last-child {
    margin-bottom: 0;
}

/* Reduce spacing for paragraphs containing only <br> (fallback for older browsers) */
.quill-content p br {
    display: block;
    content: "";
    margin-top: 0;
}

/* Modern browsers: reduce spacing for <p><br></p> */
@supports selector(:has(br:only-child)) {
    .quill-content p:has(br:only-child) {
        margin-bottom: 0.25rem;
        line-height: 1.2;
    }
}
