/* =============================================================================
   RESET AND BASE STYLES
   ============================================================================= */

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

/* CSS Custom Properties - Design System Variables */
:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --accent-color: #0ea5e9;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --code-background: #1e293b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    /* Layout Constants */
    --sidebar-width: 280px;
    --header-height: 60px;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, 'Courier New', monospace;
    
    /* Shadows - Consistent elevation system */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Border Radius */
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --transition: all 0.2s ease-in-out;
}

/* =============================================================================
   BASE ELEMENTS
   ============================================================================= */

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Loading state - prevents flash of unstyled content */
body.loaded {
    opacity: 1;
}

/* =============================================================================
   LAYOUT COMPONENTS
   ============================================================================= */

.container {
    display: flex;
    min-height: 100vh;
}

/* Mobile menu toggle - hidden on desktop, shown on mobile */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.75rem;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.mobile-menu-toggle.active {
    background-color: var(--error-color);
}

/* =============================================================================
   SIDEBAR NAVIGATION
   ============================================================================= */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: var(--transition);
}

/* Custom scrollbar styling for webkit browsers */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--surface-color);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.sidebar-header {
    padding: 0 2rem 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
    position: relative;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.sidebar-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* =============================================================================
   SEARCH FUNCTIONALITY
   ============================================================================= */

.search-container {
    padding: 0 2rem 1rem;
    position: relative;
    margin-bottom: 1rem;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.search-clear-btn:hover {
    background-color: var(--surface-hover);
    color: var(--text-primary);
}

.search-clear-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 2rem;
    right: 2rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.search-result {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background-color: var(--surface-hover);
}

.search-result-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.search-result-snippet {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.search-result-snippet mark {
    background-color: var(--primary-color);
    color: white;
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Navigation sections and links */
.nav-section {
    margin-bottom: 1.5rem;
    padding: 0 1.75rem;
}

.nav-section:first-of-type {
    margin-top: 1.5rem;
}

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

/* Dropdown toggle buttons for navigation sections */
.nav-section-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 0.375rem 0;
    margin-bottom: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.nav-section-toggle:hover {
    background-color: var(--surface-hover);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.nav-section-toggle:focus {
    outline: none;
}

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

.nav-toggle-icon {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease-in-out;
    user-select: none;
    margin-left: -0.25rem;
}

/* Rotate icon when section is collapsed */
.nav-section-toggle[aria-expanded="false"] .nav-toggle-icon {
    transform: rotate(-90deg);
}

/* Subsection lists with smooth animations */
.nav-subsection {
    list-style: none;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, opacity 0.2s ease-in-out;
    max-height: 500px; /* Generous max-height for open state */
    opacity: 1;
    padding: 0.125rem 0 0.25rem 0;
}

.nav-subsection.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding: 0;
}

.nav-section ul {
    list-style: none;
}

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

.nav-link {
    display: block;
    padding: 0.375rem 1rem;
    margin: 0 0.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 0.875rem;
    position: relative;
}

.nav-link:hover {
    background-color: var(--surface-hover);
    color: var(--text-primary);
}

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

/* Active link indicator - visual cue for current section */
.nav-link.active::before {
    content: '';
    position: absolute;
    left: -1.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 100%;
    background-color: var(--primary-color);
}

/* =============================================================================
   MAIN CONTENT AREA
   ============================================================================= */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Back button for subsections - positioned to the left of main content */
.back-button {
    display: none;
    position: fixed;
    left: calc(var(--sidebar-width) + 2.5rem);
    top: 4rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family);
    z-index: 10;
}

.back-button:hover {
    background-color: var(--surface-hover);
    border-color: var(--primary-color);
    color: var(--text-primary);
    transform: translateX(-2px);
}

.back-button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Section visibility management */
.content-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================================================
   TYPOGRAPHY
   ============================================================================= */

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 2.5rem 0 1.5rem;
    line-height: 1.3;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 2rem 0 1rem;
    line-height: 1.4;
}

h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.5rem 0 1rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.7;
}

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

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

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

ul, ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

li {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* =============================================================================
   CODE BLOCKS AND SYNTAX HIGHLIGHTING
   ============================================================================= */

code {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background-color: var(--code-background);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

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

pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Copy button for code blocks */
.copy-code-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background-color: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.7;
}

.copy-code-btn:hover {
    opacity: 1;
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* =============================================================================
   INTERACTIVE COMPONENTS
   ============================================================================= */

/* Home page cards grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover {
    background-color: var(--surface-hover);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

.card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.card p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.5;
}

/* Section navigation breadcrumbs */
.section-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 2rem 0;
    padding: 1.5rem;
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.section-nav a {
    padding: 0.5rem 1rem;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

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

/* =============================================================================
   MEDIA AND CONTENT ELEMENTS
   ============================================================================= */

.image-container {
    margin: 2rem 0;
    text-align: center;
}

.image-container img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.image-caption {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Callout boxes for important information */
.note, .warning {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
    border-left: 4px solid;
}

.note {
    background-color: rgba(59, 130, 246, 0.1);
    border-left-color: var(--primary-color);
    color: var(--text-secondary);
}

.warning {
    background-color: rgba(239, 68, 68, 0.1);
    border-left-color: var(--error-color);
    color: var(--text-secondary);
}

.note strong, .warning strong {
    color: var(--text-primary);
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

/* Tablet and small desktop breakpoint */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    /* Reposition back button for tablet/mobile */
    .back-button {
        position: static;
        margin: 0 0 1.5rem 0;
        width: fit-content;
    }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .section-nav {
        flex-direction: column;
    }
    
    .content-wrapper {
        padding: 1.5rem 1rem;
        margin-top: 4rem;
    }
    
    pre {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    .copy-code-btn {
        top: 0.5rem;
        right: 0.5rem;
        font-size: 0.7rem;
    }
}

/* Small mobile breakpoint */
@media (max-width: 480px) {
    .sidebar-header {
        padding: 0 1rem 1.5rem;
    }
    
    .nav-section {
        padding: 0 1rem;
    }
    
    .search-container {
        padding: 0 1rem 0.75rem;
    }
    
    .search-clear-btn {
        font-size: 1rem;
        width: 1.25rem;
        height: 1.25rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .sidebar {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-section {
        display: block !important;
    }
    
    .section-nav {
        display: none;
    }
    
    .copy-code-btn {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    h1, h2, h3, h4 {
        color: black;
    }
    
    p, li {
        color: black;
    }
    
    pre {
        background: #f5f5f5;
        border: 1px solid #ddd;
    }
    
    .note, .warning {
        background: #f9f9f9;
        border: 1px solid #ddd;
    }
}

/* =============================================================================
   ACCESSIBILITY AND USER PREFERENCES
   ============================================================================= */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Focus styles for keyboard navigation */
.nav-link:focus:not(.active),
.card:focus,
.section-nav a:focus,
.mobile-menu-toggle:focus,
.search-input:focus,
.copy-code-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Text selection styling */
::selection {
    background-color: var(--primary-color);
    color: white;
}

/* Smooth scrolling with proper offset for anchor links */
html {
    scroll-padding-top: 2rem;
} 