@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-primary: #0D1117;
    --bg-secondary: #161B22;
    --bg-tertiary: #21262D;
    --azure-blue: #58A6FF;
    --azure-orange: #F78166;
    --azure-green: #7EE787;
    --azure-purple: #D2A8FF;
    --azure-cyan: #79C0FF;
    --azure-yellow: #E3B341;
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --border-primary: #30363D;
    /* Syntax highlighting */
    --syntax-keyword: #FF7B72;
    --syntax-string: #A5D6FF;
    --syntax-comment: #8B949E;
    --syntax-tag: #7EE787;
    --syntax-attr: #79C0FF;
    --syntax-value: #A5D6FF;
    --syntax-punctuation: #8B949E;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Progress Bar */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--azure-blue), var(--azure-purple), var(--azure-orange));
    z-index: 1000;
    transition: width 0.1s ease-out;
    box-shadow: 0 0 10px var(--azure-blue);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.8;
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    font-size: 16px;
}

h1 { font-size: 2.2rem; text-align: center; background: linear-gradient(135deg, var(--azure-blue), var(--azure-orange)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 0.5rem; }
.subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 2rem; }
h2 { font-size: 1.5rem; color: var(--azure-blue); margin: 3rem 0 1.5rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--border-primary); }
h3 { font-size: 1.2rem; color: var(--text-primary); margin: 2rem 0 1rem; }
h4 { font-size: 1rem; color: var(--azure-orange); margin: 1.5rem 0 0.75rem; }
p { margin: 1rem 0; }

/* Code blocks with copy button */
.code-container {
    position: relative;
    margin: 1rem 0;
}
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}
.code-container:hover .copy-btn {
    opacity: 1;
}
.copy-btn:hover {
    background: var(--azure-blue);
    color: white;
    border-color: var(--azure-blue);
}
.copy-btn.copied {
    background: var(--azure-green);
    color: #0D1117;
    border-color: var(--azure-green);
}

pre { 
    background: var(--bg-secondary); 
    border: 1px solid var(--border-primary); 
    border-radius: 8px; 
    padding: 1rem; 
    overflow-x: auto; 
    margin: 0;
    position: relative;
}
code { font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; line-height: 1.6; }
:not(pre) > code { background: var(--bg-tertiary); color: var(--azure-cyan); padding: 0.2rem 0.4rem; border-radius: 4px; }

/* Syntax highlighting classes */
.xml-tag { color: var(--syntax-tag); }
.xml-attr { color: var(--syntax-attr); }
.xml-value { color: var(--syntax-value); }
.xml-comment { color: var(--syntax-comment); font-style: italic; }
.xml-punct { color: var(--syntax-punctuation); }
.kw { color: var(--syntax-keyword); font-weight: 500; }
.str { color: var(--syntax-string); }
.cmt { color: var(--syntax-comment); font-style: italic; }
.fn { color: var(--azure-purple); }
.op { color: var(--azure-orange); }
.num { color: var(--azure-cyan); }

table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; border: 1px solid var(--border-primary); border-radius: 8px; overflow: hidden; }
th { background: var(--bg-tertiary); color: var(--azure-blue); font-weight: 600; padding: 0.75rem 1rem; text-align: left; }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-primary); }
tr:last-child td { border-bottom: none; }

ul, ol { padding-left: 1.5rem; margin: 1rem 0; }
li { margin-bottom: 0.5rem; }
hr { border: none; height: 1px; background: linear-gradient(90deg, transparent, var(--border-primary), transparent); margin: 3rem 0; }
strong { color: var(--azure-orange); }

.callout { border-radius: 8px; padding: 1rem 1.25rem; margin: 1.5rem 0; border-left: 4px solid; }
.callout-title { font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; display: block; }
.attention { background: rgba(247, 129, 102, 0.1); border-color: var(--azure-orange); }
.attention .callout-title { color: var(--azure-orange); }
.exam { background: rgba(88, 166, 255, 0.1); border-color: var(--azure-blue); }
.exam .callout-title { color: var(--azure-blue); }
.definition { background: rgba(210, 168, 255, 0.1); border-color: var(--azure-purple); }
.definition .callout-title { color: var(--azure-purple); }

.nav-container { position: sticky; top: 3px; background: var(--bg-primary); border-bottom: 1px solid var(--border-primary); z-index: 100; margin: -2rem -1.5rem 2rem; padding: 0 1.5rem; }
.nav-header { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; }
.nav-title { color: var(--azure-blue); font-weight: 600; font-size: 0.9rem; margin: 0; text-decoration: none; }
.nav-toggle { background: var(--bg-tertiary); border: 1px solid var(--border-primary); color: var(--azure-cyan); padding: 0.4rem 0.8rem; border-radius: 6px; cursor: pointer; font-size: 0.8rem; }
.nav-menu { display: none; padding: 0.5rem 0 1rem; }
.nav-menu.open { display: block; }
.nav-menu ul { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 0; justify-content: center; }
.nav-menu a { color: var(--azure-cyan); text-decoration: none; padding: 0.4rem 0.6rem; border-radius: 4px; font-size: 0.8rem; background: var(--bg-tertiary); }
.nav-menu a:hover, .nav-menu a.active { background: var(--azure-blue); color: white; }

details { background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: 8px; margin: 1rem 0; }
summary { padding: 1rem; cursor: pointer; font-weight: 600; color: var(--azure-cyan); }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+ "; }
details[open] summary::before { content: "- "; }
details > div { padding: 0 1rem 1rem; }

/* Improved diagrams with consistent colors */
.diagram { 
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(88, 166, 255, 0.05) 100%); 
    border: 1px solid var(--azure-blue); 
    border-radius: 12px; 
    padding: 1.5rem; 
    margin: 1.5rem 0;
    box-shadow: 0 4px 20px rgba(88, 166, 255, 0.1);
}
.diagram-title { 
    color: var(--azure-blue); 
    font-weight: 600; 
    margin-bottom: 1rem; 
    text-align: center;
    font-size: 1.05rem;
}
.hierarchy-item { 
    padding: 0.5rem 1rem; 
    margin: 0.3rem 0; 
    border-radius: 6px; 
    display: inline-block;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.hierarchy-level-0 { background: linear-gradient(135deg, var(--azure-blue), #4090E0); color: #ffffff; }
.hierarchy-level-1 { background: linear-gradient(135deg, var(--azure-purple), #B080E0); color: #ffffff; margin-left: 1.5rem; }
.hierarchy-level-2 { background: linear-gradient(135deg, var(--azure-cyan), #60A0D0); color: #0D1117; margin-left: 3rem; }
.hierarchy-level-3 { background: linear-gradient(135deg, var(--azure-green), #60C070); color: #0D1117; margin-left: 4.5rem; }

/* Image styling */
.image-grid { margin: 1.5rem 0; }
.image-card { 
    background: var(--bg-secondary); 
    border: 1px solid var(--border-primary); 
    border-radius: 12px; 
    padding: 1rem; 
    text-align: center;
}
.image-card img { 
    max-width: 100%; 
    height: auto; 
    border-radius: 8px;
    border: 1px solid var(--border-primary);
}
.image-card .caption { 
    color: var(--text-secondary); 
    font-size: 0.85rem; 
    margin-top: 0.75rem;
    font-style: italic;
}

.cards-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card { 
    background: var(--bg-secondary); 
    border: 1px solid var(--border-primary); 
    border-radius: 10px; 
    padding: 1.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}
.card:hover {
    border-color: var(--azure-cyan);
    box-shadow: 0 4px 12px rgba(121, 192, 255, 0.1);
}
.card h5 { color: var(--azure-cyan); margin: 0 0 0.75rem; font-size: 1rem; }
.card pre { 
    font-size: 0.75rem; 
    margin-top: 0.75rem; 
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-primary) transparent;
}
.card pre::-webkit-scrollbar { height: 6px; }
.card pre::-webkit-scrollbar-track { background: transparent; }
.card pre::-webkit-scrollbar-thumb { background: var(--border-primary); border-radius: 3px; }

.quiz { background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: 12px; padding: 1.5rem; margin: 2rem 0; }
.quiz h4 { color: var(--azure-purple); margin-top: 0; }
.quiz-options label { display: block; padding: 0.75rem 1rem; margin: 0.5rem 0; background: var(--bg-tertiary); border-radius: 6px; cursor: pointer; transition: all 0.2s ease; }
.quiz-options label:hover { background: rgba(88, 166, 255, 0.1); }
.quiz-btn { background: var(--azure-blue); color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 6px; cursor: pointer; font-weight: 600; margin-top: 1rem; transition: all 0.2s ease; }
.quiz-btn:hover { background: #4090E0; transform: translateY(-1px); }
.quiz-result { margin-top: 1rem; padding: 1rem; border-radius: 6px; display: none; }
.quiz-result.correct { background: rgba(126, 231, 135, 0.2); color: var(--azure-green); }
.quiz-result.incorrect { background: rgba(247, 129, 102, 0.2); color: var(--azure-orange); }

.scenario { background: var(--bg-secondary); border: 1px solid var(--azure-purple); border-radius: 8px; padding: 1.25rem; margin: 1.5rem 0; }
.scenario-title { color: var(--azure-purple); font-weight: 600; font-size: 1rem; margin-bottom: 0.75rem; }
.scenario-context { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px dashed var(--border-primary); }
.scenario-options label { display: block; padding: 0.6rem 1rem; margin: 0.4rem 0; background: var(--bg-tertiary); border-radius: 6px; cursor: pointer; font-size: 0.9rem; border: 1px solid transparent; transition: all 0.2s ease; }
.scenario-options label:hover { background: rgba(210, 168, 255, 0.15); border-color: var(--azure-purple); }
.scenario-btn { background: var(--azure-purple); color: #0D1117; border: none; padding: 0.6rem 1.25rem; border-radius: 6px; cursor: pointer; font-weight: 600; margin-top: 0.75rem; }
.scenario-result { margin-top: 1rem; padding: 1rem; border-radius: 6px; display: none; font-size: 0.9rem; }
.scenario-result.correct { background: rgba(126, 231, 135, 0.15); border: 1px solid var(--azure-green); }
.scenario-result.incorrect { background: rgba(247, 129, 102, 0.15); border: 1px solid var(--azure-orange); }

.cheat-sheet { background: linear-gradient(135deg, rgba(227, 179, 65, 0.05), rgba(88, 166, 255, 0.05)); border: 2px solid var(--azure-yellow); border-radius: 12px; padding: 2rem; margin: 2rem 0; }
.cheat-sheet > h4 { color: var(--azure-yellow); margin: 0 0 1.5rem 0; font-size: 1.2rem; padding-bottom: 0.75rem; border-bottom: 2px solid rgba(227, 179, 65, 0.3); text-align: center; }
.cheat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.cheat-section { background: var(--bg-secondary); border-radius: 10px; padding: 1.25rem; border-left: 4px solid var(--azure-blue); transition: transform 0.2s, box-shadow 0.2s; }
.cheat-section:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(88, 166, 255, 0.15); }
.cheat-section h5 { color: var(--azure-blue); margin: 0 0 1rem 0; font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.cheat-section h5::before { content: ""; width: 8px; height: 8px; background: var(--azure-blue); border-radius: 50%; }
.cheat-section.dtd { border-left-color: var(--azure-purple); }
.cheat-section.dtd h5 { color: var(--azure-purple); }
.cheat-section.dtd h5::before { background: var(--azure-purple); }
.cheat-section.xpath { border-left-color: var(--azure-cyan); }
.cheat-section.xpath h5 { color: var(--azure-cyan); }
.cheat-section.xpath h5::before { background: var(--azure-cyan); }
.cheat-section.xquery { border-left-color: var(--azure-green); }
.cheat-section.xquery h5 { color: var(--azure-green); }
.cheat-section.xquery h5::before { background: var(--azure-green); }
.cheat-section.mongodb { border-left-color: var(--azure-orange); }
.cheat-section.mongodb h5 { color: var(--azure-orange); }
.cheat-section.mongodb h5::before { background: var(--azure-orange); }
.cheat-section.warning { border-left-color: #ff6b6b; }
.cheat-section.warning h5 { color: #ff6b6b; }
.cheat-section.warning h5::before { background: #ff6b6b; }
.cheat-item { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0; border-bottom: 1px dotted var(--border-primary); font-size: 0.9rem; gap: 1rem; }
.cheat-item:last-child { border-bottom: none; }
.cheat-key { color: var(--text-secondary); flex: 1; }
.cheat-value { color: var(--azure-cyan); font-family: 'JetBrains Mono', monospace; font-weight: 600; background: var(--bg-tertiary); padding: 0.25rem 0.6rem; border-radius: 5px; font-size: 0.85rem; white-space: nowrap; }
.cheat-value.danger { color: var(--azure-orange); background: rgba(247, 129, 102, 0.15); }
.cheat-value.success { color: var(--azure-green); background: rgba(126, 231, 135, 0.15); }
.cheat-code { background: var(--bg-tertiary); border-radius: 6px; padding: 0.75rem 1rem; margin: 0.75rem 0; font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; color: var(--azure-cyan); border: 1px solid var(--border-primary); overflow-x: auto; }
.cheat-code .comment { color: #6a9955; font-style: italic; }
.cheat-code .keyword { color: var(--azure-purple); font-weight: 600; }
.cheat-code .tag { color: var(--azure-blue); }
.cheat-code .attr { color: var(--azure-orange); }
.cheat-example { background: rgba(126, 231, 135, 0.1); border-left: 3px solid var(--azure-green); padding: 0.5rem 0.75rem; margin: 0.5rem 0; border-radius: 0 6px 6px 0; font-size: 0.85rem; }
.cheat-example strong { color: var(--azure-green); }

/* Exercise styles */
.exercise { background: linear-gradient(135deg, rgba(88, 166, 255, 0.08), rgba(126, 231, 135, 0.08)); border: 2px solid var(--azure-green); border-radius: 10px; padding: 1.25rem; margin: 1.5rem 0; }
.exercise-title { color: var(--azure-green); font-weight: 700; font-size: 1.05rem; margin-bottom: 0.75rem; }
.exercise ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.exercise ol li { margin: 0.5rem 0; color: var(--text-secondary); }
.exercise details { background: var(--bg-tertiary); border-color: var(--azure-green); margin-top: 1rem; }
.exercise details summary { color: var(--azure-green); font-size: 0.95rem; }

.case-study { background: linear-gradient(135deg, rgba(88, 166, 255, 0.05), rgba(210, 168, 255, 0.05)); border: 2px solid var(--azure-blue); border-radius: 10px; padding: 1.5rem; margin: 2rem 0; }
.case-study-title { color: var(--azure-blue); font-weight: 700; font-size: 1.15rem; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border-primary); }
.arch-box { border: 2px solid var(--azure-blue); border-radius: 8px; padding: 1rem; margin: 0.5rem 0; background: linear-gradient(135deg, var(--bg-tertiary), rgba(88, 166, 255, 0.1)); text-align: center; box-shadow: 0 2px 10px rgba(88, 166, 255, 0.15); }

.dashboard { background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: 12px; padding: 1.5rem; margin: 2rem 0; }
.dashboard h4 { color: var(--azure-blue); margin-top: 0; border-bottom: 1px solid var(--border-primary); padding-bottom: 0.75rem; }

/* Navigation inter-pages */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin: 3rem 0 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-primary);
}
.nav-buttons a {
    background: var(--bg-tertiary);
    color: var(--azure-cyan);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    transition: all 0.2s ease;
    font-weight: 500;
}
.nav-buttons a:hover {
    background: var(--azure-blue);
    color: white;
    border-color: var(--azure-blue);
}
.nav-buttons a.nav-prev::before { content: "← "; }
.nav-buttons a.nav-next::after { content: " →"; }

@media (max-width: 768px) {
    body { padding: 1rem; font-size: 15px; }
    h1 { font-size: 1.6rem; }
    .nav-menu ul { flex-direction: column; align-items: stretch; }
    .cheat-grid { grid-template-columns: 1fr; }
    .cheat-item { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
    .copy-btn { opacity: 1; }
    .nav-buttons { flex-direction: column; gap: 1rem; }
    .nav-buttons a { text-align: center; }
}

/* Override Prism theme to match our design */
pre[class*="language-"], code[class*="language-"] {
    background: var(--bg-secondary) !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 0.9rem !important;
}
pre[class*="language-"] {
    border: 1px solid var(--border-primary) !important;
    border-radius: 8px !important;
    margin: 0 !important;
}
.token.tag { color: #7EE787 !important; }
.token.attr-name { color: #79C0FF !important; }
.token.attr-value { color: #A5D6FF !important; }
.token.comment { color: #8B949E !important; }
.token.keyword { color: #FF7B72 !important; }
.token.string { color: #A5D6FF !important; }
.token.function { color: #D2A8FF !important; }
.token.number { color: #79C0FF !important; }
.token.operator { color: #FF7B72 !important; }
.token.punctuation { color: #8B949E !important; }
