/* Make TinyMCE tables responsive and prevent overflow */
/* Issue #322: Tables must be contained within their parent container */
/* Issue #337: CMS content with Bootstrap rows must not overflow */

/* The container itself must enforce boundaries */
.cms-content {
    max-width: 100%;
    overflow-x: auto;
    /* Allow horizontal scroll if absolutely necessary */
    overflow-wrap: break-word;
    word-wrap: break-word;
    box-sizing: border-box;
}

/* Issue #337: Bootstrap rows in CMS content have negative margins that cause overflow */
.cms-content>.row,
.cms-content .row {
    margin-left: 0;
    margin-right: 0;
}

/* Force all tables to respect container width */
.cms-content table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    /* Override any min-width set by TinyMCE */
    table-layout: fixed !important;
    /* Fixed layout respects width constraints */
    word-break: break-word;
    box-sizing: border-box;
    border-collapse: collapse;
}

/* Table cells must wrap text and respect boundaries */
.cms-content td,
.cms-content th {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal !important;
    max-width: 100%;
    box-sizing: border-box;
}

/* Prevent any inline styles from overriding our constraints */
.cms-content table[style],
.cms-content td[style],
.cms-content th[style] {
    max-width: 100% !important;
}

/* Images must also respect container bounds */
.cms-content img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Embedded iframes and media */
.cms-content iframe,
.cms-content embed,
.cms-content object,
.cms-content video {
    max-width: 100%;
}

/* Most media should scale height automatically */
.cms-content embed,
.cms-content object,
.cms-content video {
    height: auto;
}

/* PDF iframes need fixed height to display properly */
/* Don't override height for PDF containers */
.cms-content .pdf-container iframe {
    min-height: 600px;
    /* Ensure minimum height for PDFs; actual height is set via inline style */
}

/* Pre and code blocks */
.cms-content pre,
.cms-content code {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}
