/* Guide Base CSS - Shared styles for documentation guides */

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

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

/* Main layout */
.container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

/* Sidebar navigation */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    overflow-y: auto;
    padding: 2rem 1rem;
    z-index: 100;
}

.sidebar h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    border-bottom: none; /* Reset standard h2 border */
    margin-top: 0;
    padding-bottom: 0;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0;
}

.nav-section ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.nav-section li {
    margin-bottom: 0.25rem;
}

.nav-section a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-section a:hover {
    background: #e2e8f0; /* Fallback */
    background: var(--sidebar-hover-bg, #e2e8f0);
    color: var(--primary-color);
}

.nav-section a.active {
    background: var(--primary-color);
    color: white;
}

/* Progress bar */
.progress-bar {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    height: 4px;
    background: #e2e8f0;
    z-index: 1000;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem 3rem;
    max-width: 900px;
}

/* Floating TOC button (mobile) */
.floating-toc {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    z-index: 200;
}

.floating-toc svg {
    width: 24px;
    height: 24px;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

p {
    margin-bottom: 1rem;
}

.lead {
    font-size: 1.125rem;
    color: var(--secondary-color);
    margin-bottom: 2rem;
}

/* Lists */
ul, ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Code blocks */
code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 0.125rem 0.25rem;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 0.25rem;
}

pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
    position: relative;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    display: block;
    white-space: pre;
}

/* Syntax highlighting */
.comment { color: #64748b; font-style: italic; }
.string { color: #059669; }
.keyword { color: #7c3aed; font-weight: 600; }
.function { color: #2563eb; }
.number { color: #dc2626; }
.operator { color: #0891b2; }
.variable { color: #ea580c; }

/* Specific selection for code blocks */
pre::selection, pre *::selection,
code::selection, code *::selection {
    background: #b3d4fc;
}

/* Notes and Alerts */
.important {
    background: #fef3c7;
    border-left: 4px solid var(--warning);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0.5rem;
}

.important strong {
    color: #92400e;
}

.warning {
    background: #fff3f3;
    border-left: 4px solid var(--warning);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0.5rem;
}

.warning-title {
    color: var(--warning);
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 10px;
}

.note {
    background: #dbeafe;
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0.5rem;
}

/* Section numbers */
.section-number {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    text-align: center;
    line-height: 2rem;
    font-weight: 600;
    margin-right: 0.5rem;
    font-size: 0.875rem;
    vertical-align: middle;
}

/* Copy Button */
.code-container {
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 1;
}

/* Mobile TOC overlay */
.mobile-toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    display: none;
}

.mobile-toc-content {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw; /* Responsive width for small screens */
    background: white;
    padding: 2rem;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

.mobile-toc-overlay.active {
    display: block;
}

.mobile-toc-overlay.active .mobile-toc-content {
    transform: translateX(0);
}

.close-toc {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
}

/* Responsive design */

/* Tablet / Small Laptop (1024px and below) */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .progress-bar {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 2rem;
        max-width: 100%;
    }

    .floating-toc {
        display: flex;
    }

    h1 {
        font-size: 2.2rem;
    }

    h2 {
        font-size: 1.75rem;
    }
}

/* Tablet Portrait (768px and below) */
@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem;
    }
    
    .floating-toc {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 50px;
        height: 50px;
    }

    h1 {
        font-size: 2rem;
    }
}

/* Mobile (640px and below) */
@media (max-width: 640px) {
    .main-content {
        padding: 1.25rem 1rem;
    }

    h1 {
        font-size: 1.75rem;
        word-wrap: break-word; /* Prevent long words/titles from overflowing */
    }

    h2 {
        font-size: 1.5rem;
        margin-top: 2rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .lead {
        font-size: 1rem;
    }

    /* Adjust code block font size for mobile */
    code, pre {
        font-size: 0.8em;
    }
    
    pre {
        padding: 0.75rem;
    }

    /* Adjust floating TOC for mobile */
    .floating-toc {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        opacity: 0.9;
    }
    
    .floating-toc svg {
        width: 20px;
        height: 20px;
    }
}

/* Home link */
.home-link {
    text-align: center;
    margin: 2rem 0;
}

.home-link a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.2s;
}

.home-link a:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Print styles */
@media print {
    .sidebar,
    .floating-toc,
    .progress-bar,
    .mobile-toc-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
        max-width: 100%;
    }

    body {
        font-size: 12pt;
    }

    pre {
        white-space: pre-wrap;
        word-wrap: break-word;
    }

    h2 {
        page-break-before: always;
    }

    .important, .note, .warning {
        break-inside: avoid;
    }
}
