/* Ensure Material Icons font is properly loaded */
.material-icons {
    font-family: 'Material Icons' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    font-feature-settings: 'liga';
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.pb-text-editor-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.pb-text-editor-container .ql-editor {
    min-height: 150px;
    line-height: 1.42;
    font-size: 14px;
}

.pb-text-editor-container .ql-toolbar {
    border-top: 1px solid #ccc;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-bottom: none;
    background-color: #f7f7f7;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.pb-text-editor-container .ql-container {
    border: 1px solid #ccc;
    border-top: none;
}

.pb-text-editor-container .ql-editor.ql-blank::before {
    color: #999;
    font-style: italic;
}

.pb-text-editor-container .ql-editor p {
    margin: 0 0 1em 0;
}

.pb-text-editor-container .ql-editor h1, 
.pb-text-editor-container .ql-editor h2, 
.pb-text-editor-container .ql-editor h3, 
.pb-text-editor-container .ql-editor h4, 
.pb-text-editor-container .ql-editor h5, 
.pb-text-editor-container .ql-editor h6 {
    margin: 0 0 1em 0;
}

.pb-text-editor-container .ql-toolbar .ql-formats {
    margin-right: 15px;
    display: inline-block;
    vertical-align: middle;
}

.pb-text-editor-container .ql-toolbar button {
    padding: 5px;
    margin: 2px;
}

.pb-text-editor-container .ql-toolbar button:hover {
    background-color: #e6e6e6;
}

.pb-text-editor-container .ql-toolbar button.ql-active {
    background-color: #06c;
    color: white;
}

.pb-text-editor-container .ql-toolbar button.ql-active .ql-fill {
    fill: white;
}

.pb-text-editor-container .ql-toolbar button.ql-active .ql-stroke {
    stroke: white;
}

.pb-text-editor-container .ql-toolbar button.ql-active .ql-stroke.ql-fill {
    fill: white;
    stroke: white;
}

/* Prevent custom buttons from getting the active state */
.pb-text-editor-container .ql-toolbar .ql-custom-tool.ql-active {
    background-color: #e6e6e6 !important;
    color: #444 !important;
}

/* Custom toolbar buttons styling - match Quill toolbar buttons */
.pb-text-editor-container .ql-toolbar .ql-custom-tool {
    background: none;
    border: 1px solid #ccc !important; /* Make border visible for debugging */
    cursor: pointer;
    display: inline-block;
    float: left;
    font-size: 13px;
    font-weight: normal;
    height: 24px;
    line-height: 22px;
    margin-right: 5px;
    text-align: center;
    vertical-align: middle;
    width: 28px;
    padding: 3px 5px;
    color: #444;
}

.pb-text-editor-container .ql-toolbar .ql-custom-tool:hover {
    color: #06c;
}

.pb-text-editor-container .ql-toolbar .ql-custom-tool:active,
.pb-text-editor-container .ql-toolbar .ql-custom-tool:focus {
    outline: none;
}

/* Style SVG icons in custom buttons to match Quill's style */
.pb-text-editor-container .ql-toolbar .ql-custom-tool svg {
    display: inline-block;
    fill: currentColor;
    height: 18px;
    stroke: currentColor;
    stroke-width: 0;
    vertical-align: middle;
    width: 18px;
}

.pb-text-editor-container .ql-toolbar .ql-custom-tool .mud-icon-root {
    display: inline-block;
    fill: currentColor;
    height: 18px;
    stroke: currentColor;
    stroke-width: 0;
    vertical-align: middle;
    width: 18px;
}

.pb-text-editor-container .ql-toolbar .ql-custom-tool .material-icons {
    font-family: 'Material Icons' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 16px !important;
    line-height: 1;
    vertical-align: middle;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'liga';
    -moz-osx-font-smoothing: grayscale;
}

/* MudBlazor icon styling in custom toolbar buttons */
.pb-text-editor-container .ql-toolbar .ql-custom-tool .mud-icon-root {
    font-size: 16px;
    line-height: 1;
    vertical-align: middle;
    color: inherit;
}

.pb-text-editor-container .ql-toolbar .ql-custom-tool:hover .mud-icon-root {
    color: #444;
}

/* Template buttons container - should NOT be displayed once moved to toolbar */
.pb-template-buttons,
.pb-template-buttons-row {
    /* Will be hidden by JavaScript after moving to toolbar */
}

/* Ensure template buttons in toolbar have proper spacing and visibility */
.pb-text-editor-container .ql-toolbar .ql-formats .ql-custom-tool {
    margin-left: 2px;
    margin-right: 2px;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: 2px;
}

/* Ensure Material Icons show properly in Quill toolbar */
.pb-text-editor-container .ql-toolbar .ql-custom-tool .material-icons {
    font-family: 'Material Icons' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 16px !important;
    line-height: 1;
    vertical-align: middle;
    color: #444;
}

/* Ensure proper rendering in MudDialog context */
.mud-dialog .pb-text-editor-container {
    position: relative;
    z-index: 1;
}

.mud-dialog .pb-text-editor-container .ql-container {
    min-height: 250px;
}

/* Better styling for fallback text editor */
.pb-text-editor-container .alert-warning {
    border-radius: 4px;
    font-size: 12px;
    padding: 8px 12px;
}

/* Remove validation error styling when in fallback mode */
.pb-text-editor-container .mud-input-error .mud-input-control {
    border-color: #ccc !important;
}

/* Template buttons row below editor */
.pb-template-buttons-row {
    background-color: #f7f7f7;
    border: 1px solid #ccc;
    border-top: none;
    padding: 4px 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

/* Template button styling in the row */
.pb-template-buttons-row .ql-custom-tool {
    background: none;
    border: 1px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    height: 24px;
    line-height: 1;
    padding: 3px 5px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    width: auto;
    color: #444;
    min-width: 24px;
}

.pb-template-buttons-row .ql-custom-tool:hover {
    background-color: #e6e6e6;
    border-color: #adadad;
}

.pb-template-buttons-row .mud-icon-button {
    background-color: transparent;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.pb-template-buttons-row .mud-icon-button:hover {
    background-color: #e6e6e6;
    border-color: #adadad;
}

.pb-template-buttons-row .mud-icon-button-label {
    color: #444;
}

/* Ensure editor always has a border even without template buttons */
.pb-text-editor-container .ql-container {
    border: 1px solid #ccc !important;
}

/* Line height dropdown labels for snow theme */
.ql-snow .ql-picker.ql-lineHeight .ql-picker-label::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item::before {
    content: 'Line Height';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="0.25"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="0.25"]::before {
    content: '0.25';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="0.35"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="0.35"]::before {
    content: '0.35';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="0.5"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="0.5"]::before {
    content: '0.5';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="0.75"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="0.75"]::before {
    content: '0.75';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="1.0"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="1.0"]::before {
    content: '1.0';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="1.15"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="1.15"]::before {
    content: '1.15';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="1.5"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="1.5"]::before {
    content: '1.5';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="2.0"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="2.0"]::before {
    content: '2.0';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="2.5"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="2.5"]::before {
    content: '2.5';
}

.ql-snow .ql-picker.ql-lineHeight .ql-picker-label[data-value="3.0"]::before,
.ql-snow .ql-picker.ql-lineHeight .ql-picker-item[data-value="3.0"]::before {
    content: '3.0';
}

/* Make the dropdown label show the current value */
.ql-snow .ql-picker.ql-lineHeight .ql-picker-label::before {
    content: attr(data-value);
}

/* Default label when no value is selected */
.ql-snow .ql-picker.ql-lineHeight .ql-picker-label:not([data-value])::before {
    content: 'Line Height';
}

/* Make line height dropdown wider to prevent overlap */
.ql-snow .ql-picker.ql-lineHeight {
    width: 80px;
}

/* Adjust label padding to accommodate dropdown arrow */
.ql-snow .ql-picker.ql-lineHeight .ql-picker-label {
    padding-right: 18px;
}

/* Ensure dropdown options have enough width */
.ql-snow .ql-picker.ql-lineHeight .ql-picker-options {
    min-width: 80px;
}
