/* Custom styles for Quill rich content fields */
/* Note: You need to download quill.snow.css from https://quilljs.com/ and place it in this directory */

/* Custom styling for rich content fields */
.rich-content-container {
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin: 5px 0;
    resize: both;
    overflow: auto;
    min-height: 250px;
    max-height: 600px;
    min-width: 300px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ql-toolbar {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    background-color: #f5f5f5;
    position: sticky;
    top: 0;
    margin-top: 10px;
    z-index: 1;
    overflow: visible !important;
}

.rich-content-container .ql-editor {
    min-height: 200px;
    /* Remove max-height to allow container resizing to control height */
    overflow-y: auto;
}

/* Style for displaying rich content (read-only mode) */
.rich-content-display {
    background-color: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    min-height: 30px;
    margin-top: 10px;
    font-size: 13px;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: normal !important;
    font-style: normal !important;
}

/* Ensure base text is normal weight and style */
.rich-content-display p,
.rich-content-display div {
    font-weight: normal !important;
    font-style: normal !important;
}

/* Only apply bold to elements that should be bold */
.rich-content-display strong,
.rich-content-display b {
    font-weight: bold !important;
}

/* Only apply italic to elements that should be italic */
.rich-content-display em,
.rich-content-display i {
    font-style: italic !important;
}

/* Headers should have their natural weight */
.rich-content-display h1,
.rich-content-display h2,
.rich-content-display h3,
.rich-content-display h4,
.rich-content-display h5,
.rich-content-display h6 {
    font-weight: bold !important;
    margin: 10px 0;
}

.rich-content-display img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px 0;
}

/* Ensure consistent font sizing with the rest of the form */
.ql-editor {
    font-size: 13px;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: normal;
    font-style: normal;
}

/* Ensure default paragraph text is not bold or italic */
.ql-editor p {
    font-weight: normal;
    font-style: normal;
    margin-bottom: 1em !important;  /* Add space after paragraphs - important to override Quill defaults */
    margin-top: 0;  /* Ensure consistent spacing */
}

/* Remove extra margin from last paragraph to avoid unnecessary space at bottom */
.ql-editor p:last-child {
    margin-bottom: 0 !important;
}

/* Also apply spacing to divs that Quill might create */
.ql-editor div {
    margin-bottom: 1em !important;
    margin-top: 0;
}

.ql-editor div:last-child {
    margin-bottom: 0 !important;
}

/* Ensure spacing is also applied in the rich-content-container */
.rich-content-container .ql-editor p,
.rich-content-container .ql-editor div {
    margin-bottom: 1em !important;
    margin-top: 0;
}

.rich-content-container .ql-editor p:last-child,
.rich-content-container .ql-editor div:last-child {
    margin-bottom: 0 !important;
}

/* Reset any default formatting on empty editor */
.ql-editor.ql-blank {
    font-weight: normal;
    font-style: normal;
}

/* Ensure Quill tooltips are visible */
.ql-tooltip {
    position: absolute;
    z-index: 1000;
}

/* Style for toolbar button tooltips */
.ql-toolbar button[data-tooltip]:hover::after,
.ql-toolbar .ql-picker[data-tooltip]:hover::after,
.ql-toolbar .ql-picker-label[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    z-index: 1000;
}

/* Add arrow pointing down to button */
.ql-toolbar button[data-tooltip]:hover::before,
.ql-toolbar .ql-picker[data-tooltip]:hover::before,
.ql-toolbar .ql-picker-label[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    pointer-events: none;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    z-index: 1001;
}

/* Ensure pickers have proper positioning */
.ql-toolbar .ql-picker {
    position: relative;
}

.ql-toolbar .ql-picker-label {
    position: relative;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Ensure toolbar buttons have proper positioning for tooltips */
.ql-toolbar button,
.ql-toolbar .ql-picker {
    position: relative;
}