/* ========================================
   VIDEO BBCODE - RESPONSIVE EMBED
======================================== */

.bb-youtube,
.bb-facebook {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 22px auto;
    overflow: hidden;
    background: #111;
    border-radius: 14px;
    border: 1px solid rgba(128, 128, 128, 0.16);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.10);
    isolation: isolate;
    transition: box-shadow .25s ease, transform .25s ease;
}

/* Iframe video */
.bb-youtube iframe,
.bb-facebook iframe {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: inherit;
}

/* Hover effect */
@media (hover: hover) {
    .bb-youtube:hover,
    .bb-facebook:hover {
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.17);
        transform: translateY(-2px);
    }
}

/* Mobile */
@media (max-width: 600px) {
    .bb-youtube,
    .bb-facebook {
        margin: 16px auto;
        border-radius: 10px;
    }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .bb-youtube,
    .bb-facebook {
        border-color: rgba(255, 255, 255, 0.10);
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
    }
}

/* Fallback for old browsers */
@supports not (aspect-ratio: 16 / 9) {
    .bb-youtube,
    .bb-facebook {
        height: 0;
        padding-bottom: 56.25%;
    }
}



/* ========================================
   BBCode IMAGE - COMPACT STYLE
======================================== */

.bb-img {
    display: block;

    /* Giới hạn kích thước */
    width: auto;
    max-width: min(100%, 600px);
    max-height: 650px;
    height: auto;

    /* Căn giữa */
    margin: 18px auto;

    /* Giữ tỷ lệ ảnh gốc */
    object-fit: contain;

    /* Giao diện */
    border-radius: 10px;
    border: 1px solid rgba(128, 128, 128, 0.15);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);

    box-sizing: border-box;
    transition: transform .25s ease, box-shadow .25s ease;
}

/* Máy tính */
@media (min-width: 768px) {
    .bb-img {
        max-width: min(100%, 600px);
    }
}

/* Điện thoại */
@media (max-width: 767px) {
    .bb-img {
        max-width: 85%;
        max-height: 500px;
        border-radius: 8px;
        margin: 15px auto;
    }
}

/* Hover */
@media (hover: hover) and (pointer: fine) {
    .bb-img:hover {
        transform: scale(1.015);
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.13);
    }
}



/* ========================================
   BBCode NÚT BẤM - COMPACT STYLE
======================================== */
.bb-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    background: var(--card-bg, #fff);
}

.bb-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    padding-right: 9px;
    margin-right: 2px;
    border-right: 1px solid var(--border-color, #e2e8f0);
}

.bb-toolbar-group:last-child {
    padding-right: 0;
    border-right: 0;
}

.bb-toolbar button {
    min-width: 34px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 7px;
    background: var(--surface-bg, #f8fafc);
    color: var(--text-color, #334155);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, border-color .2s, color .2s;
}

.bb-toolbar button:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.bb-toolbar button:active {
    transform: scale(.96);
}

@media (max-width: 600px) {
    .bb-toolbar {
        gap: 6px;
        padding: 8px;
    }

    .bb-toolbar-group {
        padding-right: 0;
        margin-right: 0;
        border-right: 0;
    }

    .bb-toolbar button {
        min-height: 36px;
        padding: 7px 9px;
    }
}
/* =========================
   BBCODE BLOCK (CODE & PHP)
========================= */
.post-body .bb-code {
    position: relative;
    background: #0f172a;
    color: #e2e8f0;
    padding: 36px 16px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin: 16px 0;
    overflow-x: auto;
    font-family: 'Fira Code', 'JetBrains Mono', Consolas, Monaco, monospace;
    font-size: 13.5px;
    line-height: 1.65;
    tab-size: 4;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.post-body .bb-code code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    white-space: pre;
    display: block;
}

/* Thanh nhãn ngôn ngữ tự động từ data-lang */
.post-body .bb-code::before {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
    border-radius: 12px 12px 0 0;
}

/* Tùy chỉnh riêng cho data-lang="code" */
.post-body .bb-code[data-lang="code"] {
    border-left: 3px solid #3b82f6;
}
.post-body .bb-code[data-lang="code"]::before {
    color: #60a5fa;
}

/* Tùy chỉnh riêng cho data-lang="php" */
.post-body .bb-code[data-lang="php"] {
    border-left: 3px solid #8b5cf6;
}
.post-body .bb-code[data-lang="php"]::before {
    color: #a78bfa;
}

/* Thanh cuộn ngang gọn gàng */
.post-body .bb-code::-webkit-scrollbar {
    height: 6px;
}
.post-body .bb-code::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 0 0 12px 12px;
}
.post-body .bb-code::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 999px;
}
.post-body .bb-code::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Mobile */
@media (max-width: 768px) {
    .post-body .bb-code {
        font-size: 13px;
        padding: 34px 12px 14px;
        border-radius: 10px; 
    }
}
