/**
 * Main Styles - AI/ML Textbook
 */

:root {
    /* Primary */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;

    /* Difficulty Colors */
    --beginner: #22c55e;
    --enthusiast: #3b82f6;
    --intermediate: #eab308;
    --advanced: #f97316;
    --expert: #ef4444;

    /* Neutrals */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;

    /* Code */
    --code-bg: #1e293b;
    --code-text: #e2e8f0;

    /* Layout */
    --sidebar-width: 280px;
    --toc-width: 220px;
    --content-max-width: 900px;
    --header-height: 64px;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    margin: 0;
    padding: 0;
}

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

a:hover {
    text-decoration: underline;
}

code, pre {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Layout */
.site-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Header */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
}

.site-logo {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    text-decoration: none;
}

.site-logo i {
    color: var(--primary);
    margin-right: 0.5rem;
}

.site-logo:hover {
    text-decoration: none;
    color: var(--primary);
}

.header-search {
    flex: 1;
    max-width: 400px;
    margin: 0 2rem;
}

.header-search .form-control {
    border-radius: 2rem;
    padding-left: 2.5rem;
    background-color: var(--bg-tertiary);
    border: none;
}

.header-search .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Sidebar */
.site-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: white;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1rem 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-section {
    padding: 1rem 1.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.sidebar-nav .nav-item > a {
    display: flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.sidebar-nav .nav-item > a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-nav .nav-item > a.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    font-weight: 500;
}

.sidebar-nav .nav-item .part-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

/* Sub-navigation */
.sidebar-nav .nav-children {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
}

.sidebar-nav .nav-item.expanded .nav-children {
    display: block;
}

.sidebar-nav .nav-children a {
    padding-left: 2.5rem;
    font-size: 0.9rem;
}

/* Main Content */
.site-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 2rem;
    min-height: calc(100vh - var(--header-height));
}

.content-wrapper {
    max-width: var(--content-max-width);
    margin: 0 auto;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 2rem 2.5rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p {
    margin-bottom: 1rem;
}

/* Breadcrumb */
.breadcrumb-nav {
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.breadcrumb-nav a {
    color: var(--text-muted);
}

.breadcrumb-nav .separator {
    margin: 0 0.5rem;
    color: var(--text-muted);
}

/* Difficulty Badges */
.difficulty-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25em 0.75em;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
}

.difficulty-badge i {
    margin-right: 0.375rem;
}

/* Code Blocks */
.code-block-wrapper {
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--code-bg);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-language {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.btn-copy {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-copy.copied {
    color: var(--beginner);
}

pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.5;
}

pre code {
    color: var(--code-text);
}

/* Inline Code */
.inline-code {
    background: var(--bg-tertiary);
    padding: 0.125em 0.375em;
    border-radius: 0.25rem;
    font-size: 0.875em;
    color: var(--primary-dark);
}

/* Math */
.math-block {
    margin: 1.5rem 0;
    text-align: center;
    overflow-x: auto;
}

/* Cards */
.content-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.2s;
}

.content-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Part Cards */
.part-card {
    display: block;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.part-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    border-color: var(--primary);
}

.part-card .part-number {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.part-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.part-card .part-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* Navigation Footer */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.chapter-nav a {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    color: var(--text-primary);
    max-width: 45%;
}

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

.chapter-nav .nav-prev i {
    margin-right: 0.75rem;
}

.chapter-nav .nav-next i {
    margin-left: 0.75rem;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4rem 2rem;
    border-radius: 0.75rem;
    margin-bottom: 2rem;
    text-align: center;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.125rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero .btn-primary {
    background: white;
    color: var(--primary);
    padding: 0.75rem 2rem;
    border-radius: 2rem;
    font-weight: 600;
}

.hero .btn-primary:hover {
    background: var(--bg-tertiary);
}

/* Stats */
.stats-row {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
}

.stat-item {
    text-align: center;
}

.stat-item .stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-item .stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Footer */
.site-footer {
    background: var(--text-primary);
    color: white;
    padding: 2rem;
    margin-top: 3rem;
    margin-left: var(--sidebar-width);
    text-align: center;
}

.site-footer a {
    color: var(--primary-light);
}

/* Mobile Toggle */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    margin-right: 1rem;
}

/* Responsive */
@media (max-width: 991.98px) {
    .site-sidebar {
        transform: translateX(-100%);
    }

    .site-sidebar.show {
        transform: translateX(0);
    }

    .site-main {
        margin-left: 0;
    }

    .site-footer {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .header-search {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 1.5rem;
    }

    .hero {
        padding: 2rem 1rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .stats-row {
        flex-wrap: wrap;
        gap: 1.5rem;
    }
}
