/* ===== Dark Theme (default) ===== */
:root,
body.dark-theme {
    --md-sys-color-background: #121212;
    --md-sys-color-surface: #1e1e1e;
    --md-sys-color-surface-variant: #2d2d2d;
    --md-sys-color-on-background: #e2e2e2;
    --md-sys-color-on-surface: #e2e2e2;
    --md-sys-color-on-surface-variant: #a0a0a0;

    --md-sys-color-primary: #5c6bc0;
    --md-sys-color-primary-container: #3f51b5;
    --md-sys-color-on-primary: #ffffff;

    --md-sys-color-secondary: #2d2d2d;
    --md-sys-color-on-secondary: #e2e2e2;

    /* Terminal */
    --terminal-bg: #0a0a0a;
    --terminal-text: #f0f0f0;
    --terminal-green: #4caf50;
    --terminal-red: #f44336;
    --terminal-yellow: #ffeb3b;
    --terminal-blue: #2196f3;

    /* Surfaces */
    --app-bar-bg: rgba(18, 18, 18, 0.8);
    --border-color: rgba(255, 255, 255, 0.05);
    --hover-overlay: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.05);
    --card-border-hover: rgba(255, 255, 255, 0.1);
    --divider-color: rgba(255, 255, 255, 0.08);
    --body-gradient-start: #1e1e2e;
    --body-gradient-end: #121212;
    --terminal-header-bg: #1a1a1a;
    --terminal-border: #333;
    --terminal-glow: rgba(92, 107, 192, 0.1);
    --terminal-output: #ccc;
    --terminal-title-color: #666;
    --footer-copyright: #666;
    --badge-bg: rgba(92, 107, 192, 0.15);
    --icon-wrapper-bg: rgba(92, 107, 192, 0.1);
    --btn-primary-shadow: rgba(92, 107, 192, 0.3);
    --btn-primary-hover-shadow: rgba(92, 107, 192, 0.4);
    --btn-primary-hover-bg: #4f5eb5;
    --btn-secondary-hover-bg: #383838;
    --card-hover-shadow: 0 8px 12px -4px rgba(0, 0, 0, 0.4);

    /* Elevation Shadows */
    --elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    --elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    --elevation-4: 0px 4px 10px 4px rgba(0, 0, 0, 0.2), 0px 2px 4px -1px rgba(0, 0, 0, 0.3);
}

/* ===== Light Theme ===== */
body.light-theme {
    --md-sys-color-background: #f5f5f5;
    --md-sys-color-surface: #ffffff;
    --md-sys-color-surface-variant: #e8e8e8;
    --md-sys-color-on-background: #1a1a1a;
    --md-sys-color-on-surface: #1a1a1a;
    --md-sys-color-on-surface-variant: #5f5f5f;

    --md-sys-color-primary: #3f51b5;
    --md-sys-color-primary-container: #5c6bc0;
    --md-sys-color-on-primary: #ffffff;

    --md-sys-color-secondary: #e8e8e8;
    --md-sys-color-on-secondary: #1a1a1a;

    /* Terminal */
    --terminal-bg: #1e1e1e;
    --terminal-text: #f0f0f0;
    --terminal-green: #388e3c;
    --terminal-red: #d32f2f;
    --terminal-yellow: #f9a825;
    --terminal-blue: #1976d2;

    /* Surfaces */
    --app-bar-bg: rgba(255, 255, 255, 0.85);
    --border-color: rgba(0, 0, 0, 0.08);
    --hover-overlay: rgba(0, 0, 0, 0.05);
    --card-border: rgba(0, 0, 0, 0.08);
    --card-border-hover: rgba(0, 0, 0, 0.15);
    --divider-color: rgba(0, 0, 0, 0.1);
    --body-gradient-start: #e8eaf6;
    --body-gradient-end: #f5f5f5;
    --terminal-header-bg: #2d2d2d;
    --terminal-border: #333;
    --terminal-glow: rgba(63, 81, 181, 0.08);
    --terminal-output: #ccc;
    --terminal-title-color: #999;
    --footer-copyright: #999;
    --badge-bg: rgba(63, 81, 181, 0.1);
    --icon-wrapper-bg: rgba(63, 81, 181, 0.08);
    --btn-primary-shadow: rgba(63, 81, 181, 0.25);
    --btn-primary-hover-shadow: rgba(63, 81, 181, 0.35);
    --btn-primary-hover-bg: #3949ab;
    --btn-secondary-hover-bg: #ddd;
    --card-hover-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.12);

    /* Elevation Shadows */
    --elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(0, 0, 0, 0.04);
    --elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(0, 0, 0, 0.04);
    --elevation-4: 0px 4px 10px 4px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: radial-gradient(circle at 50% 0%, var(--body-gradient-start) 0%, var(--body-gradient-end) 60%);
    background-attachment: fixed;
    color: var(--md-sys-color-on-background);
    font-family: 'Roboto', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.5px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Top App Bar */
.top-app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: var(--app-bar-bg);
    backdrop-filter: blur(10px);
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.app-bar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    color: var(--md-sys-color-primary);
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
}

.nav-link:hover {
    color: var(--md-sys-color-on-surface);
}

.icon-link {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.icon-link:hover {
    background-color: var(--hover-overlay);
    color: var(--md-sys-color-on-surface);
}

/* Hero Section */
.hero-section {
    padding-top: 140px;
    padding-bottom: 80px;
    min-height: 80vh;
    display: flex;
    align-items: center;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: center;
}

.hero-content {
    max-width: 560px;
}

.hero-badge {
    display: inline-block;
    padding: 6px 12px;
    background-color: var(--badge-bg);
    color: var(--md-sys-color-primary);
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 24px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.hero-title {
    font-size: 56px;
    line-height: 1.1;
    margin-bottom: 24px;
    color: var(--md-sys-color-on-surface);
}

.highlight-text {
    color: var(--md-sys-color-primary);
}

.hero-subtitle {
    font-size: 18px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 40px;
    font-weight: 400;
    max-width: 480px;
}

.hero-actions {
    display: flex;
    gap: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 32px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.2px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: 0 4px 12px var(--btn-primary-shadow);
}

.btn-primary:hover {
    background-color: var(--btn-primary-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--btn-primary-hover-shadow);
}

.btn-secondary {
    background-color: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
}

.btn-secondary:hover {
    background-color: var(--btn-secondary-hover-bg);
}

/* Terminal Mockup */
.terminal-window {
    background-color: var(--terminal-bg);
    border-radius: 12px;
    border: 1px solid var(--terminal-border);
    overflow: hidden;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    color: var(--terminal-text);
    box-shadow: var(--elevation-4), 0 0 100px var(--terminal-glow); /* Glow */
    max-width: 500px;
    width: 100%;
    margin-left: auto;
}

.terminal-header {
    background-color: var(--terminal-header-bg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--terminal-border);
}

.terminal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.terminal-dot.red { background-color: #ff5f56; }
.terminal-dot.yellow { background-color: #ffbd2e; }
.terminal-dot.green { background-color: #27c93f; }

.terminal-title {
    margin-left: 12px;
    color: var(--terminal-title-color);
    font-size: 12px;
}

.terminal-body {
    padding: 20px;
    line-height: 1.6;
}

.line {
    margin-bottom: 4px;
}

.prompt {
    color: var(--terminal-green);
    margin-right: 8px;
    font-weight: bold;
}

.output {
    color: var(--terminal-output);
    padding-left: 16px;
}

.output.success { color: var(--terminal-green); }
.output.error { color: var(--terminal-red); }
.output.warning { color: var(--terminal-yellow); }
.output.info { color: var(--terminal-blue); font-weight: bold; margin-top: 8px; }

.cursor {
    animation: blink 1s step-end infinite;
    display: inline-block;
}

@keyframes blink { 50% { opacity: 0; } }

/* Features Section */
.features-section {
    padding: 80px 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
}

.feature-card {
    background-color: var(--md-sys-color-surface);
    border-radius: 24px; 
    padding: 32px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow);
    border-color: var(--card-border-hover);
}

.feature-icon-wrapper {
    background-color: var(--icon-wrapper-bg);
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.feature-icon {
    font-size: 28px;
    color: var(--md-sys-color-primary);
}

.feature-title {
    font-size: 22px;
    margin-bottom: 12px;
    color: var(--md-sys-color-on-surface);
}

.feature-desc {
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 24px;
    flex-grow: 1;
}

.feature-link {
    display: inline-flex;
    align-items: center;
    color: var(--md-sys-color-primary);
    font-weight: 500;
    font-size: 15px;
}

.feature-link .arrow {
    font-size: 18px;
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.feature-link:hover .arrow {
    transform: translateX(4px);
}

/* Footer (Matching Aniyomi) */
.footer {
    padding: 40px 0;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
}

.footer-links a:hover {
    color: var(--md-sys-color-primary);
    text-decoration: underline;
}

.footer-copyright {
    color: var(--footer-copyright);
    font-size: 12px;
}


/* Documentation Layout */
.doc-layout {
    display: flex;
    flex-direction: column;
}

.doc-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding-top: 64px; /* App bar height */
    width: 100%;
    flex: 1;
}

/* Sidebar */
.doc-sidebar {
    width: 280px;
    position: fixed;
    top: 64px;
    bottom: 0;
    left: max(0px, calc(50% - 700px)); /* Center within max-width */
    overflow-y: auto;
    padding: 32px 0 32px 24px;
    border-right: 1px solid var(--border-color);
    background-color: var(--md-sys-color-background); /* Ensure contrast */
    z-index: 100;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.doc-sidebar::-webkit-scrollbar {
    display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.doc-sidebar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.nav-group {
    margin-bottom: 32px;
}

.nav-group-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 12px;
    padding-left: 16px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin-bottom: 4px;
    font-size: 15px;
    color: var(--md-sys-color-on-surface-variant);
    border-radius: 0 24px 24px 0;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background-color: var(--hover-overlay);
    color: var(--md-sys-color-on-surface);
}

.sidebar-link.active {
    background-color: var(--badge-bg);
    color: var(--md-sys-color-primary);
    border-left-color: var(--md-sys-color-primary);
    font-weight: 500;
}

.chevron {
    font-size: 18px;
    opacity: 0.5;
}

/* Main Documentation Content */
.doc-content {
    margin-left: 280px; /* Width of sidebar */
    padding: 48px 64px;
    max-width: 900px;
    width: 100%;
    min-height: calc(100vh - 64px);
}

.breadcrumb {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 32px;
}

.breadcrumb a:hover {
    color: var(--md-sys-color-primary);
    text-decoration: underline;
}

.page-title {
    font-size: 48px;
    margin-bottom: 24px;
    color: var(--md-sys-color-on-surface);
    line-height: 1.1;
}

.page-lead {
    font-size: 20px;
    line-height: 1.6;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 40px;
    max-width: 720px;
}

.section-title {
    font-size: 32px;
    margin: 48px 0 24px;
    color: var(--md-sys-color-on-surface);
    scroll-margin-top: 80px; /* Offset for sticky header */
}

h3 {
    font-size: 24px;
    margin: 32px 0 16px;
    color: var(--md-sys-color-on-surface);
}

.doc-divider {
    height: 1px;
    background-color: var(--divider-color);
    border: none;
    margin: 48px 0;
}

/* Responsive */
@media (max-width: 900px) {
    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 64px;
    }

    .hero-content {
        margin: 0 auto;
    }

    .hero-actions {
        justify-content: center;
    }

    .terminal-window {
        margin: 0 auto;
    }

    .feature-card {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .features-grid {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: 40px;
    }

    .nav-links {
        display: none; /* Simple mobile nav hiding for now */
    }
}

/* ===== Theme Toggle Button ===== */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0;
}

.theme-toggle:hover {
    background-color: var(--hover-overlay);
    color: var(--md-sys-color-on-surface);
}

.theme-toggle .material-icons {
    font-size: 22px;
    transition: transform 0.3s ease;
}

.theme-toggle:active .material-icons {
    transform: rotate(30deg);
}

/* Show/hide icons based on theme */
body.dark-theme .theme-toggle .icon-light { display: inline; }
body.dark-theme .theme-toggle .icon-dark  { display: none;   }
body.light-theme .theme-toggle .icon-light { display: none;   }
body.light-theme .theme-toggle .icon-dark  { display: inline; }

/* Smooth theme transition */
body, body * {
    transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
/* Exclude the cursor blink and hover transforms from transition */
.cursor, .btn, .feature-card, .feature-link .arrow {
    transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

/* ===== Logo Image ===== */
.logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}

/* ===== Code Block with Copy Button ===== */
.code-block {
    background-color: var(--terminal-bg);
    border: 1px solid var(--terminal-border);
    border-radius: 12px;
    overflow: hidden;
    margin: 16px 0 24px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
}

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

.code-block-lang {
    font-size: 12px;
    font-weight: 500;
    color: var(--terminal-title-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid var(--terminal-border);
    border-radius: 6px;
    background: transparent;
    color: var(--terminal-title-color);
    font-size: 12px;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    color: var(--terminal-text);
    border-color: var(--terminal-text);
    background-color: rgba(255, 255, 255, 0.05);
}

.copy-btn.copied {
    color: var(--terminal-green);
    border-color: var(--terminal-green);
}

.copy-btn .material-icons {
    font-size: 16px;
}

.copy-label {
    font-weight: 500;
}

.code-block pre {
    margin: 0;
    padding: 20px;
    overflow-x: auto;
    color: var(--terminal-text);
    line-height: 1.6;
}

.code-block code {
    font-family: inherit;
    font-size: inherit;
    background: none;
    padding: 0;
    color: inherit;
}

/* ===== Note / Tip Box ===== */
.note-box {
    background-color: var(--badge-bg);
    border-left: 4px solid var(--md-sys-color-primary);
    border-radius: 0 12px 12px 0;
    padding: 16px 20px;
    margin: 20px 0;
    font-size: 15px;
    color: var(--md-sys-color-on-surface);
    line-height: 1.6;
}

.note-box strong {
    color: var(--md-sys-color-primary);
}

.note-box code {
    background-color: var(--hover-overlay);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* ===== Inline code ===== */
article code {
    background-color: var(--hover-overlay);
    color: var(--md-sys-color-primary);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

/* Don't double-style code inside code-block */
.code-block code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

/* ===== Article typography ===== */
article p {
    font-size: 16px;
    line-height: 1.7;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 12px;
}

/* ===== Doc Tables ===== */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 28px;
    font-size: 15px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--card-border);
}

.doc-table thead {
    background-color: var(--md-sys-color-surface-variant);
}

.doc-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface);
    border-bottom: 2px solid var(--card-border);
}

.doc-table td {
    padding: 12px 16px;
    color: var(--md-sys-color-on-surface);
    border-bottom: 1px solid var(--card-border);
    vertical-align: top;
}

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

.doc-table tbody tr:hover {
    background-color: var(--hover-overlay);
}

.doc-table code {
    font-size: 0.85em;
}

/* ===== Architecture Flow Diagram ===== */
.arch-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 32px 0 40px;
    flex-wrap: wrap;
}

.arch-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 24px;
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    min-width: 130px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.arch-step:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-hover-shadow);
    border-color: var(--md-sys-color-primary);
}

.arch-step .material-icons {
    font-size: 28px;
    color: var(--md-sys-color-primary);
}

.arch-step strong {
    font-size: 15px;
    color: var(--md-sys-color-on-surface);
}

.arch-step small {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.3;
}

.arch-arrow {
    font-size: 24px;
    color: var(--md-sys-color-on-surface-variant);
}

/* ===== Article h4 ===== */
article h4 {
    font-size: 18px;
    margin: 28px 0 8px;
    color: var(--md-sys-color-on-surface);
}

@media (max-width: 768px) {
    .arch-flow {
        flex-direction: column;
    }
    .arch-arrow {
        transform: rotate(90deg);
    }
}
