/* Đảm bảo video/iframe trong content hiển thị đúng trong grid */
.detail-content iframe,
.detail-content video,
.detail-content embed,
.detail-content object {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 12px auto !important;
}

/* Đảm bảo video có aspect ratio 16:9 */
.detail-content iframe[src*="youtube"],
.detail-content iframe[src*="youtu.be"],
.detail-content iframe[src*="vimeo"],
.detail-content iframe[src*="dailymotion"],
.detail-content iframe[src*="facebook"],
.detail-content iframe {
    aspect-ratio: 16 / 9;
    height: auto !important;
}

/* Đảm bảo container của video không tràn ra ngoài */
.detail-content p:has(iframe),
.detail-content p:has(video),
.detail-content div:has(iframe),
.detail-content div:has(video),
.detail-content figure:has(iframe),
.detail-content figure:has(video) {
    max-width: 100% !important;
    width: 100% !important;
    margin: 12px 0 !important;
    overflow: hidden !important;
}

/* Fallback cho trình duyệt không hỗ trợ :has() */
.detail-content .video-wrapper,
.detail-content .embed-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 12px auto;
}

.detail-content .video-wrapper iframe,
.detail-content .video-wrapper video,
.detail-content .embed-wrapper iframe,
.detail-content .embed-wrapper embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.detail-content table img {
    max-width: 100%;
}

/* Đảm bảo figure không tràn ra ngoài */
.detail-content figure.image_resized {
    max-width: 100% !important;
    display: block;
    box-sizing: border-box;
}

/* Drop Cap - Chữ cái đầu lớn */
.detail-content .drop-cap::first-letter{
    float: left;
    font-size: 4em;
    line-height: 0.8;
    margin: 0.1em 0.15em 0 0;
    font-weight: bold;
    color: inherit;
}

/* Lead Paragraph - Đoạn dẫn */
.detail-content .lead-paragraph{
    font-size: 1.25em;
    font-weight: 500;
    color: #374151;
    border-left: 4px solid #3b82f6;
    padding-left: 1em;
    margin: 1.5em 0;
}

/* Pull Quote - Quote nổi bật */
.detail-content .pull-quote{
    font-size: 1.5em;
    font-style: italic;
    text-align: center;
    color: #1e40af;
    border: none;
    padding: 1.5em 2em;
    margin: 2em auto;
    max-width: 80%;
    position: relative;
    background: #f8fafc;
    border-radius: 8px;
}

.detail-content .pull-quote::before{
    content: '"';
    font-size: 3em;
    position: absolute;
    top: -0.1em;
    left: 0.2em;
    color: #dbeafe;
    font-family: serif;
}

.detail-content .pull-quote::after{
  content: '❞';
  font-size: 2.5em;
  position: absolute;
  bottom: -0.1em;
  right: 0.2em;
  color: #8ca9cf;
  font-family: serif;
}

/* Highlight Box */
.detail-content .highlight-box{
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 8px;
    padding: 1.5em;
    margin: 1.5em 0;
    border-left: 4px solid #f59e0b;
}

/* Two Columns Layout */
.detail-content .two-columns {
    column-count: 2;
    column-gap: 2em;
    column-rule: 2px solid #e5e7eb;
    background: #f8fafc;
    padding: 1.5em;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Three Columns Layout */
.detail-content .three-columns {
    column-count: 3;
    column-gap: 1.5em;
    column-rule: 2px solid #e5e7eb;
    background: #f8fafc;
    padding: 1.5em;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

@media (max-width: 768px) {

    .detail-content .three-columns,
    .detail-content .two-columns {
        column-count: 1;
    }
}

/* Image Caption */
.detail-content .image-caption {
    font-size: 0.875em;
    color: #6b7280;
    text-align: center;
    font-style: italic;
    margin-top: 0.5em;
}

/* Số liệu nổi bật - Dùng cho các con số ấn tượng */
.detail-content .stat-number {
    text-align: center;
    padding: 2em 1.5em;
    margin: 2em 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    color: #ffffff;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
}

.detail-content .stat-number strong,
.detail-content .stat-number b {
    display: block;
    font-size: 3.5em;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.1em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.detail-content .stat-number p {
    margin: 0;
    font-size: 1.1em;
    opacity: 0.9;
}

/* Dấu phân cách trang trí */
.detail-content .section-divider {
    text-align: center;
    margin: 2em 0;
    display: flex;
    align-items: center;
    gap: 1em;
}

.detail-content .section-divider::before,
.detail-content .section-divider::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, transparent, #3b82f6, #8b5cf6);
}

.detail-content .section-divider::after {
    background: linear-gradient(90deg, #8b5cf6, #3b82f6, transparent);
}

/* Hộp kết luận */
.detail-content .conclusion-box {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #f1f5f9;
    padding: 2em;
    border-radius: 16px;
    margin: 2em 0;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.detail-content .conclusion-box::before {
    content: '📌 KẾT LUẬN';
    display: block;
    font-weight: 700;
    font-size: 0.85em;
    letter-spacing: 0.1em;
    color: #fbbf24;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.detail-content .conclusion-box p {
    margin: 0;
    line-height: 1.8;
}

/* Đoạn nhấn mạnh */
.detail-content .emphasis-paragraph {
    font-size: 1.15em;
    font-weight: 500;
    color: #1e40af;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    padding: 1.25em 1.5em;
    border-radius: 12px;
    margin: 1.5em 0;
    border-left: 4px solid #3b82f6;
    position: relative;
}

.detail-content .emphasis-paragraph::before {
    content: '💡';
    position: absolute;
    left: 12px;
    top: -10px;
    font-size: 1.3em;
    background: white;
    border-radius: 50%;
    padding: 2px 4px;
}

/* ==========================================================================
   BASE CONTENT STYLES
   ========================================================================== */

.detail-content .category {
    font-weight: bold;
    color: #ef4444;
    text-transform: uppercase;
    font-size: 0.9em;
}

.detail-content .document-title {
    font-size: 2.25em;
    font-weight: 800;
    margin-bottom: 0.5em;
    color: #111827;
    line-height: 1.2;
}

.detail-content .document-subtitle {
    font-size: 1.5em;
    font-weight: 600;
    color: #4b5563;
    margin-top: 0.5em;
}

.detail-content .info-box {
    position: relative;
    background: linear-gradient(-45deg, transparent 24px, #f3f4f6 24.2px);
    border-radius: 6px;
    border-bottom-right-radius: 0;
    padding: 1.25em 1.5em;
    margin: 1.5em 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
    color: #374151;
}

.detail-content .info-box::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    width: 34px;
    height: 34px;
    background: linear-gradient(to bottom right, #d1d5db 0%, #e5e7eb 45%, transparent 50%);
    border-top-left-radius: 4px;
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.04);
}

.detail-content .side-quote {
    border-left: 4px solid #3b82f6;
    padding-left: 1.25em;
    font-style: italic;
    color: #4b5563;
    margin: 1.5em 0;
}

/* ==========================================================================
   FIX FIGURE & IMAGE STYLES
   ========================================================================== */

.detail-content figure {
    display: table;
    clear: both;
    text-align: center;
    margin: 1em auto;
    min-width: 50px;

    position: relative;
    z-index: 2;
}

.detail-content figure.image-style-block-align-left {
    margin-left: 0;
    margin-right: auto;
}

.detail-content figure.image-style-block-align-right {
    margin-left: auto;
    margin-right: 0;
}

.detail-content figure.image-style-align-left {
    float: left;
    margin-right: 2em;
}

.detail-content figure.image-style-align-right {
    float: right;
    margin-left: 2em;
}

.detail-content figure>figcaption {
    display: block;
    font-size: 0.8em;
    min-height: 1.5em !important;
    max-height: 100px !important;
    height: auto !important;
    color: #6b7280;
    text-align: center;
    font-style: italic;

    caption-side: bottom;
    word-break: break-word;
    padding: 0.6em;
    outline-offset: -1px;
}

.detail-content figure:not(:has(img))>figcaption {
    color: unset;
    font-size: unset;
    font-style: normal;
    text-align: justify;
    text-decoration: unset;
    padding: 0;
}

.detail-content figure.image_resized img {
    width: 100%;
}

.detail-content figure img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    min-width: 100%;
    height: auto;
}

.detail-content figure.image_resized>figcaption {
    width: 100%;
}

/* ============================================
   IMAGE BLEED - Ảnh tràn viền
   Override overflow và max-width cho phép bleed
   ============================================ */

.detail-content figure.image-bleed {
    /* Override overflow hidden */
    overflow: visible !important;

    /* Phá vỡ container bằng margin âm */
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;

    /* Kéo giãn bằng viewport width */
    width: 100vw !important;
    max-width: 100vw !important;

    box-sizing: border-box;
}

.detail-content figure.image-bleed img {
    width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   ARTICLE BACKGROUND BLEED - Nền tràn viền
   Màu nền phủ toàn chiều rộng màn hình
   ============================================ */

.longform .detail-content [data-article-bg],
.longform .detail-content article[style*="background-color"],
.longform .detail-content > div[style*="background-color"] {
    position: relative;
    z-index: 1; /* Cần thiết để z-index:-1 của ::before không bị chìm xuống dưới container cha */
}

.longform .detail-content [data-article-bg]::before,
.longform .detail-content article[style*="background-color"]::before,
.longform .detail-content > div[style*="background-color"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc(50% - 50vw);
    width: 100vw;
    height: 100%;
    background-color: inherit;
    z-index: -1;
    pointer-events: none;
}
