/* ============================================
   CCompilter Tutorials - Complete Stylesheet
   Mobile-First Design with Responsive Layout
   ============================================ */

/* CSS Variables for easy theming */
:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --accent: #f093fb;
    --bg-light: #f5f7fa;
    --bg-white: #ffffff;
    --text-dark: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
    --code-bg: #1a202c;
    --success: #48bb78;
    --warning: #ed8936;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.7;
    color: var(--text-dark);
    background: var(--bg-light);
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; margin-top: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

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

a:hover {
    color: var(--primary-dark);
}

/* ============================================
   TOP NAVBAR
   ============================================ */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.navbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    color: white;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: all 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ============================================
   LAYOUT - Sidebar + Content
   ============================================ */
.page-wrapper {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 70px);
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    position: fixed;
    height: calc(100vh - 70px);
    overflow-y: auto;
    padding: 1.5rem;
    z-index: 100;
    transition: transform 0.3s ease;
}

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

.sidebar-header h3 {
    color: var(--primary);
    font-size: 1.1rem;
}

.sidebar-nav {
    list-style: none;
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-light);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.sidebar-nav a:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.sidebar-nav a.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin: 1.5rem 0 0.75rem;
    padding-left: 0.75rem;
}

/* Main Content Area */
.main-content {
    margin-left: 280px;
    flex: 1;
    padding: 2rem;
    max-width: calc(100% - 280px);
}

/* Breadcrumbs */
.breadcrumbs {
    background: var(--bg-white);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.breadcrumbs a {
    color: var(--primary);
}

.breadcrumbs span {
    color: var(--text-dark);
    font-weight: 500;
}

/* ============================================
   TUTORIAL CONTENT
   ============================================ */
.tutorial-container {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.tutorial-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 3px solid var(--border);
}

.topic-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

.tutorial-header h1 {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tutorial-header p {
    font-size: 1.15rem;
    color: var(--text-light);
}

/* Section Styling */
.content-section {
    margin-bottom: 3rem;
}

.content-section h2 {
    color: var(--text-dark);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.content-section h3 {
    color: var(--primary-dark);
    margin-top: 1.5rem;
}

.content-section ul,
.content-section ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.content-section li {
    margin-bottom: 0.5rem;
}

/* Algorithm Explanation Box */
.algo-explanation {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

.algo-explanation h4 {
    color: var(--primary-dark);
    margin-bottom: 0.75rem;
}

.algo-steps {
    background: var(--bg-white);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.algo-steps ol {
    margin-left: 1.25rem;
}

.algo-steps li {
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

/* Visual Diagram Placeholder */
.visual-box {
    background: var(--bg-light);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    margin: 1.5rem 0;
}

.visual-box h4 {
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* ============================================
   CODE BLOCKS - SCROLLABLE
   ============================================ */
.code-block {
    background: var(--code-bg);
    border-radius: var(--radius-lg);
    margin: 1.5rem 0;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

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

.code-header span {
    color: #a0aec0;
    font-size: 0.85rem;
    font-family: 'Monaco', 'Menlo', monospace;
}

.code-header button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.code-header button:hover {
    background: var(--primary-dark);
}

/* Scrollable Code Container */
.code-content {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: auto;
    padding: 1rem;
}

.code-content pre {
    margin: 0;
    white-space: pre;
    word-wrap: normal;
}

.code-content code {
    color: #e2e8f0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Syntax Highlighting */
.code-content .keyword { color: #c678dd; }
.code-content .string { color: #98c379; }
.code-content .comment { color: #5c6370; font-style: italic; }
.code-content .function { color: #61afef; }
.code-content .number { color: #d19a66; }

/* Scrollbar Styling */
.code-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.code-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.code-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}

.code-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    font-size: 0.95rem;
}

.data-table th {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover {
    background: var(--bg-light);
}

.data-table tr:nth-child(even) {
    background: rgba(102, 126, 234, 0.03);
}

/* Complexity Table Special */
.complexity-table th {
    background: #2d3748;
}

/* ============================================
   CARDS & GRIDS
   ============================================ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.info-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid var(--border);
}

.info-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.info-card h3 {
    color: var(--primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   NAVIGATION ARROWS
   ============================================ */
.page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
}

.page-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    font-weight: 500;
    transition: all 0.3s;
}

.page-nav a:hover {
    background: var(--primary);
    color: white;
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100%;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }
    
    .overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    .navbar-inner {
        flex-wrap: wrap;
    }
    
    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .tutorial-container {
        padding: 1.5rem;
    }
    
    .tutorial-header h1 {
        font-size: 1.75rem;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .page-nav {
        flex-direction: column;
        gap: 1rem;
    }
    
    .page-nav a {
        justify-content: center;
    }
    
    .code-content {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .tutorial-header h1 {
        font-size: 1.5rem;
    }
    
    .data-table {
        font-size: 0.85rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.625rem;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none; }

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    .page-nav {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100%;
    }
}
