/* ============================================
   ADSA Mini-Book - Common Styles
   Advanced Data Structures & Algorithms
   Mumbai University - Semester 3
   ============================================ */

/* CSS Variables for Dark Theme */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;
    --bg-code: #0d1117;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-purple: #a371f7;
    --accent-orange: #d29922;
    --accent-red: #f85149;
    --accent-cyan: #39c5cf;
    --accent-pink: #db61a2;

    --border-color: #30363d;
    --border-light: #21262d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Oxygen', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
}

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

h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 2rem;
    color: var(--accent-blue);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 3rem;
}

h3 {
    font-size: 1.5rem;
    color: var(--accent-purple);
    margin-top: 2rem;
}

h4 {
    font-size: 1.25rem;
    color: var(--accent-cyan);
    margin-top: 1.5rem;
}

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

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

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

/* Main Container */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 2rem 4rem;
}

/* Content Sections */
.section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.section-title .icon {
    font-size: 1.5rem;
}

/* Module Header */
.module-header {
    text-align: center;
    padding: 3rem 2rem;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-radius: var(--radius-lg);
    margin-bottom: 3rem;
    border: 1px solid var(--border-color);
}

.module-number {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.module-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.module-description {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Topic Navigation */
.topic-nav {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.topic-nav-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.topic-nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
}

.topic-nav-item a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.topic-nav-item a:hover {
    background: var(--accent-blue);
    color: white;
    text-decoration: none;
    border-color: var(--accent-blue);
}

/* Code Blocks */
.code-block {
    background: var(--bg-code);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.code-language {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-copy {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.code-copy:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.code-content {
    padding: 1.25rem;
    overflow-x: auto;
}

.code-content pre {
    margin: 0;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.code-content code {
    font-family: inherit;
}

/* Inline Code */
code:not(pre code) {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875em;
    color: var(--accent-orange);
}

/* Algorithm Box */
.algorithm-box {
    background: var(--bg-card);
    border: 1px solid var(--accent-purple);
    border-left: 4px solid var(--accent-purple);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.algorithm-title {
    color: var(--accent-purple);
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.algorithm-steps {
    list-style: none;
    counter-reset: step;
}

.algorithm-steps li {
    counter-increment: step;
    padding: 0.5rem 0 0.5rem 2.5rem;
    position: relative;
    color: var(--text-secondary);
}

.algorithm-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    background: var(--accent-purple);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Definition Box */
.definition-box {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.1), rgba(163, 113, 247, 0.1));
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.definition-term {
    color: var(--accent-blue);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.definition-text {
    color: var(--text-secondary);
}

/* Formula Box */
.formula-box {
    background: var(--bg-card);
    border: 1px solid var(--accent-orange);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
    text-align: center;
}

.formula {
    font-family: 'Times New Roman', serif;
    font-size: 1.25rem;
    color: var(--accent-orange);
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    display: inline-block;
    margin: 0.5rem 0;
}

.formula-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Example Box */
.example-box {
    background: var(--bg-card);
    border: 1px solid var(--accent-green);
    border-left: 4px solid var(--accent-green);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.example-title {
    color: var(--accent-green);
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Question Box (Exam Style) */
.question-box {
    background: var(--bg-card);
    border: 1px solid var(--accent-cyan);
    border-radius: var(--radius-md);
    margin: 2rem 0;
    overflow: hidden;
}

.question-header {
    background: linear-gradient(135deg, rgba(57, 197, 207, 0.2), rgba(88, 166, 255, 0.2));
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.question-label {
    color: var(--accent-cyan);
    font-weight: 600;
}

.question-marks {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
}

.question-content {
    padding: 1.5rem;
}

.question-text {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 1rem;
}

.answer-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}

.answer-label {
    color: var(--accent-green);
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Complexity Table */
.complexity-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.complexity-table th,
.complexity-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.complexity-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.complexity-table td {
    color: var(--text-secondary);
}

.complexity-table tr:last-child td {
    border-bottom: none;
}

.complexity-table tr:hover td {
    background: var(--bg-tertiary);
}

.complexity-best {
    color: var(--accent-green) !important;
}

.complexity-avg {
    color: var(--accent-orange) !important;
}

.complexity-worst {
    color: var(--accent-red) !important;
}

/* Diagram Container */
.diagram-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    margin: 1.5rem 0;
    text-align: center;
}

.diagram-title {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.diagram {
    display: inline-block;
    text-align: left;
}

/* Tree Diagram */
.tree-diagram {
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text-primary);
    white-space: pre;
}

/* Graph Diagram */
.graph-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

/* Node styling */
.node {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: white;
    font-weight: 600;
    margin: 0.25rem;
}

.node.visited {
    background: var(--accent-green);
}

.node.current {
    background: var(--accent-orange);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Comparison Box */
.comparison-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.comparison-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.comparison-item.left {
    border-top: 3px solid var(--accent-blue);
}

.comparison-item.right {
    border-top: 3px solid var(--accent-purple);
}

.comparison-title {
    font-weight: 600;
    margin-bottom: 1rem;
}

.comparison-item.left .comparison-title {
    color: var(--accent-blue);
}

.comparison-item.right .comparison-title {
    color: var(--accent-purple);
}

/* Tip/Note/Warning Boxes */
.info-box {
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.info-box .icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.info-box.tip {
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid var(--accent-green);
}

.info-box.tip .icon {
    color: var(--accent-green);
}

.info-box.note {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid var(--accent-blue);
}

.info-box.note .icon {
    color: var(--accent-blue);
}

.info-box.warning {
    background: rgba(210, 153, 34, 0.1);
    border: 1px solid var(--accent-orange);
}

.info-box.warning .icon {
    color: var(--accent-orange);
}

.info-box.exam-tip {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--accent-red);
}

.info-box.exam-tip .icon {
    color: var(--accent-red);
}

/* Step-by-Step Container */
.steps-container {
    margin: 1.5rem 0;
}

.step {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px dashed var(--border-color);
}

.step:last-child {
    border-bottom: none;
}

.step-number {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.step-content {
    flex: 1;
}

.step-title {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.step-desc {
    color: var(--text-secondary);
}

/* Lists */
ul, ol {
    margin: 1rem 0 1rem 1.5rem;
    color: var(--text-secondary);
}

li {
    margin-bottom: 0.5rem;
}

ul li::marker {
    color: var(--accent-blue);
}

ol li::marker {
    color: var(--accent-purple);
}

/* Key Points */
.key-points {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.key-points-title {
    color: var(--accent-pink);
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.key-points ul {
    list-style: none;
    margin: 0;
}

.key-points li {
    padding-left: 1.5rem;
    position: relative;
}

.key-points li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--accent-green);
    font-weight: bold;
}

/* Table of Contents */
.toc {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
}

.toc-title {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.toc-list {
    list-style: none;
    margin: 0;
}

.toc-list li {
    margin: 0;
}

.toc-list a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.toc-list a:hover {
    background: var(--bg-tertiary);
    color: var(--accent-blue);
    text-decoration: none;
}

.toc-list a .toc-number {
    color: var(--accent-purple);
    font-weight: 600;
    margin-right: 0.75rem;
}

/* Collapsible Sections */
.collapsible {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 1rem 0;
    overflow: hidden;
}

.collapsible-header {
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background var(--transition-fast);
}

.collapsible-header:hover {
    background: var(--bg-secondary);
}

.collapsible-title {
    color: var(--text-primary);
    font-weight: 600;
}

.collapsible-icon {
    color: var(--accent-blue);
    font-size: 1.25rem;
    transition: transform var(--transition-normal);
}

.collapsible.open .collapsible-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
}

.collapsible.open .collapsible-content {
    max-height: 2000px;
}

.collapsible-body {
    padding: 1.5rem;
}

/* Progress Bar */
.progress-container {
    margin: 2rem 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 4px;
    transition: width 0.5s ease;
}

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

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.nav-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    text-decoration: none;
}

.nav-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--accent-purple);
    transform: translateY(-3px);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* Selection */
::selection {
    background: var(--accent-blue);
    color: white;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.highlight-blue { color: var(--accent-blue); }
.highlight-green { color: var(--accent-green); }
.highlight-purple { color: var(--accent-purple); }
.highlight-orange { color: var(--accent-orange); }
.highlight-red { color: var(--accent-red); }

/* Matrix Display */
.matrix {
    display: inline-block;
    margin: 1rem;
    font-family: 'Fira Code', monospace;
}

.matrix-row {
    display: flex;
}

.matrix-cell {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.matrix-cell.highlight {
    background: var(--accent-blue);
    color: white;
}

.matrix-cell.header {
    background: var(--bg-secondary);
    color: var(--accent-purple);
    font-weight: 600;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

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

/* Responsive Adjustments (minimal since desktop only) */
@media (max-width: 1400px) {
    .container {
        padding: 2rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .section {
        break-inside: avoid;
    }

    .nav-buttons,
    .back-to-top,
    .topic-nav {
        display: none;
    }
}
