/* Trix Editor Styles for JRP Rich Text Editor */

.trix-content ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.trix-content ol {
    list-style-type: decimal;
    padding-left: 1.5rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.trix-content li {
    margin-bottom: 0.5rem;
    display: list-item;
}

.trix-content ul li,
.trix-content ol li {
    list-style-position: outside;
}

/* Ensure Trix editor shows list styles */
trix-editor ul {
    list-style-type: disc !important;
    padding-left: 1.5rem !important;
    margin-left: 0 !important;
}

trix-editor ol {
    list-style-type: decimal !important;
    padding-left: 1.5rem !important;
    margin-left: 0 !important;
}

trix-editor li {
    display: list-item !important;
    list-style-position: outside !important;
}

/* Alignment helper tags for Trix */
centered-div,
left-aligned-div,
right-aligned-div {
    display: block;
}

centered-div {
    text-align: center;
}

left-aligned-div {
    text-align: left;
}

right-aligned-div {
    text-align: right;
}

.trix-content centered-div,
.trix-content left-aligned-div,
.trix-content right-aligned-div {
    display: block;
}

trix-editor centered-div,
trix-editor left-aligned-div,
trix-editor right-aligned-div {
    display: block;
}

/* Ensure H1 is bigger than H2 in Trix editor */
trix-editor h1,
.trix-content h1 {
    font-size: 1.5em !important;
    font-weight: bold !important;
    line-height: 1.2 !important;
    margin-top: 0.67em !important;
    margin-bottom: 0.67em !important;
}

trix-editor h2,
.trix-content h2 {
    font-size: 1em !important;
    font-weight: bold !important;
    line-height: 1.3 !important;
    margin-top: 0.83em !important;
    margin-bottom: 0.83em !important;
}

/* Remove margin-bottom from toolbar */
trix-toolbar,
.trix-toolbar,
.trix-button-row {
    margin-bottom: 0 !important;
    padding-bottom: 3px !important;
}

/* Remove margin-bottom from all spans inside trix-button-row */
.trix-button-row > span {
    margin-bottom: 0 !important;
}

/* Remove margin-bottom and borders from heading dropdown wrapper div */
.trix-button-group[data-trix-heading-dropdown] {
    margin-bottom: 0 !important;
    border-bottom-width: 0px !important;
    border-right-width: 0px !important;
    border-top-width: 0px !important;
    border-left-width: 0px !important;
}

/* Make all Trix buttons match the Bold button dimensions */
.trix-button-group .trix-button {
    width: 33px !important;
    height: 31px !important;
    padding-right: 0px !important;
    padding-left: 0px !important;
    border-bottom-width: 0px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Ensure heading dropdown button maintains borders when active/dropdown is open */
.trix-button-group[data-trix-heading-dropdown] .trix-button {
    border-top-width: 1px !important;
    border-left-width: 1px !important;
    border-right-width: 1px !important;
    border-bottom-width: 0px !important;
}

/* Preserve Trix's default active state borders (yellow highlight) - don't override border colors */
.trix-button-group[data-trix-heading-dropdown] .trix-button:active,
.trix-button-group[data-trix-heading-dropdown] .trix-button:focus,
.trix-button-group[data-trix-heading-dropdown] .trix-button.trix-active,
.trix-button-group[data-trix-heading-dropdown] .trix-button:hover {
    border-top-width: 1px !important;
    border-left-width: 1px !important;
    border-right-width: 1px !important;
    border-bottom-width: 0px !important;
    /* Let Trix's default active state border colors (yellow) show through */
}

.trix-button-group .trix-button .icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    line-height: 1 !important;
}

/* Trix default SVG icons */
.trix-button-group .trix-button .icon svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
    max-width: 1.25rem !important;
    max-height: 1.25rem !important;
    display: block !important;
}

/* FontAwesome icons (color buttons) */
.trix-button-group .trix-button .icon i {
    font-size: 1.25rem !important;
    line-height: 1 !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Heading dropdown button text */
.trix-button-group .trix-button .icon span[data-heading-text] {
    font-size: 1rem !important;
    line-height: 1.25rem !important;
    font-weight: 500 !important;
    display: inline-block !important;
}

/* Heading dropdown arrow */
.trix-button-group .trix-button .icon span:not([data-heading-text]) {
    font-size: 0.5rem !important;
    line-height: 1 !important;
}

trix-editor a,
.trix-input-wrapper .trix-content a {
    color: #2563eb;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-decoration-color: #2563eb;
    font-weight: 600;
    transition: color 0.15s ease-in-out;
}

trix-editor a:hover,
.trix-input-wrapper .trix-content a:hover {
    color: #1d4ed8;
    text-decoration-color: #1d4ed8;
}

/* Attachment styling inside Trix editor */
trix-editor figure.attachment,
.trix-input-wrapper .trix-content figure.attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background-color: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0.5rem 0;
    min-width: 0;
}

trix-editor figure.attachment:hover,
.trix-input-wrapper .trix-content figure.attachment:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
    color: #111827;
}

trix-editor figure.attachment::before,
.trix-input-wrapper .trix-content figure.attachment::before {
    content: "📎";
    font-size: 1.25rem;
    margin-right: 0.25rem;
}

trix-editor figure.attachment figcaption,
.trix-input-wrapper .trix-content figure.attachment figcaption {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

trix-editor figure.attachment .attachment__name,
.trix-input-wrapper .trix-content figure.attachment .attachment__name {
    font-weight: 600;
    color: #1f2937;
    display: block;
    word-break: break-word;
}

trix-editor figure.attachment .attachment__size,
.trix-input-wrapper .trix-content figure.attachment .attachment__size {
    font-size: 0.85rem;
    color: #6b7280;
}

trix-editor figure.attachment.attachment--preview::before,
.trix-input-wrapper .trix-content figure.attachment.attachment--preview::before {
    content: none;
}

/* Hide captions (filename/size) for image attachments */
trix-editor figure.attachment[data-trix-content-type^="image/"] figcaption,
.trix-content figure.attachment[data-trix-content-type^="image/"] figcaption,
trix-editor figure.attachment.attachment--jpeg figcaption,
trix-editor figure.attachment.attachment--jpg figcaption,
trix-editor figure.attachment.attachment--png figcaption,
trix-editor figure.attachment.attachment--gif figcaption,
trix-editor figure.attachment.attachment--svg figcaption,
.trix-content figure.attachment.attachment--jpeg figcaption,
.trix-content figure.attachment.attachment--jpg figcaption,
.trix-content figure.attachment.attachment--png figcaption,
.trix-content figure.attachment.attachment--gif figcaption,
.trix-content figure.attachment.attachment--svg figcaption {
    display: none !important;
}

/* Hide filename and size spans for images */
trix-editor figure.attachment[data-trix-content-type^="image/"] .attachment__name,
trix-editor figure.attachment[data-trix-content-type^="image/"] .attachment__size,
.trix-content figure.attachment[data-trix-content-type^="image/"] .attachment__name,
.trix-content figure.attachment[data-trix-content-type^="image/"] .attachment__size {
    display: none !important;
}

/* Trix attachment button is now enabled - images only */
/* Change attachment button icon from clip to image icon - OVERRIDE TRIX'S ::before background-image */
/* MUST be more specific than Trix's .trix-button--icon-attach::before rule */
trix-toolbar .trix-button-group .trix-button.trix-button--icon.trix-button--icon-attach::before,
trix-toolbar .trix-button-group button.trix-button.trix-button--icon.trix-button--icon-attach::before,
trix-toolbar button.trix-button.trix-button--icon.trix-button--icon-attach[data-trix-action="attachFiles"]::before,
trix-toolbar button[data-trix-action="attachFiles"].trix-button--icon-attach::before,
trix-toolbar .trix-button.trix-button--icon.trix-button--icon-attach::before,
trix-toolbar .trix-button--icon-attach::before {
    /* CRITICAL: Remove the paperclip SVG background-image */
    background-image: none !important;
    /* Use FontAwesome image icon instead */
    content: "\f03e" !important; /* FontAwesome fa-image icon (Unicode: f03e) */
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    font-style: normal !important;
    display: inline-block !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    right: auto !important;
    bottom: auto !important;
    font-size: 1rem !important;
    line-height: 1 !important;
    opacity: 0.6 !important;
    color: #000 !important;
    text-indent: 0 !important;
    text-align: center !important;
    width: auto !important;
    height: auto !important;
}

/* Center alignment icons (left, center, right) within their button space */
trix-toolbar .trix-button[data-trix-attribute="textAlignLeft"],
trix-toolbar .trix-button[data-trix-attribute="textAlignCenter"],
trix-toolbar .trix-button[data-trix-attribute="textAlignRight"],
trix-toolbar .trix-button[data-trix-align-left],
trix-toolbar .trix-button[data-trix-align-center],
trix-toolbar .trix-button[data-trix-align-right] {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

trix-toolbar .trix-button[data-trix-attribute="textAlignLeft"] .icon,
trix-toolbar .trix-button[data-trix-attribute="textAlignCenter"] .icon,
trix-toolbar .trix-button[data-trix-attribute="textAlignRight"] .icon,
trix-toolbar .trix-button[data-trix-align-left] .icon,
trix-toolbar .trix-button[data-trix-align-center] .icon,
trix-toolbar .trix-button[data-trix-align-right] .icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
    height: auto !important;
}

trix-toolbar .trix-button[data-trix-attribute="textAlignLeft"] .icon i,
trix-toolbar .trix-button[data-trix-attribute="textAlignCenter"] .icon i,
trix-toolbar .trix-button[data-trix-attribute="textAlignRight"] .icon i,
trix-toolbar .trix-button[data-trix-align-left] .icon i,
trix-toolbar .trix-button[data-trix-align-center] .icon i,
trix-toolbar .trix-button[data-trix-align-right] .icon i {
    display: inline-block !important;
    margin: 0 !important;
}

/* Center color picker icons (foreground and background color) and remove duplicate icons BEHIND them */
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"],
trix-toolbar .trix-button[data-trix-color-picker="background-btn"],
trix-toolbar button[data-trix-color-picker="foreground-btn"],
trix-toolbar button[data-trix-color-picker="background-btn"] {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Remove trix-button--icon class styling if it exists */
trix-toolbar .trix-button.trix-button--icon[data-trix-color-picker="foreground-btn"],
trix-toolbar .trix-button.trix-button--icon[data-trix-color-picker="background-btn"] {
    width: auto !important;
    height: auto !important;
}

/* Ensure color picker buttons are visible */
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"],
trix-toolbar .trix-button[data-trix-color-picker="background-btn"] {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
}

/* Center the FontAwesome icon */
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"] .icon,
trix-toolbar .trix-button[data-trix-color-picker="background-btn"] .icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"] .icon i,
trix-toolbar .trix-button[data-trix-color-picker="background-btn"] .icon i {
    display: inline-block !important;
    margin: 0 !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 3 !important;
    font-size: 1rem !important;
    color: rgba(0, 0, 0, 0.6) !important;
}

/* ONLY hide the duplicate ::before pseudo-elements (the icons BEHIND) - ULTRA AGGRESSIVE */
/* Use universal selector FIRST to catch ANY element with these data attributes */
trix-toolbar [data-trix-color-picker="foreground-btn"]::before,
trix-toolbar [data-trix-color-picker="background-btn"]::before,
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"]::before,
trix-toolbar .trix-button[data-trix-color-picker="background-btn"]::before,
trix-toolbar .trix-button.trix-button--icon[data-trix-color-picker="foreground-btn"]::before,
trix-toolbar .trix-button.trix-button--icon[data-trix-color-picker="background-btn"]::before,
trix-toolbar button[data-trix-color-picker="foreground-btn"]::before,
trix-toolbar button[data-trix-color-picker="background-btn"]::before,
trix-toolbar .trix-button-group .trix-button[data-trix-color-picker="foreground-btn"]::before,
trix-toolbar .trix-button-group .trix-button[data-trix-color-picker="background-btn"]::before,
trix-toolbar .trix-button-group button[data-trix-color-picker="foreground-btn"]::before,
trix-toolbar .trix-button-group button[data-trix-color-picker="background-btn"]::before,
trix-toolbar button.trix-button[data-trix-color-picker="foreground-btn"]::before,
trix-toolbar button.trix-button[data-trix-color-picker="background-btn"]::before,
trix-toolbar button.trix-button.trix-button--icon[data-trix-color-picker="foreground-btn"]::before,
trix-toolbar button.trix-button.trix-button--icon[data-trix-color-picker="background-btn"]::before {
    display: none !important;
    content: "" !important;
    background-image: none !important;
    background: none !important;
    background-color: transparent !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 0 !important;
    max-height: 0 !important;
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
    pointer-events: none !important;
    overflow: hidden !important;
    clip-path: inset(100%) !important;
}

/* CRITICAL: Override Trix's general .trix-button--icon::before rule for color picker buttons */
/* This must come after all other rules to ensure it takes precedence */
trix-toolbar [data-trix-color-picker="foreground-btn"].trix-button--icon::before,
trix-toolbar [data-trix-color-picker="background-btn"].trix-button--icon::before {
    display: none !important;
    content: "" !important;
    background-image: none !important;
    background: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

/* Hide ::after pseudo-elements if they exist */
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"]::after,
trix-toolbar .trix-button[data-trix-color-picker="background-btn"]::after,
trix-toolbar button[data-trix-color-picker="foreground-btn"]::after,
trix-toolbar button[data-trix-color-picker="background-btn"]::after,
trix-toolbar .trix-button-group .trix-button[data-trix-color-picker="foreground-btn"]::after,
trix-toolbar .trix-button-group .trix-button[data-trix-color-picker="background-btn"]::after {
    display: none !important;
    content: "" !important;
    background-image: none !important;
    background: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Also hide any pseudo-elements on the icon span itself */
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"] .icon::before,
trix-toolbar .trix-button[data-trix-color-picker="background-btn"] .icon::before,
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"] .icon::after,
trix-toolbar .trix-button[data-trix-color-picker="background-btn"] .icon::after {
    display: none !important;
    content: "" !important;
    background-image: none !important;
    background: none !important;
}

/* Hide any SVG elements that might be showing as duplicates */
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"] svg,
trix-toolbar .trix-button[data-trix-color-picker="background-btn"] svg,
trix-toolbar button[data-trix-color-picker="foreground-btn"] svg,
trix-toolbar button[data-trix-color-picker="background-btn"] svg {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

/* Hide any text nodes or other content that might be showing */
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"] > *:not(.icon),
trix-toolbar .trix-button[data-trix-color-picker="background-btn"] > *:not(.icon) {
    display: none !important;
}

/* Ensure only the FontAwesome icon inside .icon is visible */
trix-toolbar .trix-button[data-trix-color-picker="foreground-btn"] .icon > *:not(i),
trix-toolbar .trix-button[data-trix-color-picker="background-btn"] .icon > *:not(i) {
    display: none !important;
}