/* ============================================
   CSS VARIABLES & DESIGN TOKENS
   ============================================ */
:root {
    /* Corporate Dark Mode Colors (Default) - Professional & Clean */
    --bg-primary: #1a1d21;
    /* Professional Dark Gray */
    --bg-secondary: #212529;
    /* Slightly lighter sidebar/cards */
    --bg-tertiary: #2c3035;
    --surface: #212529;
    --surface-hover: #2c3035;

    /* Corporate Blue Palette */
    --primary: #0d6efd;
    /* Standard Trustworthy Blue */
    --primary-hover: #0b5ed7;
    --accent: #6c757d;
    /* Standard Gray Accent */
    --accent-light: #adb5bd;

    --text-primary: #e9ecef;
    /* High legibility off-white */
    --text-secondary: #adb5bd;
    /* Muted gray */
    --text-muted: #6c757d;

    --border: #343a40;
    --border-hover: #495057;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Subtle/Professional Gradients */
    --gradient-primary: linear-gradient(180deg, #0d6efd 0%, #0a58ca 100%);
    --gradient-accent: linear-gradient(180deg, #6c757d 0%, #495057 100%);
    --gradient-surface: linear-gradient(180deg, #212529 0%, #212529 100%);
    /* Solid for professional look */

    /* Spacing */
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-code: 'Consolas', 'Monaco', 'Courier New', monospace;

    /* Layout */
    --header-height: 70px;
    /* Condensed header */
    --sidebar-width: 280px;
    --ad-sidebar-width: 320px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* Light Mode - Warm & Comfortable */
/* Light Mode - Corporate Standard */
body.light-mode {
    --bg-primary: #ffffff;
    /* Pure White */
    --bg-secondary: #f8f9fa;
    /* Very Light Gray */
    --bg-tertiary: #e9ecef;
    --surface: #ffffff;
    --surface-hover: #f8f9fa;

    --primary: #0d6efd;
    /* Bootstrap Blue */
    --primary-hover: #0b5ed7;
    --accent: #6c757d;
    /* Gray */
    --accent-light: #ced4da;

    --text-primary: #212529;
    /* Darkest Gray */
    --text-secondary: #495057;
    /* Dark Gray */
    --text-muted: #6c757d;

    --border: #dee2e6;
    /* Standard Light Border */
    --border-hover: #ced4da;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    --gradient-primary: linear-gradient(180deg, #0d6efd 0%, #0a58ca 100%);
    --gradient-accent: linear-gradient(180deg, #6c757d 0%, #495057 100%);
    --gradient-surface: linear-gradient(180deg, #ffffff 0%, #ffffff 100%);
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ============================================
   HEADER STYLES
   ============================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--gradient-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 var(--spacing-lg);
    max-width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo {
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast);
}

.logo:hover {
    transform: scale(1.05) rotate(5deg);
}

.site-title h1 {
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.theme-toggle {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    transform: scale(1.05);
}

.theme-toggle i {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* ============================================
   MOBILE MENU TOGGLE
   ============================================ */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 999;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-fast);
}

.mobile-menu-toggle:hover {
    transform: scale(1.1);
}

/* ============================================
   MAIN CONTAINER LAYOUT
   ============================================ */
.main-container {
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding: var(--spacing-md);
}

/* Bootstrap compatibility - use flexbox for row */
.main-container .row {
    display: flex;
    flex-wrap: wrap;
    /* gap: var(--spacing-md); REMOVED to prevent grid wrapping */
    margin-right: -15px;
    margin-left: -15px;
}

/* ============================================
   SIDEBAR NAVIGATION
   ============================================ */
.sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--spacing-md));
    height: calc(100vh - var(--header-height) - var(--spacing-md) * 2);
    background: var(--gradient-surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: var(--spacing-md);
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    flex: 0 0 auto;
    max-width: 100%;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
}

.menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.menu-item {
    width: 100%;
    padding: var(--spacing-sm);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
}

.menu-item i {
    font-size: 18px;
    min-width: 20px;
    color: var(--accent);
    transition: transform var(--transition-fast);
}

.menu-item:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
    transform: translateX(4px);
}

.menu-item:hover i {
    transform: scale(1.1);
}

.menu-item.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.menu-item.active i {
    color: white;
}

/* Custom Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-light);
}

/* ============================================
   CONTENT AREA
   ============================================ */
.content-area {
    background: var(--gradient-surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: var(--spacing-lg);
    min-height: 600px;
    box-shadow: var(--shadow-md);
    animation: fadeIn var(--transition-normal);
    flex: 1 1 auto;
    max-width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-section {
    animation: slideIn var(--transition-normal);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.content-section h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: var(--spacing-md);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.content-section h2 {
    font-size: 28px;
    font-weight: 700;
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.content-section h3 {
    font-size: 22px;
    font-weight: 600;
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    color: var(--accent);
}

.content-section p {
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
    line-height: 1.8;
}

.content-section ul,
.content-section ol {
    margin-left: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
}

.content-section li {
    margin-bottom: var(--spacing-xs);
    line-height: 1.8;
}

.content-section code {
    font-family: var(--font-code);
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--accent-light);
    border: 1px solid var(--border);
}

.content-section pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.content-section pre code {
    background: transparent;
    padding: 0;
    border: none;
    display: block;
    line-height: 1.6;
}

.info-box {
    background: var(--surface);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
    box-shadow: var(--shadow-sm);
}

.info-box.warning {
    border-left-color: #f59e0b;
}

.info-box.success {
    border-left-color: #10b981;
}

.info-box.error {
    border-left-color: #ef4444;
}

/* Image Styling */
.content-section img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: var(--spacing-md) 0;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.topic-image {
    width: 100%;
    max-width: 800px;
    margin: var(--spacing-lg) auto;
    display: block;
}


/* ============================================
   AD SIDEBAR
   ============================================ */
.ad-sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--spacing-md));
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    flex: 0 0 auto;
    max-width: 100%;
}

.ad-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
}

.ad-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
}

.ad-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.ad-placeholder {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 240px;
        --ad-sidebar-width: 280px;
    }

    .header-content {
        padding: 0 var(--spacing-md);
    }

    .ad-header {
        display: none;
    }

    .site-title h1 {
        font-size: 20px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --header-height: 70px;
    }

    .main-container {
        grid-template-columns: 1fr;
        padding: var(--spacing-sm);
    }

    .header-content {
        padding: 0 var(--spacing-sm);
    }

    .site-title h1 {
        font-size: 16px;
    }

    .subtitle {
        display: none;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        width: 280px;
        height: calc(100vh - var(--header-height));
        z-index: 998;
        transition: left var(--transition-normal);
        margin: 0;
    }

    .sidebar.active {
        left: 0;
        display: block !important;
        /* Override Bootstrap d-none */
        visibility: visible;
    }

    .ad-sidebar {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .content-area {
        padding: var(--spacing-md);
    }

    .content-section h1 {
        font-size: 28px;
    }

    .content-section h2 {
        font-size: 22px;
    }

    .content-section h3 {
        font-size: 18px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .logo {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .site-title h1 {
        font-size: 14px;
    }

    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .content-area {
        padding: var(--spacing-sm);
    }

    .content-section h1 {
        font-size: 24px;
    }
}

.site-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}