/* ========================================
   CSS DESIGN SYSTEM - CENTRALIZED VARIABLES
   ======================================== */
:root {
    /* Colors */
    --primary-color: #6366f1; /* Adjusted primary */
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-hover: #4338ca; /* Darker hover */
    --secondary-color: #6b7280;
    --secondary-dark: #4b5563;
    --secondary-light: #9ca3af;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-dark: #111827; /* Darkest text */
    --text-muted: #9ca3af;
    --text-light: #d1d5db; /* Lighter text */
    --text-white: #ffffff;
    --background-color: #ffffff;
    --background-alt: #f9fafb;
    --background-dark: #f3f4f6; /* Renamed light grey */
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --border-dark: #d1d5db;
    --success-color: #10b981;
    --success-dark: #059669;
    --warning-color: #f59e0b;
    --warning-dark: #d97706;
    --error-color: #ef4444; /* Changed name */
    --error-dark: #dc2626;
    --info-color: #3b82f6;
    --info-dark: #2563eb;
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-card: var(--shadow-sm);
    --shadow-hover: var(--shadow-lg);
    /* Borders */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --line-height-tight: 1.3;
    --line-height-normal: 1.6;
    /* Transitions */
    --transition-fast: 0.1s ease-out;
    --transition-base: 0.2s ease-out;
    --transition-slow: 0.3s ease-out;
    /* Components */
    --button-padding-y: 0.5rem;
    --button-padding-x: 1rem;
}

/* ========================================
   BASE & GLOBAL STYLES
   ======================================== */
body {
    font-family: var(--font-family);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background-color: var(--background-alt);
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden;
}

a { color: var(--primary-color); text-decoration: none; transition: color var(--transition-base); }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ========================================
   CONTAINER & GRID LAYOUT
   ======================================== */
.container {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: var(--spacing-lg) !important;
    padding-right: var(--spacing-lg) !important;
}
main.container {
    padding-top: var(--spacing-xl) !important;
    padding-bottom: var(--spacing-2xl) !important;
}

/* Corrected Bootstrap Column Styles */
.row > * { box-sizing: border-box; }
.row {
     --bs-gutter-x: 2rem; /* Define gutter */
     margin-left: calc(-.5 * var(--bs-gutter-x));
     margin-right: calc(-.5 * var(--bs-gutter-x));
     display: flex;
     flex-wrap: wrap;
}
@media (min-width: 992px) {
    .col-lg-8 {
        flex: 0 0 auto;
        width: 66.66666667%;
        padding-right: calc(var(--bs-gutter-x) * .5);
        padding-left: calc(var(--bs-gutter-x) * .5);
    }
    .col-lg-4 {
        flex: 0 0 auto;
        width: 33.33333333%;
        padding-right: calc(var(--bs-gutter-x) * .5);
        padding-left: calc(var(--bs-gutter-x) * .5);
    }
}
@media (max-width: 991px) {
    .col-lg-8, .col-lg-4 {
        width: 100%;
        padding-left: 15px;
        padding-right: 15px;
        flex: 0 0 auto;
    }
    .col-lg-4 { margin-top: var(--spacing-xl); }
}

/* ========================================
   FEATURED CAROUSEL (TOP OF PAGE)
   ======================================== */
.featured-carousel-section { background: white; padding: 2rem 0; border-bottom: 1px solid var(--border-color); }
.carousel-post-card { background: white; border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-lg); border: 1px solid var(--border-color); margin: 0 1rem; min-height: 400px; }
.carousel-image, .carousel-image-placeholder { width: 100%; height: 400px; object-fit: cover; }
.carousel-image-placeholder { background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.carousel-content { padding: 2rem; height: 400px; display: flex; flex-direction: column; justify-content: space-between; }
.carousel-category { background: var(--primary-color); color: white; padding: 0.25rem 0.75rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 500; text-transform: uppercase; display: inline-block; margin-bottom: 1rem; }
.carousel-title-post { font-size: 1.6rem; font-weight: 700; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.carousel-title-post a { color: var(--text-primary); text-decoration: none; transition: color 0.2s ease; }
.carousel-title-post a:hover { color: var(--primary-color); }
.carousel-excerpt { color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.6; flex-grow: 1; }
.carousel-meta { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: auto; font-size: 0.875rem; color: var(--text-secondary); }
.carousel-read-more { background: var(--primary-color); color: white; padding: 0.75rem 1.5rem; border-radius: var(--radius-md); text-decoration: none; font-weight: 500; transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 0.5rem; align-self: flex-start; }
.carousel-read-more:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.carousel-control-prev, .carousel-control-next { background: rgba(255, 255, 255, 0.9); border: 2px solid var(--border-color); border-radius: 50%; width: 50px; height: 50px; top: 50%; transform: translateY(-50%); }
.carousel-control-prev:hover, .carousel-control-next:hover { background: var(--primary-color); border-color: var(--primary-color); }
.carousel-control-prev-icon, .carousel-control-next-icon { filter: invert(0.5); }
.carousel-control-prev:hover .carousel-control-prev-icon, .carousel-control-next:hover .carousel-control-next-icon { filter: invert(1); }
.carousel-indicators { display: none !important; } /* Hide indicators */
@media (max-width: 768px) { /* Carousel Responsive */
    .carousel-post-card { flex-direction: column; min-height: auto; }
    .carousel-image, .carousel-image-placeholder { height: 250px; }
    .carousel-content { height: auto; padding: 1.5rem; }
    .carousel-title-post { font-size: 1.3rem; }
}

/* ========================================
   INDEX PAGE: ENHANCED CATEGORY SECTION LAYOUT
   ======================================== */
.category-section-enhanced { background: #ffffff; border-radius: var(--radius-xl); padding: 2rem; margin-bottom: 3rem; box-shadow: var(--shadow-lg); border-top: 4px solid var(--category-accent-color, var(--primary-color)); transition: all 0.3s ease; }
.category-section-enhanced:hover { transform: translateY(-5px); box-shadow: var(--shadow-xl); }
.category-header-enhanced { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); gap: 1rem; }
.category-header-enhanced .category-icon-wrapper { width: 50px; height: 50px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; background: var(--category-accent-color, var(--primary-color)); color: white; font-size: 1.5rem; flex-shrink: 0; }
.category-header-enhanced .category-info { flex: 1; }
.category-header-enhanced .category-title { font-size: 1.75rem; margin: 0; }
.category-header-enhanced .category-title a { text-decoration: none; color: var(--text-primary); }
.category-header-enhanced .category-description { margin-top: 0.25rem; color: var(--text-secondary); font-size: 0.9rem; }
.category-header-enhanced .view-all-btn { background-color: var(--category-accent-color, var(--primary-color)); color: white; padding: 0.6rem 1.2rem; border-radius: var(--radius-md); text-decoration: none; font-weight: 500; transition: all 0.2s ease; white-space: nowrap; }
.category-header-enhanced .view-all-btn:hover { opacity: 0.85; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.category-content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.featured-post-card { grid-column: 1 / 2; background: #f9fafb; border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--border-light); }
.featured-post-image-container img, .featured-post-image-container .post-image-placeholder { width: 100%; height: 250px; object-fit: cover; }
.featured-post-content { padding: 1.5rem; display: flex; flex-direction: column; justify-content: space-between; flex-grow: 1; }
.featured-post-title { font-size: 1.5rem; font-weight: 600; line-height: 1.3; margin-bottom: 1rem; }
.featured-post-title a { text-decoration: none; color: var(--text-primary); }
.featured-post-title a:hover { color: var(--category-accent-color, var(--primary-color)); }
.featured-post-excerpt { color: var(--text-secondary); font-size: 0.95rem; }
.featured-post-meta { margin-top: 1.5rem; font-size: 0.85rem; color: var(--text-secondary); display: flex; gap: 1rem; }
.remaining-posts-grid { grid-column: 2 / 3; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.post-card-small { background: white; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); transition: all 0.3s ease; }
.post-card-small:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.post-card-small-image-container img, .post-card-small-image-container .post-image-placeholder { width: 100%; height: 120px; object-fit: cover; }
.post-card-small-content { padding: 1rem; }
.post-card-small-title { font-size: 1rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.5rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-card-small-title a { text-decoration: none; color: var(--text-primary); }
.post-card-small-title a:hover { color: var(--category-accent-color, var(--primary-color)); }
.post-card-small-date { font-size: 0.8rem; color: var(--text-secondary); }
.no-posts-message { text-align: center; padding: 3rem 1rem; color: var(--text-secondary); grid-column: 1 / -1; }
.no-posts-message i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
@media (max-width: 992px) { .category-content-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) { .category-header-enhanced { flex-direction: column; align-items: flex-start; } .remaining-posts-grid { grid-template-columns: 1fr; } }

/* Category Pagination */
.category-pagination-wrapper { margin: 3rem 0 2rem 0; text-align: center; }
.category-pagination { display: inline-flex; align-items: center; gap: 1.5rem; background: white; padding: 1.5rem 2rem; border-radius: var(--radius-xl); box-shadow: var(--shadow-md); border: 1px solid var(--border-color); flex-wrap: wrap; justify-content: center; }
.cat-page-btn { background: var(--primary-color); color: white; padding: 0.75rem 1.5rem; border-radius: var(--radius-md); text-decoration: none; font-weight: 600; transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 0.5rem; }
.cat-page-btn:hover { background: var(--primary-dark); color: white; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.category-page-info { font-weight: 500; color: var(--text-secondary); font-size: 0.95rem; }

/* ========================================
   SIDEBAR STYLES
   ======================================== */
.sidebar { background: #fff; border-radius: var(--radius-lg); padding: 0; box-shadow: var(--shadow-md); height: fit-content; position: sticky; top: 100px; border: 1px solid var(--border-light); }
.sidebar-section { padding: var(--spacing-lg) var(--spacing-xl); position: relative; }
.sidebar-section:not(:last-child)::after { content: ''; position: absolute; bottom: 0; left: var(--spacing-xl); right: var(--spacing-xl); height: 1px; background: var(--border-light); }
.sidebar-title { font-size: 0.9rem; font-weight: var(--font-weight-bold); margin-bottom: var(--spacing-md); color: var(--text-dark); display: flex; align-items: center; gap: var(--spacing-sm); text-transform: uppercase; letter-spacing: 0.05em; position: relative; padding-bottom: var(--spacing-sm); }
.sidebar-title::after { content: ''; position: absolute; bottom: 0; left: 0; width: 40px; height: 3px; border-radius: 2px; background: var(--primary-light); transition: width var(--transition-slow); }
.sidebar-section:hover .sidebar-title::after { width: 60px; }
.sidebar-title i { font-size: 1rem; padding: var(--spacing-sm); border-radius: var(--radius-md); background: rgba(0,0,0,0.03); color: var(--text-secondary); transition: all var(--transition-base); line-height: 1; }
.sidebar-item { padding: var(--spacing-xs) 0; margin: 0 calc(-1 * var(--spacing-sm)); padding-left: var(--spacing-sm); padding-right: var(--spacing-sm); border-radius: var(--radius-sm); transition: background-color var(--transition-base); }
.sidebar-item:not(:last-child) { border-bottom: 1px dashed var(--border-light); }
.sidebar-item:hover { background-color: var(--background-alt); }
.sidebar-link { display: flex; align-items: center; justify-content: space-between; padding: var(--spacing-sm) 0; color: var(--text-secondary); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); text-decoration: none; transition: color var(--transition-base), transform var(--transition-base); }
.sidebar-link:hover { color: var(--primary-color); transform: translateX(4px); text-decoration: none; }
.sidebar-item small.text-muted { font-size: var(--font-size-xs); display: block; margin-top: var(--spacing-xs); padding-left: 26px; color: var(--text-muted); } /* Ensured color */
.sidebar-link i.fas { margin-right: var(--spacing-sm); width: 16px; text-align: center; color: var(--text-light); transition: color var(--transition-base); }
.sidebar-link:hover i.fas { color: var(--primary-light); }
.tags-cloud { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); margin-top: var(--spacing-sm); }
.tag-item { background: var(--background-alt); color: var(--text-secondary); padding: var(--spacing-xs) var(--spacing-sm); border-radius: var(--radius-sm); text-decoration: none; font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); border: 1px solid var(--border-light); transition: all var(--transition-base); }
.tag-item:hover { background: var(--primary-light); color: white; border-color: var(--primary-light); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.tag-count { font-size: 0.7rem; opacity: 0.7; margin-left: var(--spacing-xs); }

/* Sidebar Title Icon Colors */
.popular-posts-section .sidebar-title i { color: #ff6b35; background: rgba(255, 107, 53, 0.1); }
.popular-posts-section .sidebar-title::after { background: #ff6b35; }
.main-pages-section .sidebar-title i { color: #3b82f6; background: rgba(59, 130, 246, 0.1); }
.main-pages-section .sidebar-title::after { background: #3b82f6; }
.categories-section .sidebar-title i { color: #f59e0b; background: rgba(245, 158, 11, 0.1); }
.categories-section .sidebar-title::after { background: #f59e0b; }
.newsletter-section .sidebar-title i { color: #10b981; background: rgba(16, 185, 129, 0.1); }
.newsletter-section .sidebar-title::after { background: #10b981; }
.featured-posts-section .sidebar-title i { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.featured-posts-section .sidebar-title::after { background: #fbbf24; }
.recent-activity-section .sidebar-title i { color: #8b5cf6; background: rgba(139, 92, 246, 0.1); }
.recent-activity-section .sidebar-title::after { background: #8b5cf6; }
.tags-section .sidebar-title i { color: #ec4899; background: rgba(236, 72, 153, 0.1); }
.tags-section .sidebar-title::after { background: #ec4899; }
.sidebar-section:hover .sidebar-title i { transform: scale(1.1) rotate(5deg); box-shadow: var(--shadow-sm); }

/* ENHANCED WELCOME SECTION */
.welcome-section { background: linear-gradient(145deg, var(--primary-dark) 0%, var(--primary-color) 100%); color: var(--text-white); border-radius: var(--radius-lg); padding: var(--spacing-lg) var(--spacing-xl); text-align: center; border: none; position: relative; overflow: hidden; }
.welcome-title { font-size: var(--font-size-xl); font-weight: var(--font-weight-bold); margin-bottom: var(--spacing-xs); color: var(--text-white); }
.welcome-subtitle { font-size: var(--font-size-base); font-weight: var(--font-weight-medium); margin-bottom: var(--spacing-md); color: rgba(255, 255, 255, 0.9); }
.welcome-description { font-size: var(--font-size-sm); line-height: var(--line-height-normal); margin-bottom: var(--spacing-lg); color: rgba(255, 255, 255, 0.85); max-width: 45ch; margin-left: auto; margin-right: auto; }
.stats-mini-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--spacing-md); }
.stat-mini-item { text-align: center; padding: var(--spacing-sm); background: rgba(255, 255, 255, 0.15); border-radius: var(--radius-md); border: 1px solid rgba(255, 255, 255, 0.25); transition: all var(--transition-base); }
.stat-mini-item:hover { background: rgba(255, 255, 255, 0.25); transform: scale(1.03); }
.stat-mini-number { font-size: var(--font-size-xl); font-weight: var(--font-weight-bold); display: block; color: var(--text-white); margin-bottom: var(--spacing-xs); }
.stat-mini-label { font-size: var(--font-size-xs); color: rgba(255, 255, 255, 0.85); text-transform: uppercase; letter-spacing: 0.05em; }

/* Newsletter Form */
.newsletter-section { background-color: var(--background-alt); }
.newsletter-form { margin-top: var(--spacing-sm); }
.newsletter-form .form-control { border-radius: var(--radius-sm); border: 1px solid var(--border-color); padding: var(--button-padding-y) var(--button-padding-x); font-size: var(--font-size-sm); background: var(--background-color); margin-bottom: var(--spacing-sm); }
.newsletter-form .form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.newsletter-form .btn { border-radius: var(--radius-sm); font-weight: var(--font-weight-medium); padding: var(--button-padding-y) var(--button-padding-x); background: var(--success-color); border: none; color: white; }
.newsletter-form .btn:hover { background: var(--success-dark); }

/* Individual Sidebar Section Scrolling */
.categories-section, .popular-posts-section, .main-pages-section, .tags-section, .recent-activity-section, .featured-posts-section { max-height: 350px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(99, 102, 241, 0.3) transparent; padding-right: 8px; /* Space for scrollbar */ }
.categories-section::-webkit-scrollbar, .popular-posts-section::-webkit-scrollbar, .main-pages-section::-webkit-scrollbar, .tags-section::-webkit-scrollbar, .recent-activity-section::-webkit-scrollbar, .featured-posts-section::-webkit-scrollbar { width: 6px; }
.categories-section::-webkit-scrollbar-track, .popular-posts-section::-webkit-scrollbar-track, .main-pages-section::-webkit-scrollbar-track, .tags-section::-webkit-scrollbar-track, .recent-activity-section::-webkit-scrollbar-track, .featured-posts-section::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 3px; }
.categories-section::-webkit-scrollbar-thumb, .popular-posts-section::-webkit-scrollbar-thumb, .main-pages-section::-webkit-scrollbar-thumb, .tags-section::-webkit-scrollbar-thumb, .recent-activity-section::-webkit-scrollbar-thumb, .featured-posts-section::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.4); border-radius: 3px; }
.newsletter-section, .welcome-section { max-height: none !important; overflow: visible !important; } /* Ensure these don't scroll */

@media (max-width: 991px) { .sidebar { margin-top: 3rem; position: static; } }

/* ========================================
   SKELETON LOADER (FOR ASYNC SIDEBAR)
   ======================================== */
.skeleton-loader { padding: 1.5rem; }
.skeleton-header, .skeleton-text, .skeleton-stat, .skeleton-item { background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 4px; }
.skeleton-header { height: 28px; margin-bottom: 1rem; }
.skeleton-text { height: 16px; margin-bottom: 0.75rem; }
.skeleton-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 1.5rem; }
.skeleton-stat { height: 60px; border-radius: 8px; }
.skeleton-item { height: 50px; margin-bottom: 0.75rem; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
[aria-busy="false"] .skeleton-loader { display: none; }

/* ========================================
   UTILITIES
   ======================================== */
.post-image-placeholder { background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }

/* Add other utility classes as needed */