/**
 * Blog Giza - Main Stylesheet
 */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap');

/* Base Styles */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}


/* body {
    font-family: "Noto Sans", sans-serif;
    font-optical-sizing: auto;
    font-style: normal;
    font-size: 16px;
    list-style: 1.4;
} */

span.carousel-control-prev-icon,
span.carousel-control-next-icon,
.carousel-indicators [data-bs-target] {
    opacity: 0.1;
}


.banner-ads-block {
    margin: 20px auto;
    padding: 20px;
    border-radius: 12px;
    background: #f8f9fa;
    text-align: center;
}
.banner-ads-block img {
    max-width: 650px;
    width: 95%;
    height: auto;
    border-radius: 12px;
}


.banner-ads-block.banner-ads-home,
.banner-ads-block.banner-ads-category {
    margin: 10px auto !important;
    padding: 0 !important;
    background: transparent !important;
}

.container.noidungbaiviet {
    margin: 0 !important;
}


h5.alert-heading.mb-2 {
    margin: 0;
}

/* Banner ads carousel (nhiều banner = slide) */
.banner-ads-block .banner-ads-carousel {
    position: relative;
}
.banner-ads-block .banner-ads-carousel .carousel-indicators {
    margin-bottom: 0.5rem;
}
.banner-ads-block .banner-ads-carousel .carousel-control-prev,
.banner-ads-block .banner-ads-carousel .carousel-control-next {
    width: 40px;
    opacity: 0.8;
}
.banner-ads-block .banner-ads-carousel .carousel-item a,
.banner-ads-block .banner-ads-carousel .carousel-item img {
    border-radius: 12px;
}

@media (min-width: 992px) {
    .container, .container-lg, .container-md, .container-sm {
        width: 95%;
        max-width: 1600px;
    }
}


img.img-fluid.featured-image {
    max-width: 800px;
    width: 100%;
    height: auto;
}

/* Navbar */

.navbar-main {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    background: #0d6efd;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.2);
}

@media (min-width: 992px) {
    .navbar-main {
        position: sticky;
        top: 0;
        z-index: 1030;
    }
}

.navbar-main .navbar-brand {
    font-weight: 700;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.navbar-main .navbar-brand .brand-text {
    font-size: 1.1rem;
}

.navbar-main .nav-link {
    color: rgba(255, 255, 255, 0.88);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.navbar-main .nav-link:hover,
.navbar-main .nav-link:focus,
.navbar-main .nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
}

.navbar-main .nav-item + .nav-item {
    margin-left: 0.15rem;
}

.navbar-main .main-nav-links .nav-link {
    font-weight: 500;
}

.navbar-main .nav-admin-link {
    font-size: 0.9rem;
    opacity: 0.9;
}

.navbar-main .nav-user-toggle {
    padding-right: 0;
}

.navbar-main .dropdown-menu {
    font-size: 0.9rem;
}

.sticky {
    position: sticky;
    top: 0;
}
/* Cards */

.card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

article.card {
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

a:link {
    text-decoration: none;
}

a:visited {}

a:hover {}

a:active {}


/* tu khoa */

.tukhoa {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    line-height: 1.5;
    flex-direction: row;
    flex-wrap: wrap;
}

.tukhoa a {
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    color: gray;
}


/* khac */

h2.card-title {
    font-size: 20px;
    line-height: 1.4;
}

/* CSS cũ cho .noidungbaiviet đã được override bởi CSS mới cho table of contents */

.noidungbaiviet h1 {
    font-size: 24px;
    margin: 15px 0;
    line-height: 1.4;
    position: relative;
    padding-bottom: 10px;
}

.noidungbaiviet h1::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 50px;
    height: 5px;
    /* độ dày của gạch */
    background: #eee;
    /* màu gạch */
}

.noidungbaiviet .codecopy {
    position: relative;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
    overflow-x: auto;
}

.noidungbaiviet .codecopy pre {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre;
    word-wrap: normal;
    overflow-x: auto;
    color: #333;
}


/* Line numbers container */

.noidungbaiviet .codecopy.has-lines {
    display: flex;
    padding: 0;
    overflow: hidden;
}

.noidungbaiviet .codecopy.has-lines .code-lines {
    display: flex;
    flex-direction: column;
    background: #e9ecef;
    border-right: 1px solid #dee2e6;
    padding: 15px 10px;
    user-select: none;
    text-align: right;
    min-width: 50px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #6c757d;
}

.noidungbaiviet .codecopy.has-lines .code-lines .line-number {
    display: block;
    padding: 0;
    margin: 0;
}

.noidungbaiviet .codecopy.has-lines pre {
    flex: 1;
    margin: 0;
    padding: 15px;
    overflow-x: auto;
}

.noidungbaiviet .codecopy .copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s;
    z-index: 10;
}

.noidungbaiviet .codecopy .copy-btn:hover {
    background: #0b5ed7;
}

.noidungbaiviet .codecopy .copy-btn:active {
    background: #0a58ca;
}

.noidungbaiviet .codecopy .copy-btn.copied {
    background: #198754;
}

.noidungbaiviet .codecopy .copy-btn.copied:hover {
    background: #157347;
}

.noidungbaiviet h2,
.noidungbaiviet h3,
.noidungbaiviet h4,
.noidungbaiviet h5,
.noidungbaiviet h6 {
    font-size: 20px;
    margin: 30px 0 10px 0;
    line-height: 1.4;
}

.noidungbaiviet p {
    margin: 10px 0;
    overflow: auto;
}

.noidungbaiviet .chuyenmuc {
    margin-top: 40px;
}

.noidungbaiviet .thongtinthem {
    font-size: 14px;
    color: gray;
}

.noidungbaiviet .thongtinthem a {
    color: gray;
}

.noidungbaiviet hr {
    border: 1px solid #eee;
    margin: 10px 0;
}

/* Admin sidebar */
.admin-sidebar .card {
    border-radius: 14px;
}

.admin-sidebar .card-header {
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
}

.admin-sidebar .list-group-item {
    border: 0;
    border-radius: 0;
    padding: 0.65rem 1rem;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.15s ease, color 0.15s ease, padding-left 0.15s ease, box-shadow 0.15s ease;
}

.admin-sidebar .list-group-item i {
    font-size: 1rem;
}

.admin-sidebar .list-group-item span {
    flex: 1;
}

.admin-sidebar .list-group-item:hover {
    background: #f5f7fb;
    padding-left: 1.15rem;
}

.admin-sidebar .list-group-item.active {
    background: #e7f1ff;
    color: red;
    border-left: 3px solid #0d6efd;
    padding-left: 1.25rem;
    box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.08);
    font-weight: 500;
}

.admin-sidebar .list-group-item.active i {
    filter: brightness(1.1);
}



/* Toast Notification System */

.toast-notification {
    min-width: 300px;
    max-width: 500px;
    margin-bottom: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.toast-notification::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: currentColor;
}

.toast-notification.success {
    color: #155724;
    border-left: 4px solid #28a745;
}

.toast-notification.success .toast-icon {
    color: #28a745;
}

.toast-notification.error {
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.toast-notification.error .toast-icon {
    color: #dc3545;
}

.toast-notification.warning {
    color: #856404;
    border-left: 4px solid #ffc107;
}

.toast-notification.warning .toast-icon {
    color: #ffc107;
}

.toast-notification.info {
    color: #004085;
    border-left: 4px solid #17a2b8;
}

.toast-notification.info .toast-icon {
    color: #17a2b8;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-message {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #343a40;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-notification.hiding {
    animation: slideOutRight 0.3s ease-out forwards;
}

@media (max-width: 576px) {
    #toast-container {
        left: 10px;
        right: 10px;
        top: 10px;
    }
    .toast-notification {
        min-width: auto;
        max-width: 100%;
    }
}


/* Expired Promotion Banner */

.alert-expired-promotion {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-left: 5px solid #f39c12;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.2);
}

.alert-expired-promotion .alert-heading {
    color: #856404;
    font-weight: 600;
}

.alert-expired-promotion i {
    color: #f39c12;
}


/* Expired Promotion Visual Effects */

.post-expired .card-img-top,
.post-expired img.featured-image,
.post-expired img.img-fluid,
.post-expired img.imgbv {
    filter: grayscale(100%);
    opacity: 0.7;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

.post-expired .card-title a,
.post-expired .card-title,
.post-expired h1,
.post-expired h2 a,
.post-expired h2,
.post-expired h5.card-title a {
    color: #6c757d !important;
    text-decoration: none;
}

.post-expired .card-title a:hover,
.post-expired h2 a:hover,
.post-expired h5.card-title a:hover {
    color: #495057 !important;
}

.post-expired article {
    opacity: 0.85;
}

.related-post-card.post-expired .related-post-thumb img {
    filter: grayscale(100%);
    opacity: 0.7;
}
.related-post-card.post-expired .related-post-title {
    color: #6c757d !important;
}
.related-post-card.post-expired:hover .related-post-title {
    color: #495057 !important;
}


/* Search Suggestions */

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 2px;
}

.search-suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.search-suggestion-item:last-child {
    border-bottom: none;
}

.search-suggestion-item:hover,
.search-suggestion-item:focus {
    background-color: #f8f9fa;
    outline: none;
}

.search-suggestion-item strong {
    color: #0d6efd;
    font-weight: 600;
}


/* table */

.noidungbaiviet table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 15px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}


/* Header */

.noidungbaiviet table thead th {
    background: #007bff;
    color: #fff;
    padding: 12px;
    text-align: center;
    font-weight: bold;
}


/* Body */

.noidungbaiviet table td,
table th {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid #eee;
}


/* Row Even */

.noidungbaiviet table tbody tr:nth-child(even) {
    background: #f9f9f9;
}


/* Hover */

.noidungbaiviet table tbody tr:hover {
    background: #eaf4ff;
    transition: 0.2s;
}


/* Strong text */

.noidungbaiviet table strong {
    font-weight: 600;
}

.imgbv {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.tittukhoa {
    /* font-size: 18px; */
    background-color: #eee;
    color: gray;
    padding: 5px 10px;
    border-radius: 10px;
    margin: 0 5px;
}

.h1tukhoa {
    font-size: 25px;
    margin: 20px 0;
}

.card-title {
    font-size: 17px;
    line-height: 1.4;
}

/* Index Page - Enhanced Layout */

/* Featured Post Styles */
.featured-post {
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.6s ease-out;
}

.featured-post:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.featured-image-wrapper {
    overflow: hidden;
    position: relative;
    max-height: 400px;
}

.featured-post-img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.featured-post:hover .featured-post-img {
    transform: scale(1.05);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
}

.featured-badge {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Regular Post Cards */
.post-card {
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.6s ease-out;
    height: 100%;
}

.post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.post-image-wrapper {
    overflow: hidden;
    position: relative;
}

.post-image-wrapper .imgbv {
    transition: transform 0.4s ease;
    width: 100%;
}

.post-card:hover .imgbv {
    transform: scale(1.08);
}

.image-overlay-small {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.2) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.post-card:hover .image-overlay-small {
    opacity: 1;
}

.post-badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

/* Expired Badge Overlay */
.expired-badge-overlay {
    z-index: 3;
    pointer-events: none;
}

.expired-badge {
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    animation: pulse-expired 2s ease-in-out infinite;
    backdrop-filter: blur(4px);
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
}

.expired-badge i {
    font-size: 1rem;
}

@keyframes pulse-expired {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
    }
    50% {
        box-shadow: 0 4px 16px rgba(220, 53, 69, 0.6);
    }
}

/* Responsive cho expired badge */
@media (max-width: 768px) {
    .expired-badge {
        font-size: 0.75rem;
        padding: 0.4rem 0.7rem;
    }
    
    .expired-badge i {
        font-size: 0.875rem;
    }
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-card,
.featured-post {
    animation-fill-mode: both;
}

/* Latest Posts Section */
.latest-posts-section {
    animation: fadeInUp 0.6s ease-out;
    margin-bottom: 4rem !important;
}

/* Featured Large Post (Bài viết lớn đầu tiên) */
.featured-large-post {
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.6s ease-out;
    background: #fff;
}

.featured-large-post:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.featured-large-image-wrapper {
    overflow: hidden;
    position: relative;
    width: 100%;
    background: #f8f9fa;
}

.featured-large-img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    transition: transform 0.5s ease;
    display: block;
}

.featured-large-post:hover .featured-large-img {
    transform: scale(1.05);
}

.featured-large-post .card-title {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.featured-large-post .card-title a {
    color: #212529;
    transition: color 0.2s ease;
    text-decoration: none;
    display: block;
}

.featured-large-post .card-title a:hover {
    color: #0d6efd;
}

.featured-large-post .card-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #6c757d;
}

.section-header {
    border-bottom: 3px solid #0d6efd;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-weight: 700;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.75rem;
}

.latest-post-card {
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.6s ease-out;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.latest-post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.latest-post-image-wrapper {
    overflow: hidden;
    position: relative;
    width: 100%;
    background: #f8f9fa;
    flex-shrink: 0;
}

/* Hot Posts Layout 2 - 2 bài lớn cạnh nhau */
.hot-layout2-card {
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
}
.hot-layout2-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}
.hot-layout2-card .hot-layout2-image-wrapper {
    overflow: hidden;
    position: relative;
    width: 100%;
    background: #f8f9fa;
}
.hot-layout2-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.hot-layout2-card:hover .hot-layout2-img {
    transform: scale(1.05);
}

/* Hot Posts Layout 3 - Lưới đều */
.hot-layout3-card .latest-post-image-wrapper {
    flex-shrink: 0;
}
.hot-layout3-card .latest-post-img {
    height: 140px;
}

.latest-post-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    transition: transform 0.5s ease;
    display: block;
}

.latest-post-card:hover .latest-post-img {
    transform: scale(1.1);
}

.latest-post-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.latest-post-card .card-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.latest-post-card .card-title a {
    color: #212529;
    transition: color 0.2s ease;
    text-decoration: none;
    display: block;
}

.latest-post-card .card-title a:hover {
    color: #0d6efd;
}

.latest-post-card .post-meta {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}

.latest-post-card .card-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #6c757d;
    flex: 1;
}

/* Category Section */
.category-section {
    animation: fadeInUp 0.6s ease-out;
    margin-bottom: 3rem !important;
}

.category-header {
    border-bottom: 3px solid #0d6efd;
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
}

.category-header h1,
.category-header h2 {
    font-weight: 700;
    color: #212529;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.category-header h1 a,
.category-header h2 a {
    color: #212529;
    text-decoration: none;
    transition: color 0.2s ease;
}

.category-header h1 a:hover,
.category-header h2 a:hover {
    color: #0d6efd;
}

.category-post-card {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.category-post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.category-post-image-wrapper {
    overflow: hidden;
    position: relative;
    width: 100%;
    background: #f8f9fa;
    flex-shrink: 0;
}

.category-post-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.category-post-card:hover .category-post-img {
    transform: scale(1.08);
}

.category-post-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.75rem !important;
}

.category-post-card .card-title {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    font-weight: 600;
    flex-shrink: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-post-card .card-title a {
    color: #212529;
    transition: color 0.2s ease;
    text-decoration: none;
    display: block;
}

.category-post-card .card-title a:hover {
    color: #0d6efd;
}

.category-post-card .text-muted {
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .category-post-card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 768px) {
    .featured-post-img {
        height: 250px;
    }
    
    .featured-post .card-body {
        padding: 1.5rem !important;
    }
    
    .post-card .card-body {
        padding: 1rem !important;
    }
    
    .featured-large-img {
        height: 300px;
    }
    
    .latest-post-img {
        height: 140px;
    }
    
    .latest-post-card .card-body {
        padding: 0.75rem !important;
    }
    
    .latest-post-card .card-title {
        font-size: 0.85rem;
    }
    
    .featured-large-post .card-title {
        font-size: 1.25rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .category-header h2 {
        font-size: 1.25rem;
    }
    
    .category-post-img {
        height: 140px;
    }
    
    .category-section .row {
        --bs-gutter-y: 1rem;
    }
    
    .category-post-card {
        margin-bottom: 0;
    }
    
    .category-post-card .card-body {
        padding: 0.75rem !important;
    }
}

@media (max-width: 768px) {
    .category-post-card .card-title {
        font-size: 0.85rem;
    }
}

@media (max-width: 576px) {
    .latest-post-img {
        height: 200px;
    }
    
    .category-post-img {
        height: 120px;
    }
    
    .category-post-card .card-title {
        font-size: 0.8rem;
    }
    
    .category-post-card .card-body {
        padding: 0.5rem !important;
    }
}

/* Sidebar Sticky - Chỉ áp dụng cho trang index */
.sidebar-sticky-wrapper {
    position: relative;
    align-self: flex-start;
}

.sidebar-sticky-wrapper > div {
    position: sticky;
    top: 20px;
    z-index: 10;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    transition: top 0.3s ease;
    padding-bottom: 20px;
}

/* Chỉ áp dụng sticky trên desktop */
@media (max-width: 991.98px) {
    .sidebar-sticky-wrapper {
        align-self: stretch;
    }
    
    .sidebar-sticky-wrapper > div {
        position: static;
        max-height: none;
        overflow-y: visible;
        padding-bottom: 0;
    }
}

/* Custom scrollbar cho sidebar khi sticky */
.sidebar-sticky-wrapper > div::-webkit-scrollbar {
    width: 6px;
}

.sidebar-sticky-wrapper > div::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.sidebar-sticky-wrapper > div::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.sidebar-sticky-wrapper > div::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Đảm bảo sidebar không bị overflow trên mobile */
@media (max-width: 991.98px) {
    .sidebar-sticky-wrapper > div::-webkit-scrollbar {
        display: none;
    }
}

/* ============================================
   Table of Contents (Mục lục)
   ============================================ */

/* Container chính - Override CSS cũ */
.noidungbaiviet {
    position: relative;
    margin: 0 auto;
    padding: 0;
}

/* Kịch bản 1: Có mục lục - Container tổng max-width 1800px, 2 cột */
body.has-toc .noidungbaiviet {
    max-width: 1800px;
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 2rem;
    margin-left: auto;
    margin-right: auto;
}

/* Mục lục - Cột trái, max-width 300px, fixed position */
.toc-sidebar-wrapper {
    position: fixed;
    left: 0;
    top: 56px; /* Bắt đầu từ dưới header */
    width: 100%;
    max-width: 400px;
    height: calc(100vh - 56px - 80px); /* Full viewport height trừ header và footer */
    bottom: 80px; /* Kết thúc trước footer */
    overflow: hidden;
    background: #fff;
    /* border-right: 1px solid #dee2e6; */
    z-index: 100;
    box-sizing: border-box;
}

/* Nội dung bài viết - Cột phải, auto width */
body.has-toc .post-content-wrapper {
    flex: 1;
    width: auto;
    min-height: 100vh;
    padding: 1.5rem;
    box-sizing: border-box;
    margin-left: 400px; /* Tránh bị che bởi mục lục */
}

/* Kịch bản 2: Không có mục lục - Container nội dung max-width 1300px, 1 cột */
body:not(.has-toc) .noidungbaiviet {
    max-width: 1300px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

body:not(.has-toc) .post-content-wrapper {
    width: 100%;
    min-height: 100vh;
    padding: 1.5rem;
    box-sizing: border-box;
}

.table-of-contents-sidebar {
    position: relative;
    height: 100%; /* Chiếm 100% height của parent (toc-sidebar-wrapper) */
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    box-sizing: border-box;
}

.table-of-contents-wrapper {
    position: relative;
    height: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.table-of-contents {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1.25rem;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.toc-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #212529;
    display: flex;
    align-items: center;
}

.toc-nav {
    font-size: 0.9rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: 0.5rem;
}

.toc-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #495057;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.toc-link:hover {
    background-color: #e9ecef;
    color: #0d6efd;
    border-left-color: #0d6efd;
    padding-left: 1rem;
}

.toc-link.active {
    background-color: #e7f1ff;
    color: #0d6efd;
    font-weight: 600;
    border-left-color: #0d6efd;
    padding-left: 1rem;
}

.toc-sublist {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
    padding-left: 1rem;
    border-left: 1px solid #dee2e6;
}

.toc-sublist .toc-item {
    margin-bottom: 0.35rem;
}

.toc-sublist .toc-link {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
}

.toc-level-1 .toc-link {
    font-weight: 600;
    font-size: 0.95rem;
}

.toc-level-2 .toc-link {
    font-weight: 500;
}

.toc-level-3 .toc-link,
.toc-level-4 .toc-link,
.toc-level-5 .toc-link,
.toc-level-6 .toc-link {
    font-weight: 400;
    color: #6c757d;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar cho mục lục */
.table-of-contents::-webkit-scrollbar {
    width: 6px;
}

.table-of-contents::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-of-contents::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.table-of-contents::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive - Xử lý mục lục trên tablet và mobile */
@media (max-width: 1199.98px) {
    /* Tablet: Giảm width mục lục */
    .toc-sidebar-wrapper {
        width: 280px;
        max-width: 280px;
    }
    
    body.has-toc .post-content-wrapper {
        margin-left: 280px;
    }
}

@media (max-width: 991.98px) {
    /* Tablet nhỏ và mobile: Mục lục không fixed, hiển thị sau nội dung */
    .table-of-contents {
        position: static;
        height: auto;
        max-height: 400px;
        margin-bottom: 1.5rem;
    }
    
    .table-of-contents-sidebar {
        height: auto;
        min-height: auto;
        padding: 1.5rem 1.5rem 0 1.5rem;
    }
    
    .table-of-contents-wrapper {
        /* margin-bottom: 1.5rem; */
        height: auto;
    }
    
    /* Trên tablet/mobile, mục lục không fixed, hiển thị sau nội dung */
    .toc-sidebar-wrapper {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
        margin-bottom: 2rem;
    }
    
    body.has-toc .noidungbaiviet {
        flex-direction: column;
        max-width: 100%;
        gap: 0;
    }
    
    body.has-toc .post-content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
        order: 1; /* Nội dung hiển thị trước */
    }
    
    body.has-toc .toc-sidebar-wrapper {
        order: 2; /* Mục lục hiển thị sau */
    }
    
    /* Trên mobile, container nội dung full width */
    body:not(.has-toc) .noidungbaiviet {
        max-width: 100%;
    }
}

@media (max-width: 767.98px) {
    /* Mobile: Tối ưu thêm */
    .table-of-contents {
        max-height: 100%;
        padding: 1rem;
    }
    
    .toc-title {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .toc-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
    
    .toc-sidebar-wrapper {
        margin-bottom: 1.5rem;
    }
}

/* ============================================
   Related Posts (Bài viết liên quan)
   ============================================ */
.related-posts-section {
    border-top: 1px solid #e9ecef;
}
.related-posts-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #212529;
}
.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
.related-post-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.related-post-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}
.related-post-card:hover .related-post-title {
    color: #0d6efd;
}
.related-post-thumb {
    position: relative;
    aspect-ratio: 16/10;
    overflow: hidden;
    background: #f1f3f5;
}
.related-post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.related-post-card:hover .related-post-thumb img {
    transform: scale(1.05);
}
.related-post-body {
    padding: 0.75rem 0.85rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.related-post-title {
    font-size: 14px !important;
    font-weight: 500;
    line-height: 1.35;
    color: #212529;
    margin: 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}
.related-post-date {
    font-size: 0.75rem;
    color: #6c757d;
}
.related-post-date i {
    font-size: 0.7rem;
    margin-right: 0.2rem;
}
@media (max-width: 991.98px) {
    .related-posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 575.98px) {
    .related-posts-section {
        margin-top: 2rem !important;
        padding-top: 1.5rem !important;
    }
    .related-posts-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .related-post-body {
        padding: 0.6rem 0.75rem;
    }
    .related-post-title {
        font-size: 0.75rem;
    }
}

/* Animation cho active state */
@keyframes tocHighlight {
    0% {
        background-color: transparent;
    }
    50% {
        background-color: #e7f1ff;
    }
    100% {
        background-color: #e7f1ff;
    }
}

.toc-link.active {
    animation: tocHighlight 0.5s ease;
}




/* Wrapper - dùng class để hỗ trợ nhiều block trên 1 trang */
.code-block-viewer,
#code-block-viewer {
    position: relative;
    background: #0f172a;
    border-radius: 12px;
    border: 1px solid #1e293b;
    padding: 16px 16px 16px 56px; /* chừa chỗ số dòng */
    overflow-x: auto;
    cursor: pointer;
    transition: all .2s ease;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    line-height: 1.6;
  }
  
  /* Hover */
  .code-block-viewer:hover,
#code-block-viewer:hover {
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
  }
  
  /* Nội dung */
  .code-block-viewer .cm-content,
.code-block-viewer pre,
.code-block-viewer code,
#code-block-viewer .cm-content,
#code-block-viewer pre,
#code-block-viewer code {
    color: #e5e7eb;
    white-space: pre;
    counter-reset: line;
  }
  
  /* Mỗi dòng */
  .code-block-viewer .cm-content br,
#code-block-viewer .cm-content br {
    counter-increment: line;
  }
  
  /* Số dòng */
  .code-block-viewer .cm-content,
#code-block-viewer .cm-content {
    position: relative;
  }
  
  .code-block-viewer .cm-content span:first-child,
  #code-block-viewer .cm-content span:first-child {
    counter-increment: line;
  }
  
  .code-block-viewer .line-number,
#code-block-viewer .line-number {
    position: absolute;
    left: 0;
    top: 16px;
    padding-right: 12px;
    width: 40px;
    text-align: right;
    color: #64748b;
    font-size: 14px;
    line-height: 1.6;
    user-select: none;
  }
  
  /* màu keyword */
  .code-block-viewer .ͼs,
#code-block-viewer .ͼs {
    color: #38bdf8;
    font-weight: 600;
  }
  
  .code-block-viewer .ͼu,
#code-block-viewer .ͼu {
    color: #f59e0b;
  }
  
  /* thông báo copy */
  .code-block-viewer .code-copied,
  #code-block-viewer .code-copied {
    position: absolute;
    top: 10px;
    right: 12px;
    background: #22c55e;
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    opacity: 0;
    transform: translateY(-6px);
    transition: all .25s ease;
  }
  
  .code-block-viewer .code-copied.show,
#code-block-viewer .code-copied.show {
    opacity: 1;
    transform: translateY(0);
  }