/* Shared WYSIWYG editor chrome (notes, KB, modals) */

/* Header / style pickers — enough width so label + arrow do not overlap or wrap */
.atomware-wysiwyg-editor-wrap .ql-toolbar .ql-picker.ql-header,
.atomware-wysiwyg-editor .ql-toolbar .ql-picker.ql-header {
    width: 118px;
    min-width: 118px;
}
.atomware-wysiwyg-editor-wrap .ql-toolbar .ql-picker.ql-header .ql-picker-label,
.atomware-wysiwyg-editor .ql-toolbar .ql-picker.ql-header .ql-picker-label {
    min-width: 108px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 22px;
    line-height: 1.35;
}
.atomware-wysiwyg-editor-wrap .ql-toolbar .ql-picker.ql-color .ql-picker-label,
.atomware-wysiwyg-editor-wrap .ql-toolbar .ql-picker.ql-background .ql-picker-label,
.atomware-wysiwyg-editor .ql-toolbar .ql-picker.ql-color .ql-picker-label,
.atomware-wysiwyg-editor .ql-toolbar .ql-picker.ql-background .ql-picker-label {
    padding: 2px 4px;
}

/* Image selection + resize overlay */
.atomware-quill-editor-host {
    position: relative;
}
.atomware-quill-editor-host .ql-editor img.atomware-quill-image-selected {
    outline: 2px solid var(--atomware-primary, #4a86e8);
    outline-offset: 2px;
}
.atomware-quill-image-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 14;
    box-sizing: border-box;
    border: 1px dashed var(--atomware-primary, #4a86e8);
}
.atomware-quill-image-drag-handle {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 12px;
    height: 12px;
    background: var(--atomware-primary, #4a86e8);
    border: 2px solid #fff;
    border-radius: 2px;
    cursor: nwse-resize;
    pointer-events: auto;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.atomware-quill-image-panel {
    position: absolute;
    z-index: 15;
    min-width: 220px;
    max-width: 320px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--atomware-border, rgba(255, 255, 255, 0.15));
    background: var(--atomware-surface-modal, #1a1a1a);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.atomware-quill-image-panel-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--atomware-text-primary, #f9fafb);
    margin-bottom: 2px;
}
.atomware-quill-image-panel-label {
    font-size: 0.75rem;
    color: var(--atomware-text-muted, #9ca3af);
    margin: 0;
}
.atomware-quill-image-panel .atomware-input {
    width: 100%;
    box-sizing: border-box;
    font-size: 0.85rem;
    padding: 6px 8px;
}
.atomware-quill-image-width-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.atomware-quill-image-width-presets button {
    flex: 1 1 auto;
    min-width: 42px;
    padding: 4px 6px;
    font-size: 0.72rem;
    border-radius: 4px;
    border: 1px solid var(--atomware-border, rgba(255, 255, 255, 0.2));
    background: var(--atomware-bg-tertiary, #2a2a2a);
    color: var(--atomware-text-primary, #f9fafb);
    cursor: pointer;
}
.atomware-quill-image-width-presets button:hover {
    border-color: var(--atomware-primary, #4a86e8);
}
.atomware-quill-image-panel .atomware-quill-image-remove {
    margin-top: 4px;
    align-self: flex-start;
}
.atomware-quill-img-caption {
    margin: 4px 0 12px;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--atomware-text-muted, #6b7280);
    text-align: center;
}
.atomware-wysiwyg-editor .ql-editor .atomware-quill-img-caption,
#kb-article-editor .ql-editor .atomware-quill-img-caption {
    color: #6b7280;
}

/* KB: resizable editor wrap (parity with notes modals) */
.atomware-kb-form-group .atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable {
    display: flex;
    flex-direction: column;
    position: relative;
    height: 300px;
    min-height: 180px;
    max-height: 600px;
    overflow: visible;
}
.atomware-kb-form-group .atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable > .atomware-wysiwyg-editor,
.atomware-kb-form-group .atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable > #kb-article-editor {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: visible;
    min-height: 0 !important;
}
.atomware-kb-form-group .atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable .ql-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.atomware-kb-form-group .atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable .ql-editor {
    flex: 1 1 auto;
    min-height: 0 !important;
    overflow-y: auto;
    overflow-x: hidden;
}
.atomware-kb-form-group .atomware-wysiwyg-editor-wrap .ql-toolbar.ql-snow {
    overflow: visible;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.atomware-kb-modal .atomware-wysiwyg-editor-wrap .ql-toolbar .ql-picker.ql-expanded {
    z-index: 30;
}
.atomware-kb-modal .atomware-wysiwyg-editor-wrap .ql-snow .ql-picker-options {
    z-index: 31;
}

/* Resize handle (notes modals + KB) */
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable > .atomware-wysiwyg-resize-handle {
    position: relative;
    flex: 0 0 10px;
    width: 100%;
    z-index: 4;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable > .atomware-wysiwyg-resize-handle::after {
    content: '';
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--atomware-text-muted, rgba(0, 0, 0, 0.3));
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable > .atomware-wysiwyg-resize-handle:hover::after {
    background: var(--atomware-primary, #6366f1);
}

/* Toolbar theme fallback (KB light theme + all editors when wysiwyg-dark is absent) */
.atomware-wysiwyg-editor-wrap .ql-toolbar.ql-snow,
.atomware-wysiwyg-editor .ql-toolbar.ql-snow,
#kb-article-editor .ql-toolbar.ql-snow,
.atomware-kb-modal .ql-toolbar.ql-snow {
    background: #1d4ed8 !important;
    border: none !important;
    border-bottom: 1px solid #1e40af !important;
    border-radius: 8px 8px 0 0;
}
.atomware-wysiwyg-editor-wrap .ql-toolbar .ql-stroke,
.atomware-wysiwyg-editor .ql-toolbar .ql-stroke,
#kb-article-editor .ql-toolbar .ql-stroke,
.atomware-kb-modal .ql-toolbar .ql-stroke {
    stroke: #fff !important;
}
.atomware-wysiwyg-editor-wrap .ql-toolbar .ql-fill,
.atomware-wysiwyg-editor .ql-toolbar .ql-fill,
#kb-article-editor .ql-toolbar .ql-fill,
.atomware-kb-modal .ql-toolbar .ql-fill {
    fill: #fff !important;
}
.atomware-wysiwyg-editor-wrap .ql-toolbar .ql-picker,
.atomware-wysiwyg-editor-wrap .ql-toolbar .ql-picker-label,
.atomware-wysiwyg-editor .ql-toolbar .ql-picker,
.atomware-wysiwyg-editor .ql-toolbar .ql-picker-label,
#kb-article-editor .ql-toolbar .ql-picker,
#kb-article-editor .ql-toolbar .ql-picker-label,
.atomware-kb-modal .ql-toolbar .ql-picker,
.atomware-kb-modal .ql-toolbar .ql-picker-label {
    color: #fff !important;
}

/* Responsive toolbar — two logical rows; dropdowns stay visible */
.atomware-wysiwyg-editor-wrap {
    position: relative;
}
.atomware-wysiwyg-editor-wrap .ql-toolbar.ql-snow,
.atomware-wysiwyg-editor .ql-toolbar.ql-snow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    gap: 4px 6px;
    padding: 8px 10px 10px;
    overflow: visible;
    box-sizing: border-box;
    min-height: 44px;
}
.atomware-wysiwyg-editor-wrap .ql-toolbar.ql-snow .ql-formats,
.atomware-wysiwyg-editor .ql-toolbar.ql-snow .ql-formats {
    margin: 0 6px 2px 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    gap: 2px;
}
/* Row break after header picker */
.atomware-wysiwyg-editor-wrap .ql-toolbar.ql-snow .ql-formats:has(.ql-header)::after,
.atomware-wysiwyg-editor .ql-toolbar.ql-snow .ql-formats:has(.ql-header)::after {
    content: '';
    flex-basis: 100%;
    width: 0;
    height: 0;
}
/* Fullscreen toggle — last item in toolbar, matches Quill icon style */
.atomware-wysiwyg-toolbar-fs-group {
    margin-left: auto !important;
    margin-right: 0 !important;
}
.atomware-wysiwyg-editor-fullscreen-btn {
    position: static;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #fff;
    border-radius: 4px;
}
.atomware-wysiwyg-editor-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}
.atomware-wysiwyg-editor-fullscreen-btn .material-icons {
    font-size: 18px;
    line-height: 1;
    color: #fff;
}
.atomware-wysiwyg-editor-wrap.atomware-quill-readonly .atomware-wysiwyg-toolbar-fs-group {
    display: none !important;
}
@media (max-width: 640px) {
    .atomware-wysiwyg-editor-wrap .ql-toolbar.ql-snow,
    .atomware-wysiwyg-editor .ql-toolbar.ql-snow {
        padding-right: 6px;
    }
    .atomware-wysiwyg-editor-wrap .ql-toolbar button,
    .atomware-wysiwyg-editor .ql-toolbar button {
        width: 26px;
        height: 26px;
    }
    .atomware-wysiwyg-editor-wrap .ql-toolbar .ql-picker-label,
    .atomware-wysiwyg-editor .ql-toolbar .ql-picker-label {
        font-size: 12px;
        padding: 2px 4px;
    }
}

/* Per-editor fullscreen — reparented to body; always true viewport fullscreen */
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 100200;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 0 !important;
    margin: 0;
    padding: 12px;
    box-sizing: border-box;
    background: var(--atomware-bg-primary, #0a0a0a);
    display: flex;
    flex-direction: column;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen.atomware-wysiwyg-resizable {
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 0 !important;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .atomware-wysiwyg-resize-handle {
    display: none !important;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > .ql-toolbar.ql-snow {
    flex: 0 0 auto;
    width: 100%;
    position: relative;
    z-index: 2;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > .atomware-wysiwyg-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #kb-article-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #note-description-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #note-detail-description-editor {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > .atomware-wysiwyg-editor .ql-container,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #note-description-editor .ql-container,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #note-detail-description-editor .ql-container,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #kb-article-editor .ql-container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > .atomware-wysiwyg-editor .ql-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #note-description-editor .ql-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #note-detail-description-editor .ql-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #kb-article-editor .ql-editor {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
/* White editor surface in viewport fullscreen (survives reparent to body; notes modals lose scoped rules) */
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > .atomware-wysiwyg-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #note-description-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #note-detail-description-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen > #kb-article-editor {
    background: #ffffff !important;
    color: #1a1a1a !important;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-container.ql-snow {
    background: #ffffff !important;
    color: #1a1a1a !important;
    border: none;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor {
    background: #ffffff !important;
    color: #1a1a1a !important;
    font-size: 14px;
    line-height: 1.6;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor.ql-blank::before {
    color: #999;
    font-style: normal;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor h1,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor h2,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor h3 {
    color: #1a1a1a;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor a {
    color: #2f6fd4;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor blockquote {
    border-left: 4px solid #2f6fd4;
    background: #f0f7ff;
    color: #333;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor pre,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen .ql-editor code {
    background: #f3f4f6;
    color: #1a1a1a;
}

/* Sub-task editors: Quill toolbar + host live inside .atomware-subtask-quill-slot (not direct wrap children) */
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen.atomware-subtask-description-wrap > .atomware-subtask-quill-slot {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen.atomware-subtask-description-wrap .atomware-subtask-quill-slot > .ql-toolbar.ql-snow {
    flex: 0 0 auto;
    width: 100%;
    position: relative;
    z-index: 2;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen.atomware-subtask-description-wrap .atomware-subtask-quill-slot > .atomware-wysiwyg-editor,
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen.atomware-subtask-description-wrap .atomware-subtask-quill-slot > [id^="subtask-desc-"] {
    flex: 1 1 auto;
    min-height: 0 !important;
    height: auto !important;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ffffff !important;
    color: #1a1a1a !important;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen.atomware-subtask-description-wrap .atomware-subtask-quill-slot .ql-container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.atomware-wysiwyg-editor-wrap.atomware-wysiwyg-editor-fullscreen.atomware-subtask-description-wrap .atomware-subtask-quill-slot .ql-editor {
    flex: 1 1 auto;
    min-height: 0 !important;
    overflow-y: auto;
}

body.atomware-wysiwyg-editor-fs-active {
    overflow: hidden;
}
/* Editor / KB modal viewport fullscreen — keep platform shell underneath */
body.atomware-wysiwyg-editor-fs-active .atomware-platform-shell-nav,
body.atomware-kb-modal-fs-active .atomware-platform-shell-nav {
    z-index: 99990 !important;
}
body.atomware-kb-modal-fs-active {
    overflow: hidden;
}

/* Note/KB modals: grow editor when modal is fullscreen */
#create-note-modal.atomware-modal-fullscreen .atomware-modal-body,
#note-detail-modal.atomware-modal-fullscreen .atomware-modal-body,
#kb-article-modal.atomware-kb-modal-fullscreen .atomware-kb-modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#create-note-modal.atomware-modal-fullscreen .atomware-form-group:has(.atomware-wysiwyg-editor-wrap),
#note-detail-modal.atomware-modal-fullscreen .atomware-note-detail-desc-block,
#kb-article-modal.atomware-kb-modal-fullscreen .atomware-kb-form-group:has(.atomware-wysiwyg-editor-wrap) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
#create-note-modal.atomware-modal-fullscreen .atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable,
#note-detail-modal.atomware-modal-fullscreen .atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable,
#kb-article-modal.atomware-kb-modal-fullscreen .atomware-wysiwyg-editor-wrap.atomware-wysiwyg-resizable {
    flex: 1 1 auto;
    height: auto;
    min-height: 240px;
    max-height: none;
}
