
/* 
 * FrontCat Custom Editor Styles
 * Modern, clean, and minimal design for Quill.js with Lucide Icons
 */

.frontcat-wysiwyg-wrapper {
    position: relative;
    margin-bottom: 24px;
    background: transparent;
    border: none;
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: all 0.3s ease;
}

/* Toolbar Styling - Floating/Pill Look */
.frontcat-wysiwyg-wrapper .ql-toolbar.ql-snow {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px 12px 0 0; /* Rounded top */
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    z-index: 10;
    position: relative;
    justify-content: flex-start; /* Prevent weird justification */
}

/* Reset styles specifically for toolbar buttons to prevent theme leakage */
.frontcat-wysiwyg-wrapper .ql-toolbar.ql-snow button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    box-shadow: none;
    line-height: normal;
    float: none !important; /* Fix floating issues from theme */
    display: inline-flex !important;
}

/* Toolbar Buttons */
.frontcat-wysiwyg-wrapper .ql-snow .ql-formats {
    margin-right: 12px;
    padding-right: 12px;
    border-right: 1px solid #edf2f7;
    display: flex;
    align-items: center;
    gap: 4px; /* Space between buttons */
    flex-wrap: nowrap; /* Prevent buttons from breaking awkwardly */
}

.frontcat-wysiwyg-wrapper .ql-snow .ql-formats:last-child {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
}

.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar button,
.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar .ql-picker-label {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: all 0.2s ease;
    color: #4a5568;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Fix Picker (Dropdown) Label - "Normal" Text */
.frontcat-wysiwyg-wrapper .ql-snow .ql-picker-label {
    width: auto !important;
    padding-right: 24px !important; /* More space for arrow */
    font-size: 14px;
    font-weight: 500;
    border: none;
    outline: none;
    display: flex !important;
    align-items: center;
}

/* Reset Picker arrow position */
.frontcat-wysiwyg-wrapper .ql-snow .ql-picker-label::before {
    position: relative;
    top: auto;
    right: auto;
    line-height: normal;
}

.frontcat-wysiwyg-wrapper .ql-snow .ql-picker-label svg {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px !important;
    height: 16px !important;
    opacity: 0.7;
}

/* Lucide Icon Sizing inside Buttons */
.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar button svg, 
.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar i svg {
    width: 18px !important; /* Lucide Icon Size */
    height: 18px !important;
    stroke-width: 2px;
    display: block; /* Prevent extra space */
    max-width: 100%;
    max-height: 100%;
}

.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar button:hover,
.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar .ql-picker-label:hover {
    background-color: #f7fafc;
    color: #2d3748;
}

.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar button.ql-active,
.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar .ql-picker-label.ql-active {
    background-color: #ebf4ff;
    color: #3182ce;
}

/* Hide default Quill SVGs if they persist (though JS replaces content) */
.frontcat-wysiwyg-wrapper .ql-snow.ql-toolbar button .ql-stroke {
    display: none;
}

/* Editor Content Area - Theme Isolation & Reset */
.frontcat-wysiwyg-wrapper .ql-container.ql-snow {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-top: none; /* Connect seamlessly to toolbar */
    border-radius: 0 0 12px 12px; /* Rounded bottom */
    font-size: 16px;
    line-height: 1.6;
    color: #2d3748;
    min-height: 200px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.01);
}

.frontcat-wysiwyg-wrapper .ql-editor {
    padding: 24px;
    min-height: 200px;
    /* Force default styles inside editor to override theme */
    text-align: left;
    white-space: normal;
}

/* Content Reset - Ensure editor content looks consistent regardless of theme */
.frontcat-wysiwyg-wrapper .ql-editor p,
.frontcat-wysiwyg-wrapper .ql-editor h1,
.frontcat-wysiwyg-wrapper .ql-editor h2,
.frontcat-wysiwyg-wrapper .ql-editor h3,
.frontcat-wysiwyg-wrapper .ql-editor ul,
.frontcat-wysiwyg-wrapper .ql-editor ol,
.frontcat-wysiwyg-wrapper .ql-editor li,
.frontcat-wysiwyg-wrapper .ql-editor blockquote {
    margin-bottom: 1em !important;
    color: #2d3748 !important;
    line-height: 1.6 !important;
    padding: 0;
    border: none;
    background: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

.frontcat-wysiwyg-wrapper .ql-editor p {
    font-size: 16px !important;
    margin-bottom: 1em !important;
    font-weight: 400 !important;
}

.frontcat-wysiwyg-wrapper .ql-editor h1 {
    font-size: 2em !important;
    font-weight: 700 !important;
    margin-bottom: 0.5em !important;
    margin-top: 0.5em !important;
    line-height: 1.2 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.frontcat-wysiwyg-wrapper .ql-editor h2 {
    font-size: 1.5em !important;
    font-weight: 600 !important;
    margin-bottom: 0.5em !important;
    margin-top: 0.5em !important;
    line-height: 1.3 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.frontcat-wysiwyg-wrapper .ql-editor h3 {
    font-size: 1.25em !important;
    font-weight: 600 !important;
    margin-bottom: 0.5em !important;
}

.frontcat-wysiwyg-wrapper .ql-editor ul,
.frontcat-wysiwyg-wrapper .ql-editor ol {
    padding-left: 1.5em !important;
    margin-bottom: 1em !important;
}

.frontcat-wysiwyg-wrapper .ql-editor li {
    margin-bottom: 0.25em !important;
    list-style-position: outside !important;
}

.frontcat-wysiwyg-wrapper .ql-editor ul li,
.frontcat-wysiwyg-wrapper .ql-editor ol li {
    list-style-type: none !important;
}

.frontcat-wysiwyg-wrapper .ql-editor blockquote {
    border-left: 4px solid #cbd5e0 !important;
    padding-left: 16px !important;
    color: #718096 !important;
    font-style: italic !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.frontcat-wysiwyg-wrapper .ql-editor a {
    color: #3182ce !important;
    text-decoration: underline !important;
}

.frontcat-wysiwyg-wrapper .ql-editor img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 8px !important;
    display: block !important;
    margin: 10px 0 !important;
}

.frontcat-wysiwyg-wrapper .ql-editor.ql-blank::before {
    font-style: normal;
    color: #a0aec0 !important;
    font-size: 16px !important;
    left: 24px; /* Align placeholder with padding */
    right: 24px;
}

/* Focus State */
.frontcat-wysiwyg-wrapper.focused .ql-toolbar.ql-snow,
.frontcat-wysiwyg-wrapper.focused .ql-container.ql-snow {
    border-color: #cbd5e0;
}

.frontcat-wysiwyg-wrapper.focused {
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
    border-radius: 12px;
}

/* Code View Toggle Button - Modern Pill Switch */
.frontcat-wysiwyg-wrapper .frontcat-toggle-code {
    position: absolute;
    top: -45px;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #718096;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.frontcat-wysiwyg-wrapper .frontcat-toggle-code:hover {
    background-color: #f7fafc;
    color: #2d3748;
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.frontcat-wysiwyg-wrapper .frontcat-toggle-code.active {
    background-color: #2d3748;
    color: #fff;
    border-color: #2d3748;
}

.frontcat-wysiwyg-wrapper .frontcat-toggle-code svg {
    width: 14px;
    height: 14px;
}

/* Textarea (Code View) Styling */
.frontcat-wysiwyg-wrapper textarea.frontcat-wysiwyg-content {
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 24px !important;
    background: #1a202c !important; /* Dark mode for code */
    color: #e2e8f0 !important;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    resize: vertical;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1) !important;
    width: 100%;
    box-sizing: border-box;
    display: none; /* Hidden by default */
    white-space: pre-wrap !important; /* Fix line wrapping */
    overflow-x: auto;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .frontcat-wysiwyg-wrapper .ql-toolbar.ql-snow {
        padding: 8px;
        gap: 4px;
        justify-content: space-between;
    }
    
    .frontcat-wysiwyg-wrapper .ql-snow .ql-formats {
        margin-right: 4px;
        padding-right: 4px;
        border-right: none;
    }
    
    .frontcat-wysiwyg-wrapper .frontcat-toggle-code {
        position: relative;
        top: 0;
        margin-bottom: 12px;
        display: inline-flex;
        width: auto;
    }
}

/* Table Styles for Quill 2.0 */
.frontcat-wysiwyg-wrapper .ql-editor table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}
.frontcat-wysiwyg-wrapper .ql-editor table td,
.frontcat-wysiwyg-wrapper .ql-editor table th {
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    vertical-align: top;
}
.frontcat-wysiwyg-wrapper .ql-editor table th {
    background-color: #f3f4f6;
    font-weight: 600;
}
/* Quill 2.0 Table Tooltip fix */
.ql-tooltip.ql-editing {
    left: 50% !important;
    transform: translate(-50%, 0);
}

