/* RichText Editor Scoped Styles */
.richtext-editor-content,
body.richtext-editor-content {
    margin: 0;
    padding: 8px;
    min-height: 200px;
    font-family: var(--bgl-font);
    line-height: 1.5;
    color: inherit;
    background: transparent;
    max-width: 1060px;
    margin: 0 auto;
}

/* Fallback styles for iframe body */
body {
    margin: 0;
    padding: 8px;
    min-height: 200px;
    font-family: var(--bgl-font);
    line-height: 1.5;
    color: inherit;
    background: transparent;
    max-width: 1060px;
    margin: 0 auto;
}

.richtext-editor-content table,
body.richtext-editor-content table {
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.richtext-editor-content th,
.richtext-editor-content td,
body.richtext-editor-content th,
body.richtext-editor-content td {
    padding: 1rem;
    border: 1px solid #2a2a2a;
    line-height: 1.5;
    text-align: unset;
}

.richtext-editor-content th,
body.richtext-editor-content th {
    background-color: #f4f4f4;
}

/* Fallback table styles */
table {
    border-collapse: collapse;
    margin-bottom: 1rem;
}

th,
td {
    padding: 1rem;
    border: 1px solid #2a2a2a;
    line-height: 1.5;
    text-align: unset;
}

th {
    background-color: #f4f4f4;
}

/* Add styles for embedded content */
.richtext-editor-content iframe {
    max-width: 100%;
    border: 1px solid var(--bgl-border-color, #ddd);
    border-radius: 8px;
    display: block;
    margin: 1em auto;
    min-height: 200px;
    background: white;
}

/* Video placeholder styles */
.richtext-editor-content .video-placeholder {
    width: 100%;
    height: auto;
    min-height: 50px;
    background-color: var(--bgl-gray-20);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
    overflow: hidden;
}

.richtext-editor-content .video-placeholder.has-thumbnail {
    position: relative;
}

.richtext-editor-content .video-placeholder-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.7;
}

.richtext-editor-content .video-placeholder-description {
    text-align: center;
}

.richtext-editor-content .video-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    position: absolute;
    top: 0;
    left: 0;
}

.richtext-editor-content .video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;

}

.richtext-editor-content .video-overlay-icon::after {
    content: "▶";
    font-size: 50px;
    color: white;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));

}

/* Video container styles */
.richtext-editor-content .video-container {
    width: 100%;
    height: auto;
}

/* Embed iframe styles */
.richtext-editor-content .embed-iframe {
    width: 100%;
    height: 315px;
    border: 1px solid var(--bgl-border-color, #ddd);
    border-radius: 8px;
    background: white;
}

.richtext-editor-content .embed-iframe.responsive {
    aspect-ratio: 16/9;
    height: auto;
}

/* Image figure styles */
.richtext-editor-content .image-figure {
    margin: 2rem auto;
    text-align: end;
    max-width: 100%;
    cursor: pointer;
    transition: var(--bgl-transition);
}

.richtext-editor-content .image-figure:hover {
    filter: var(--bgl-hover-filter);
}

.richtext-editor-content .image-figure:active {
    filter: var(--bgl-active-filter);
}

.richtext-editor-content .image-figure img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    pointer-events: none;
}

.richtext-editor-content .image-figure figcaption {
    margin-top: 0.5rem;
    font-size: 0.9em;
    padding: 0 1rem;
    pointer-events: none;
    text-align: center;
    line-height: 1.4;
}

.richtext-editor-content .image-figure figcaption .alt-text {
    font-weight: 400;
    color: inherit;
}

.richtext-editor-content .image-figure figcaption .photo-credit {
    font-weight: 100;
    opacity: 0.8;
}

/* Responsive iframe wrapper */
.richtext-editor-content div:has(> iframe) {
    position: relative;
    width: 100%;
    margin: 1em 0;
    text-align: center;
}

/* Ensure iframes don't overflow their containers */
.richtext-editor-content div:has(> iframe) iframe {
    max-width: 100%;
    margin: 0;
}

/* Add a subtle border to distinguish embedded content */
.richtext-editor-content iframe:not([class*='editableContent']) {
    border: 1px solid var(--bgl-border-color);
    border-radius: 4px;
    background: white;
}

/* Video figure styles */
.richtext-editor-content .video-figure {
    margin: 2rem auto;
    text-align: center;
    max-width: 100%;
    cursor: pointer;
    transition: var(--bgl-transition);
}

.richtext-editor-content .video-figure:hover {
    filter: var(--bgl-hover-filter);
}

.richtext-editor-content .video-figure:active {
    filter: var(--bgl-active-filter);
}

.richtext-editor-content .video-figure .video-container {
    display: block;
    max-width: 100%;
    margin: 0 auto;
}

.richtext-editor-content .video-figure .bgl_vid {
    width: 100%;
    margin: 0 auto;
}

.richtext-editor-content .video-figure .bgl_vid.vid_short {
    max-width: 56.25vh;
    margin: 0 auto;
}

.richtext-editor-content .video-figure .bgl_vid iframe,
.richtext-editor-content .video-figure .bgl_vid video,
.richtext-editor-content .video-figure .bgl_vid .video-placeholder {
    width: 100%;
    height: auto;
    display: block;
    margin: auto;
    border-radius: 8px;
    overflow: hidden;
}

/* Video placeholder specific styles */
.richtext-editor-content .video-figure .bgl_vid .video-placeholder {
    transition: all 0.2s ease;
}

.richtext-editor-content .video-figure:hover .bgl_vid .video-placeholder {
    filter: var(--bgl-hover-filter);
}

.richtext-editor-content .video-figure .bgl_vid .video-placeholder img {
    pointer-events: none;
}

.richtext-editor-content .video-figure figcaption {
    margin-top: 0.5rem;
    font-size: 0.9em;
    padding: 0 1rem;
    color: inherit;
    text-align: center;
}

/* Embed figure styles */
.richtext-editor-content .embed-figure {
    margin: 2rem auto;
    text-align: center;
    max-width: 100%;
    cursor: pointer;
    transition: var(--bgl-transition);
}

.richtext-editor-content .embed-figure:hover {
    filter: var(--bgl-hover-filter);
}

.richtext-editor-content .embed-figure:active {
    filter: var(--bgl-active-filter);
}

.richtext-editor-content .embed-figure iframe {
    display: block;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    border: 1px solid var(--bgl-border-color, #ddd);
    border-radius: 8px;
    background: white;
    transition: var(--bgl-transition);
    pointer-events: none;
}

.richtext-editor-content .embed-figure:hover iframe {
    box-shadow: 0 4px 12px var(--bgl-shadow);
}

.richtext-editor-content .embed-figure figcaption {
    margin-top: 0.5rem;
    font-size: 0.9em;
    padding: 0 1rem;
    color: inherit;
    text-align: center;
}