/* ===== QUILL EDITOR CLEANUP & TOOLBAR MANAGEMENT ===== */

/* Sicherstellen, dass Quill-Toolbars ordnungsgemäß positioniert und entfernt werden */
.card-content-full .ql-toolbar {
    position: relative !important;
    border: 1px solid #ccc;
    border-bottom: none;
    background: #f8f9fa;
    z-index: 10;
}

/* Container für Quill Editor */
.card-content-full .ql-container {
    border: 1px solid #ccc;
    background: white;
    min-height: 200px;
}

/* Verstecke potentiell übrig gebliebene Quill-Elemente */
.card-content-full:not(.quill-editing) .ql-toolbar,
.card-content-full:not(.quill-editing) .ql-container.ql-snow {
    display: none !important;
}

/* Aktiver Quill-Editor Zustand */
.card-content-full.quill-editing .ql-editor {
    padding: 15px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}

/* Quill-Toolbar sollte nicht außerhalb des Containers erscheinen */
.modal-body .ql-toolbar {
    margin-bottom: 0;
}

/* Verhindere das Übrigbleiben von Quill-Klassen */
/* .markdown-content.ql-container:not(.quill-active) {
    border: none !important;
    background: transparent !important;
} */

/* .markdown-content.ql-container:not(.quill-active) .ql-editor {
    padding: 0 !important;
    background: transparent !important;
} */

/* ===== TOGGLE SWITCHES UND SETTINGS UI ===== */

/* Toggle Switch Styling */
.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #d1d5db;
    border-radius: 12px;
    margin-right: 0.75rem;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider {
    background-color: #3b82f6;
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.toggle-label:hover .toggle-slider {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Settings Section Styling */
.sidebar-setting {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.setting-status {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.setting-status span {
    font-weight: 600;
}

.setting-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #eff6ff;
    border-radius: 4px;
    border-left: 3px solid #3b82f6;
}

.setting-info small {
    color: #1e40af;
    line-height: 1.4;
}

/* Quill Editor Anpassungen für Card Content */
.markdown-content.ql-container 
{
    border: 1px solid #e2e8f0;
    background: #f7fafc;
    border-radius: 8px;
}
#full-card-modal .ql-editor {
    min-height: 400px;
    font-size: 1.05rem;
    line-height: 1.6;
    padding: 1rem;
    border-radius: 8px;
    border: 0px solid #e2e8f0;
    background: #f7fafc;
    height: fit-content;
}

#full-card-modal .ql-toolbar {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

#full-card-modal .ql-container {
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-top-left-radius: 0px;
    border-top-right-radius: 0px;
    border-top: none;
}

/* Quill Toolbar Button Styling */
#full-card-modal .ql-toolbar .ql-formats {
    margin-right: 1rem;
}

#full-card-modal .ql-toolbar button {
    padding: 0.25rem;
    border-radius: 3px;
    transition: background-color 0.2s;
}

#full-card-modal .ql-toolbar button:hover {
    background-color: #f3f4f6;
}

#full-card-modal .ql-toolbar button.ql-active {
    background-color: #3b82f6;
    color: white;
}

/* Responsive Design für Settings */
@media (max-width: 768px) {
    .toggle-slider {
        width: 40px;
        height: 22px;
        margin-right: 0.5rem;
    }
    
    .toggle-slider::after {
        width: 18px;
        height: 18px;
    }
    
    .toggle-label input[type="checkbox"]:checked + .toggle-slider::after {
        transform: translateX(18px);
    }
    
    .sidebar-setting {
        padding: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .setting-info {
        padding: 0.5rem;
    }
}

/* Loading State für Quill */
.quill-loading {
    position: relative;
    min-height: 400px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quill-loading::before {
    content: '📝 Editor wird geladen...';
    color: #6b7280;
    font-size: 0.9rem;
}

/* Error State für Quill */
.quill-error {
    position: relative;
    min-height: 200px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dc2626;
}

.quill-error::before {
    content: '❌ Editor konnte nicht geladen werden';
    font-size: 0.9rem;
}

/* Smooth Transitions */
.card-content-full {
    transition: all 0.3s ease;
}

/* Quill Editor Focus Styling */
#full-card-modal .ql-editor:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

/* Custom Quill Theme Anpassungen */
#full-card-modal .ql-snow .ql-stroke {
    stroke: #374151;
}

#full-card-modal .ql-snow .ql-fill {
    fill: #374151;
}

#full-card-modal .ql-snow .ql-picker-label {
    color: #374151;
}

/* Markdown Preview Styling (falls Markdown Plugin aktiv) */
.quill-markdown-preview {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #374151;
}

.quill-markdown-preview h1,
.quill-markdown-preview h2,
.quill-markdown-preview h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.quill-markdown-preview p {
    margin-bottom: 0.75rem;
}

.quill-markdown-preview code {
    background: #e5e7eb;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.875rem;
}

/* Manual Activation Edit Button */
.quill-edit-button {
    padding: 7px 7px;
    cursor: pointer;
    z-index: 11;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.quill-edit-button:hover {
    background: #ffffff;
    transform: translateY(-1px);
}

.quill-edit-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}

/* Button Container für bessere Positionierung */
.quill-button-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0px;
    position: sticky;
    z-index: 11;
    margin-top: 0px;
}

/* ESC-Hinweis für aktive Editoren */
.card-content-full.quill-editing::before {
    content: 'ESC = Abbrechen ohne Speichern';
    position: absolute;
    top: -20px;
    right: 0;
    background: #374151;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    z-index: 15;
    opacity: 0.8;
    pointer-events: none;
}

/* Card Content Container Styling for Edit Mode */
.card-content-full {
    position: relative;
}

.card-content-full:hover .quill-edit-button {
    opacity: 1;
    visibility: visible;
}

.quill-edit-button {
    opacity: 0.8;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Responsive Edit Button */
@media (max-width: 768px) {
    .quill-edit-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        top: 5px;
        right: 5px;
    }
}

/* Quill Editor Enhancements for Manual Mode */
.ql-editor {
    min-height: 300px;
    font-size: 1.05rem;
    line-height: 1.6;
}

.ql-toolbar {
    border-top: 1px solid #e2e8f0;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    border-bottom: none;
    background: #f8fafc;
}

.ql-container {
    border-bottom: 1px solid #e2e8f0;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    border-top: none;
}

/* ===== QUILL EDITOR WORD WRAP & TEXT FLOW ===== */

/* Zeilenumbruch für Quill Editor erzwingen */
.card-content-full .ql-editor {
    /* Erzwinge Wortumbruch für lange Wörter und Zeilen */
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important; /* WICHTIG: normal statt pre-wrap */
    
    /* Verhindere horizontales Scrollen */
    overflow-x: hidden !important;
    max-width: 100% !important;
    
    /* Bessere Lesbarkeit */
    line-height: 1.6 !important;
    padding: 15px !important;
    font-family: inherit !important;
    font-size: 14px !important;
}

/* Spezielle Behandlung für verschiedene Content-Typen im Quill Editor */
.card-content-full .ql-editor p {
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important; /* WICHTIG: normal statt pre-wrap */
    margin-bottom: 1em !important;
}

.card-content-full .ql-editor div {
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important; /* WICHTIG: normal statt pre-wrap */
}

/* Für Code-Blöcke spezielles Handling */
.card-content-full .ql-editor pre {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-x: auto !important;
    max-width: 100% !important;
}

/* Listen sollten auch umbrechen */
.card-content-full .ql-editor ul,
.card-content-full .ql-editor ol,
.card-content-full .ql-editor li {
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

/* Quill Container selbst auch sicherstellen */
.card-content-full .ql-container {
    border: 1px solid #ccc;
    background: white;
    min-height: 200px;
    overflow-x: hidden !important; /* Verhindere horizontales Scrollen */
    word-wrap: break-word !important;
}

/* Markdown Content Anzeige - auch hier Zeilenumbruch sicherstellen */
.card-content-full .markdown-content {
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important; /* WICHTIG: normal für korrekte Zeilenumbrüche bei Leerzeichen */
    max-width: 100% !important;
    overflow-x: hidden !important;
}

.card-content-full .markdown-content p,
.card-content-full .markdown-content div {
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important; /* WICHTIG: normal für korrekte Zeilenumbrüche bei Leerzeichen */
}

/* ===== IFRAME EMBED SUPPORT ===== */

/* iframe-embed Container Styling */
.card-content-full .iframe-embed {
    margin: 1rem 0;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    position: relative;
}

.card-content-full .iframe-embed iframe {
    width: 100% !important;
    min-height: 315px;
    border: none;
    display: block;
}

/* Quill Editor iframe-embed Styling */
.card-content-full .ql-editor .iframe-embed {
    margin: 1rem 0 !important;
    padding: 0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    background: #000 !important;
    position: relative !important;
}

.card-content-full .ql-editor .iframe-embed iframe {
    width: 100% !important;
    min-height: 315px !important;
    border: none !important;
    display: block !important;
}

/* Verhindere dass Quill iframe-Elemente als Text behandelt */
.card-content-full .ql-editor iframe {
    pointer-events: auto !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.ql-tooltip.ql-editing[data-mode="video"] {
    left: 10px !important;
}
.card-content-full .markdown-content iframe.ql-video {
    width: 100% !important;
    min-height: 50vh!important;
}