:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --nav-bg: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --hero-bg: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
    background-color: var(--bg-light);
}

/* Header */
.site-header {
    background: var(--nav-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s ease;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon {
    font-size: 2rem;
    display: inline-block;
}

img.brand-icon {
    height: 32px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.brand-text {
    color: white;
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: all 0.3s ease;
}

.navbar-nav .nav-link:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

.dropdown-menu {
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}

.dropdown-item {
    padding: 0.75rem 1.25rem;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: var(--bg-light);
    color: var(--primary-color);
}

.categories-dropdown {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

.categories-dropdown::-webkit-scrollbar {
    width: 8px;
}

.categories-dropdown::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.categories-dropdown::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 4px;
}

.categories-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Hero Section */
.hero-section {
    background: var(--hero-bg);
    color: white;
    padding: 4rem 0;
    margin-bottom: 3rem;
    transition: background 0.3s ease;
}

.hero-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.95;
    font-weight: 300;
}

/* Section Titles */
.section-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-dark);
    position: relative;
    padding-bottom: 1rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

/* Categories */
.categories-section {
    margin-bottom: 4rem;
}

.category-card {
    display: block;
    background: var(--bg-white);
    border-radius: 1rem;
    padding: 2rem;
    text-decoration: none;
    color: var(--text-dark);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    height: 100%;
    border: 2px solid transparent;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
    color: var(--text-dark);
    text-decoration: none;
}

.category-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.category-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.category-description {
    color: var(--text-light);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.category-count {
    display: inline-block;
    background: var(--bg-light);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Post Cards */
.post-card {
    background: var(--bg-white);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.post-image {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-card:hover .post-image img {
    transform: scale(1.1);
}

.post-category {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.post-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.post-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.reading-time {
    white-space: nowrap;
}

.post-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.post-title a {
    color: var(--text-dark);
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-title a:hover {
    color: var(--primary-color);
}

.post-excerpt {
    color: var(--text-light);
    margin-bottom: 1rem;
    flex-grow: 1;
    font-size: 0.95rem;
    line-height: 1.6;
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.post-author {
    font-size: 0.875rem;
    color: var(--text-light);
}

.post-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    background: var(--bg-light);
    color: var(--primary-color);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tag:hover {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
}

.read-more {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.read-more:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Post Detail */
.post-detail {
    padding: 2rem 0;
}

.breadcrumb {
    background: none;
    padding: 0;
    margin-bottom: 2rem;
    font-size: 0.875rem;
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.post-header {
    margin-bottom: 3rem;
}

.post-detail .post-title {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.post-meta {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
    font-size: 0.95rem;
}

.meta-icon {
    font-size: 1.25rem;
}

.post-image-main {
    width: 100%;
    height: 400px;
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.post-image-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-dark);
}

.post-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.post-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content ul,
.post-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content pre {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.post-content code {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.post-tags-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.post-tags-section h4 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Social Sharing */
.social-sharing {
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: 0.5rem;
}

.social-sharing h5 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.share-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.share-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.share-facebook {
    background: #1877f2;
    color: white;
}

.share-facebook:hover {
    background: #166fe5;
    color: white;
}

.share-twitter {
    background: #1da1f2;
    color: white;
}

.share-twitter:hover {
    background: #1a91da;
    color: white;
}

.share-linkedin {
    background: #0077b5;
    color: white;
}

.share-linkedin:hover {
    background: #006399;
    color: white;
}

.share-copy {
    background: var(--text-light);
    color: white;
}

.share-copy:hover {
    background: var(--text-dark);
    color: white;
}

/* Related Posts */
.related-posts {
    margin-top: 3rem;
}

/* Post Navigation */
.post-navigation {
    display: flex;
    gap: 1rem;
    margin-top: 3rem;
    flex-wrap: wrap;
}

/* Sidebar */
.sidebar {
    padding-left: 2rem;
    display: flex;
    flex-direction: column;
}

.sidebar-widget {
    background: var(--bg-white);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    flex-shrink: 0; /* Không co lại */
}

/* TOC là widget đầu tiên trong sidebar (desktop only) */
@media (min-width: 992px) {
    .sidebar .table-of-contents {
        order: -1; /* Hiển thị đầu tiên */
    }
}

.sidebar-widget h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.category-list {
    list-style: none;
    padding: 0;
}

.category-list li {
    margin-bottom: 0.75rem;
}

.category-list a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-dark);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.category-list a:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.category-icon-small {
    font-size: 1.25rem;
}

.category-count {
    margin-left: auto;
    color: var(--text-light);
    font-size: 0.875rem;
}

.recent-posts {
    list-style: none;
    padding: 0;
}

.recent-posts li {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.recent-posts li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.recent-posts a {
    text-decoration: none;
    color: var(--text-dark);
}

.recent-post-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    transition: color 0.2s ease;
    font-size: 0.95rem;
}

.recent-posts a:hover .recent-post-title {
    color: var(--primary-color);
}

.recent-post-date {
    font-size: 0.875rem;
    color: var(--text-light);
}

.recent-post-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Category Header */
.category-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 3rem 0;
    margin-bottom: 3rem;
}

.category-header-content {
    text-align: center;
}

.category-header-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.category-header-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.category-header-description {
    font-size: 1.25rem;
    opacity: 0.95;
    margin-bottom: 1rem;
}

.category-header-count {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-weight: 600;
}

.category-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-white);
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.category-link:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Tag Header */
.tag-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 3rem 0;
    margin-bottom: 3rem;
}

.tag-header-content {
    text-align: center;
}

.tag-header-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.tag-header-count {
    font-size: 1.25rem;
    opacity: 0.95;
}

/* Tags Search */
.tags-search {
    margin-bottom: 2rem;
}

.tags-search-form {
    max-width: 600px;
}

.tags-search .input-group {
    box-shadow: var(--shadow);
    border-radius: 0.5rem;
    overflow: hidden;
}

.tags-search .input-group-text {
    background: var(--bg-white);
    border: none;
    padding: 0.75rem 1rem;
    color: var(--text-light);
}

.tags-search .form-control {
    border: none;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.tags-search .form-control:focus {
    box-shadow: none;
    border-color: var(--primary-color);
}

.tags-search .form-control:focus + .input-group-text,
.tags-search .form-control:focus ~ .input-group-text {
    border-color: var(--primary-color);
}

.tags-search .btn {
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.tags-search .btn i {
    font-size: 1.1rem;
}

.tags-count {
    font-size: 0.95rem;
}

/* Tags Cloud */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 200px;
}

.tag-cloud-item {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--bg-white);
    color: var(--primary-color);
    border-radius: 2rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.tag-cloud-item:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

/* Archive */
.archive-header {
    margin-bottom: 3rem;
}

.archive-month {
    margin-bottom: 3rem;
}

.archive-month-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-dark);
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

/* Search */
.search-header {
    margin-bottom: 2rem;
}

.search-results-info {
    font-size: 1.1rem;
    color: var(--text-light);
}

.search-form {
    max-width: 600px;
    margin: 0 auto;
}

.search-form .input-group {
    box-shadow: var(--shadow-lg);
    border-radius: 0.5rem;
    overflow: hidden;
}

.search-form .input-group-text {
    background: var(--bg-white);
    border-right: none;
    padding: 0.75rem 1rem;
    color: var(--text-light);
}

.search-form .form-control {
    border-left: none;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
}

.search-form .form-control:focus {
    box-shadow: none;
    border-color: var(--primary-color);
}

.search-form .form-control:focus ~ .input-group-text {
    border-color: var(--primary-color);
}

.search-form .btn {
    padding: 0.75rem 2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-form .btn i {
    font-size: 1.1rem;
}

/* Header Search */
.navbar-search-form {
    min-width: 180px;
    max-width: 280px;
    margin-left: 1rem;
}

.navbar-search-form .input-group {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    border-radius: 1.5rem;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.navbar-search-form .input-group:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.navbar-search-form .input-group:focus-within {
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.navbar-search-input {
    border: none;
    background: transparent;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.navbar-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.navbar-search-form .input-group:focus-within .navbar-search-input {
    color: var(--text-dark);
}

.navbar-search-form .input-group:focus-within .navbar-search-input::placeholder {
    color: var(--text-light);
}

.navbar-search-btn {
    border: none;
    background: transparent;
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.navbar-search-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.navbar-search-form .input-group:focus-within .navbar-search-btn {
    color: var(--text-dark);
}

.navbar-search-form .input-group:focus-within .navbar-search-btn:hover {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.navbar-search-btn i {
    font-size: 1rem;
}

.navbar-search-btn:focus {
    box-shadow: none;
    outline: none;
}

/* Pagination Info */
.pagination-info {
    margin-top: 1rem;
}

.pagination-info p {
    font-size: 0.875rem;
    margin: 0;
}

/* Pagination */
.pagination {
    margin-top: 2rem;
}

.page-link {
    color: var(--primary-color);
    border-color: var(--border-color);
    padding: 0.75rem 1rem;
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.page-link:hover:not(.disabled) {
    color: var(--primary-dark);
    background-color: var(--bg-light);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.page-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.page-item.disabled .page-link {
    color: var(--text-light);
    background-color: var(--bg-light);
    border-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.6;
}

.page-item.disabled .page-link:hover {
    transform: none;
}

/* Footer */
.site-footer {
    background: var(--text-dark);
    color: white;
    padding: 3rem 0 1.5rem;
    margin-top: 5rem;
}

.site-footer h5 {
    font-weight: 700;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.site-footer p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.8;
}

.footer-links {
    list-style: none;
    padding: 0;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: white;
}

.footer-bottom {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }

    .post-detail .post-title {
        font-size: 1.75rem;
    }

    .category-header-title {
        font-size: 2rem;
    }

    .sidebar {
        padding-left: 0;
        margin-top: 3rem;
    }

    .post-image-main {
        height: 250px;
    }

    .post-content {
        font-size: 1rem;
    }

    .post-navigation {
        flex-direction: column;
    }

    .post-navigation .btn {
        width: 100%;
    }

    .share-buttons {
        flex-direction: column;
    }

    .share-btn {
        width: 100%;
        text-align: center;
    }

    .navbar-search-form {
        min-width: auto;
        max-width: 100%;
        width: 100%;
        margin-top: 1rem;
        margin-left: 0;
    }

    .navbar .navbar-collapse {
        margin-top: 1rem;
    }
    
    .navbar-search-form .input-group {
        width: 100%;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .pagination-info {
        font-size: 0.75rem;
    }
}

/* ============================================
   DARK MODE
   ============================================ */
:root[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-dark: #6366f1;
    --secondary-color: #a78bfa;
    --text-dark: #f1f5f9;
    --text-light: #cbd5e1;
    --bg-light: #0f172a;
    --bg-white: #1e293b;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    /* Dark mode nav và hero - gradient tối với accent màu primary */
    --nav-bg: linear-gradient(135deg, #1e293b 0%, #334155 50%, rgba(99, 102, 241, 0.3) 100%);
    --hero-bg: linear-gradient(135deg, #1e293b 0%, #334155 50%, rgba(139, 92, 246, 0.25) 100%);
}

[data-theme="dark"] body {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

[data-theme="dark"] .post-card,
[data-theme="dark"] .category-card,
[data-theme="dark"] .sidebar-widget,
[data-theme="dark"] .card {
    background-color: var(--bg-white);
    border-color: var(--border-color);
    color: var(--text-dark);
}

[data-theme="dark"] .post-content,
[data-theme="dark"] .post-excerpt {
    color: var(--text-light);
}

[data-theme="dark"] .breadcrumb a {
    color: var(--primary-color);
}

[data-theme="dark"] .tag {
    background-color: var(--bg-white);
    color: var(--text-dark);
    border-color: var(--border-color);
}

[data-theme="dark"] .share-btn {
    background-color: var(--bg-white);
    color: var(--text-dark);
    border-color: var(--border-color);
}

[data-theme="dark"] .share-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

[data-theme="dark"] .form-control {
    background-color: var(--bg-white);
    border-color: var(--border-color);
    color: var(--text-dark);
}

[data-theme="dark"] .form-control:focus {
    background-color: var(--bg-white);
    border-color: var(--primary-color);
    color: var(--text-dark);
}

[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-white);
    border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-dark);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--bg-light);
    color: var(--primary-color);
}

[data-theme="dark"] .site-footer {
    background-color: var(--bg-white);
    color: var(--text-light);
    border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .site-footer h5 {
    color: var(--text-dark);
}

[data-theme="dark"] .site-footer a {
    color: var(--text-light);
}

[data-theme="dark"] .site-footer a:hover {
    color: var(--primary-color);
}

[data-theme="dark"] .post-header,
[data-theme="dark"] .post-meta {
    color: var(--text-light);
}

[data-theme="dark"] .post-title a {
    color: var(--text-dark);
}

[data-theme="dark"] .sidebar-widget h3 {
    color: var(--text-dark);
}

[data-theme="dark"] .recent-posts a {
    color: var(--text-dark);
}

[data-theme="dark"] .recent-posts a:hover {
    color: var(--primary-color);
}

[data-theme="dark"] .category-list a {
    color: var(--text-dark);
}

[data-theme="dark"] .category-list a:hover {
    color: var(--primary-color);
}

[data-theme="dark"] .breadcrumb {
    color: var(--text-light);
}

[data-theme="dark"] .breadcrumb span {
    color: var(--text-dark);
}

[data-theme="dark"] .btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

[data-theme="dark"] .btn-outline-primary {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

[data-theme="dark"] .btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Dark mode specific styles for nav and hero */
[data-theme="dark"] .site-header {
    background: var(--nav-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .hero-section {
    background: var(--hero-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

[data-theme="dark"] .hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent 50%);
    pointer-events: none;
}

/* Đảm bảo text trong nav và hero vẫn đọc được trong dark mode */
[data-theme="dark"] .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.95) !important;
}

[data-theme="dark"] .navbar-nav .nav-link:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .hero-title {
    color: #f8fafc;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .hero-subtitle {
    color: #e2e8f0;
    opacity: 0.9;
}

[data-theme="dark"] .brand-text {
    color: white;
}

/* Dark mode search form */
[data-theme="dark"] .navbar-search-input {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

[data-theme="dark"] .navbar-search-input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

[data-theme="dark"] .navbar-search-form .input-group:focus-within .navbar-search-input {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: white !important;
}

[data-theme="dark"] .navbar-search-form .input-group:focus-within .navbar-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

[data-theme="dark"] .navbar-search-btn {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

[data-theme="dark"] .navbar-search-btn:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

[data-theme="dark"] .navbar-search-form .input-group:focus-within .navbar-search-btn {
    color: white !important;
}

[data-theme="dark"] .navbar-search-form .input-group:focus-within .navbar-search-btn:hover {
    background-color: rgba(255, 255, 255, 0.25) !important;
    color: white !important;
}

[data-theme="dark"] .navbar-search-form .input-group {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

[data-theme="dark"] .navbar-search-form .input-group:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

[data-theme="dark"] .navbar-search-form .input-group:focus-within {
    background-color: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
}

/* Dark mode dropdown menu */
[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-dark);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--bg-light);
    color: var(--primary-color);
}

.dark-mode-toggle {
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .dark-mode-toggle {
    border-color: rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   READING PROGRESS BAR
   ============================================ */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    z-index: 9999;
    transition: width 0.1s ease;
}

/* ============================================
   TABLE OF CONTENTS (TOC)
   ============================================ */
.table-of-contents {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: 350px; /* Chiều cao cố định */
}

.table-of-contents.sticky {
    position: relative; /* Không sticky nữa, để các widget khác hiển thị bên dưới */
}

.table-of-contents h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    flex-shrink: 0; /* Không co lại */
}

.table-of-contents ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto; /* Scroll cho danh sách */
    flex: 1; /* Chiếm phần còn lại của chiều cao */
    min-height: 0; /* Quan trọng cho flexbox scroll */
}

.table-of-contents li {
    margin: 0.5rem 0;
}

.table-of-contents a {
    color: var(--text-light);
    text-decoration: none;
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.table-of-contents a:hover {
    color: var(--primary-color);
    background-color: var(--bg-light);
    padding-left: 1rem;
}

.table-of-contents a.active {
    color: var(--primary-color);
    background-color: var(--bg-light);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
    padding-left: 0.75rem;
}

.table-of-contents ul ul {
    margin-left: 1rem;
    margin-top: 0.25rem;
}

.table-of-contents ul ul a {
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
}

[data-theme="dark"] .table-of-contents {
    background-color: var(--bg-white);
    border-color: var(--border-color);
}

[data-theme="dark"] .table-of-contents a {
    color: var(--text-light);
}

[data-theme="dark"] .table-of-contents a:hover,
[data-theme="dark"] .table-of-contents a.active {
    background-color: var(--bg-light);
    color: var(--primary-color);
}

/* ============================================
   CODE BLOCKS & SYNTAX HIGHLIGHTING
   ============================================ */
.post-content pre {
    position: relative;
    background: #2d2d2d;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.post-content pre code {
    color: #ccc;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    display: block;
}

.post-content code:not(pre code) {
    background-color: #f1f5f9;
    color: #dc2626;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

[data-theme="dark"] .post-content code:not(pre code) {
    background-color: #334155;
    color: #f87171;
}

.post-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Prism.js theme adjustments */
[data-theme="dark"] .post-content pre {
    background: #1e1e1e;
}

[data-theme="dark"] .post-content pre code {
    color: #d4d4d4;
}

.code-block-wrapper {
    position: relative;
    margin: 1.5rem 0;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2d2d2d;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem 0.5rem 0 0;
    border: 1px solid #404040;
    border-bottom: none;
}

.code-block-header span {
    color: #aaa;
    font-size: 0.85rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    text-transform: uppercase;
    font-weight: 600;
}

.copy-code-btn {
    background: #404040 !important;
    color: #e2e8f0 !important;
    border: 1px solid #555 !important;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.copy-code-btn:hover {
    background: #555 !important;
    border-color: #666 !important;
    color: white !important;
}

.copy-code-btn.copied {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.code-block-wrapper pre {
    margin: 0;
    border-radius: 0 0 0.5rem 0.5rem;
    border: 1px solid #404040;
    border-top: none;
}

[data-theme="dark"] .code-block-header {
    background: #1e1e1e;
    border-color: #333;
}

[data-theme="dark"] .code-block-header span {
    color: #888;
}

[data-theme="dark"] .code-block-wrapper pre {
    border-color: #333;
}

[data-theme="dark"] .copy-code-btn {
    background: #333 !important;
    color: #ccc !important;
    border-color: #444 !important;
}

[data-theme="dark"] .copy-code-btn:hover {
    background: #444 !important;
    border-color: #555 !important;
    color: white !important;
}

/* Scrollbar styling for TOC - chỉ áp dụng cho ul */
.table-of-contents ul::-webkit-scrollbar {
    width: 6px;
}

.table-of-contents ul::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 3px;
}

.table-of-contents ul::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.table-of-contents ul::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Firefox scrollbar */
.table-of-contents ul {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-light);
}

/* Mobile TOC - hiển thị trước post content */
.table-of-contents.toc-mobile {
    height: auto;
    max-height: 400px;
    margin-bottom: 2rem;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    box-sizing: border-box;
}

/* Desktop TOC - giữ trong sidebar */
.table-of-contents.sticky {
    position: relative;
}

/* Responsive TOC */
@media (max-width: 991px) {
    /* Ẩn TOC trong sidebar trên mobile */
    .sidebar .table-of-contents.sticky {
        display: none !important;
    }
    
    /* Hiển thị TOC mobile trong col-lg-8 (sau post-header) */
    .table-of-contents.toc-mobile {
        display: flex !important;
        flex-direction: column;
        height: auto;
        max-height: 400px;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Đảm bảo TOC mobile hiển thị đúng trong col-lg-8 */
    .col-lg-8 .table-of-contents.toc-mobile {
        display: flex !important;
    }
}

@media (min-width: 992px) {
    /* Ẩn TOC mobile trên desktop */
    .table-of-contents.toc-mobile {
        display: none !important;
    }
    
    /* Hiển thị TOC trong sidebar trên desktop */
    .sidebar .table-of-contents.sticky {
        display: flex !important;
        height: 350px;
    }
    
    /* Đảm bảo TOC không hiển thị trong col-lg-8 trên desktop */
    .col-lg-8 .table-of-contents:not(.toc-mobile) {
        display: none;
    }
}
