/* ============================================
   CSS VARIABLES & THEME
   ============================================ */
:root {
    --bg: #f5f7fa;
    --bg-alt: #eef1f6;
    --text: #1c1f24;
    --text-muted: #6b7280;
    --card: #ffffff;
    --card-hover: #f9fafb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #dbeafe;
    --accent-soft: #eff6ff;
    --border: rgba(0,0,0,0.08);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --header-bg: #0f172a;
    --header-text: #e2e8f0;
    --code-bg: #f1f5f9;
    --pre-bg: #0f172a;
    --pre-text: #e2e8f0;
    --green: #16a34a;
    --green-light: #dcfce7;
    --orange: #ea580c;
    --orange-light: #fff7ed;
    --red: #dc2626;
    --red-light: #fef2f2;
    --purple: #7c3aed;
    --purple-light: #f5f3ff;
    --teal: #0d9488;
    --teal-light: #ccfbf1;
    --radius: 10px;
    --radius-lg: 14px;
}

[data-theme="dark"] {
    --bg: #0b0f19;
    --bg-alt: #111827;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --card: #1e293b;
    --card-hover: #263548;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-light: #1e3a5f;
    --accent-soft: #172554;
    --border: rgba(255,255,255,0.08);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    --code-bg: #1e293b;
    --green-light: #052e16;
    --orange-light: #431407;
    --red-light: #450a0a;
    --purple-light: #2e1065;
    --teal-light: #042f2e;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background 0.25s, color 0.25s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ============================================
   HEADER
   ============================================ */
.header {
    background: var(--header-bg);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 1px 8px rgba(0,0,0,0.15);
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 54px;
}
.logo {
    color: #fff;
    font-size: 1.15em;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.02em;
}
.logo:hover { text-decoration: none; color: #fff; }
.logo span { color: var(--accent); }

.header-right { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95em;
    transition: 0.2s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.15); }

/* Hamburger */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    z-index: 1002;
}
.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    margin: 4px 0;
    border-radius: 2px;
    transition: all 0.3s ease;
}
.menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ============================================
   NAVIGATION
   ============================================ */
.nav { display: flex; gap: 0; align-items: center; }
.nav-item { position: relative; }
.nav-item > a {
    color: var(--header-text);
    text-decoration: none;
    padding: 8px 11px;
    display: block;
    font-size: 0.82em;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    transition: 0.2s;
}
.nav-item > a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}

.dropdown {
    display: none !important;
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    z-index: 1001;
    padding: 6px;
    margin-top: 4px;
}
.dropdown a {
    color: var(--text) !important;
    padding: 8px 12px;
    display: block;
    text-decoration: none !important;
    font-size: 0.82em;
    border-radius: 6px;
    transition: 0.15s;
}
.dropdown a:hover { background: var(--accent-soft); color: var(--accent) !important; }
.nav-item:hover > .dropdown { display: block !important; visibility: visible; opacity: 1; }

/* ============================================
   HERO SECTION (Homepage)
   ============================================ */
.hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    padding: 48px 20px 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 30% 50%, rgba(37,99,235,0.1) 0%, transparent 60%),
                radial-gradient(ellipse at 70% 40%, rgba(124,58,237,0.07) 0%, transparent 60%);
    pointer-events: none;
}
.hero-content { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; }
.hero h1 { color: #fff; font-size: 2.1em; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.02em; line-height: 1.2; }
.hero h1 em { font-style: normal; color: #60a5fa; }
.hero p { color: #94a3b8; font-size: 1.02em; line-height: 1.6; margin-bottom: 22px; }

.hero-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88em;
    transition: 0.2s;
    text-decoration: none !important;
}
.hero-btn.primary { background: var(--accent); color: #fff; }
.hero-btn.primary:hover { background: var(--accent-hover); }
.hero-btn.secondary { background: rgba(255,255,255,0.08); color: #e2e8f0; border: 1px solid rgba(255,255,255,0.12); }
.hero-btn.secondary:hover { background: rgba(255,255,255,0.14); }

/* ============================================
   SECTION TITLES
   ============================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 36px 0 16px;
}
.section-header:first-child { margin-top: 28px; }
.section-title {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.section-link { font-size: 0.82em; font-weight: 500; }

/* ============================================
   QUICK-ACCESS GRID
   ============================================ */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.quick-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-decoration: none !important;
    color: var(--text);
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}
.quick-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
    color: var(--text);
}
.quick-icon {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    flex-shrink: 0;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}
.qi-blue { background: var(--accent-light); color: var(--accent); }
.qi-green { background: var(--green-light); color: var(--green); }
.qi-orange { background: var(--orange-light); color: var(--orange); }
.qi-purple { background: var(--purple-light); color: var(--purple); }
.qi-red { background: var(--red-light); color: var(--red); }
.qi-teal { background: var(--teal-light); color: var(--teal); }
.quick-text { min-width: 0; }
.quick-label { font-size: 0.88em; font-weight: 600; line-height: 1.25; }
.quick-sub { font-size: 0.73em; color: var(--text-muted); font-weight: 400; margin-top: 1px; display: block; }

/* ============================================
   FEATURED CARDS
   ============================================ */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.featured-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none !important;
    color: var(--text);
    transition: 0.25s;
    box-shadow: var(--shadow-sm);
}
.featured-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.featured-thumb {
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.featured-body { padding: 16px; }
.featured-body h3 { font-size: 1em; font-weight: 600; margin-bottom: 4px; }
.featured-body p { font-size: 0.82em; color: var(--text-muted); line-height: 1.5; margin: 0; }

/* ============================================
   MAIN LAYOUT (Content + Sidebar)
   ============================================ */
.main { padding: 25px 0; min-height: calc(100vh - 150px); }
.layout { display: grid; grid-template-columns: 1fr 300px; gap: 25px; }

.content {
    background: var(--card);
    padding: 28px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.content h1 { font-size: 1.7em; margin-bottom: 16px; color: var(--text); letter-spacing: -0.02em; font-weight: 700; }
.content h2 { font-size: 1.3em; margin: 28px 0 12px; color: var(--text); border-bottom: 2px solid var(--border); padding-bottom: 8px; font-weight: 600; }
.content h3 { font-size: 1.1em; margin: 20px 0 8px; color: var(--text); font-weight: 600; }
.content p { margin-bottom: 14px; }
.content ul, .content ol { margin: 12px 0 12px 25px; }
.content li { margin-bottom: 6px; }
.content code {
    background: var(--code-bg);
    padding: 2px 7px;
    border-radius: 5px;
    font-family: 'JetBrains Mono', Monaco, Consolas, monospace;
    font-size: 0.88em;
    border: 1px solid var(--border);
}
.content pre {
    background: var(--pre-bg);
    color: var(--pre-text);
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 14px 0;
    border: 1px solid rgba(255,255,255,0.06);
    font-family: 'JetBrains Mono', Monaco, Consolas, monospace;
    font-size: 0.88em;
    line-height: 1.6;
}
.content pre code { background: none; color: inherit; padding: 0; border: none; font-size: inherit; }

/* Access Box */
.access-box {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    padding: 18px;
    border-radius: var(--radius-lg);
    margin: 22px 0;
    border: 1px solid rgba(255,255,255,0.06);
}
.access-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.access-label { color: #94a3b8; font-size: 0.9em; }
.access-btn {
    display: inline-block;
    background: var(--accent);
    color: #fff !important;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none !important;
    font-family: 'JetBrains Mono', Monaco, monospace;
    font-size: 0.88em;
    transition: 0.2s;
}
.access-btn:hover { background: var(--accent-hover); }
.alt-links { color: #64748b; font-size: 0.82em; }
.alt-links a { color: #60a5fa; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 16px 0; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.92em; }
th { background: var(--bg-alt); font-weight: 600; }
tr:hover { background: var(--card-hover); }

/* Note & Info Boxes */
.note { background: var(--orange-light); border-left: 4px solid var(--orange); padding: 14px 16px; margin: 16px 0; border-radius: 0 var(--radius) var(--radius) 0; font-size: 0.92em; }
.note strong { color: var(--orange); }
.info-box { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 14px 16px; margin: 16px 0; border-radius: 0 var(--radius) var(--radius) 0; font-size: 0.92em; }

/* TOC */
.toc { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin: 20px 0; }
.toc h2 { font-size: 1em; margin: 0 0 10px !important; border: none !important; padding: 0 !important; }
.toc ul { list-style: none; margin: 0 !important; padding: 0 !important; columns: 2; }
.toc li { margin-bottom: 5px; }
.toc a { font-size: 0.85em; font-weight: 500; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-widget {
    background: var(--card);
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.sidebar-widget h3 { font-size: 0.85em; margin-bottom: 12px; color: var(--text); border-bottom: 2px solid var(--border); padding-bottom: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.sidebar-widget ul { list-style: none; margin: 0; padding: 0; }
.sidebar-widget li { margin-bottom: 5px; }
.sidebar-widget a { color: var(--accent); font-size: 0.85em; }

/* Adbox */
.adbox { background: var(--bg-alt); padding: 15px; border-radius: var(--radius); text-align: center; min-height: 200px; border: 1px solid var(--border); }

/* Breadcrumb */
.breadcrumb { font-size: 0.82em; margin-bottom: 14px; color: var(--text-muted); }
.breadcrumb a { color: var(--accent); }

/* ============================================
   FOOTER
   ============================================ */
.footer { background: var(--header-bg); color: #94a3b8; padding: 36px 0 18px; margin-top: 40px; border-top: 1px solid rgba(255,255,255,0.06); }
.footer-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 15px; margin-bottom: 24px; }
.footer-col h4 { color: #e2e8f0; margin-bottom: 10px; font-size: 0.82em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 4px; }
.footer-col a { color: #64748b; font-size: 0.8em; transition: 0.2s; }
.footer-col a:hover { color: #e2e8f0; text-decoration: none; }
.footer-bottom { text-align: center; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.06); }
.footer-bottom p { color: #475569; font-size: 0.8em; }
.footer-legal { font-size: 0.8em; color: #64748b; margin-top: 6px; }
.footer-legal a { color: #64748b; }
.footer-legal a:hover { color: #e2e8f0; text-decoration: none; }

/* 404 */
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 3.5em; color: var(--red); margin-bottom: 10px; }
.error-page h2 { font-size: 1.3em; margin-bottom: 15px; }
.error-page p { color: var(--text-muted); margin-bottom: 25px; }
.error-page .btn { display: inline-block; background: var(--accent); color: #fff; padding: 10px 25px; border-radius: 6px; text-decoration: none; font-weight: 600; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1100px) { .footer-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .menu-toggle { display: block; }
    .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--header-bg); flex-direction: column; padding: 12px; border-top: 1px solid rgba(255,255,255,0.06); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
    .nav.active { display: flex; }
    .nav-item { width: 100%; border-bottom: 1px solid rgba(255,255,255,0.06); }
    .nav-item:last-child { border-bottom: none; }
    .nav-item > a { padding: 12px 10px; font-size: 0.9em; }
    .dropdown { position: static !important; display: none !important; box-shadow: none; background: rgba(255,255,255,0.03); border-radius: 0; padding: 0; border: none; margin-top: 0; }
    .dropdown a { color: #94a3b8 !important; padding: 10px 20px; border-bottom: 1px solid rgba(255,255,255,0.04); border-radius: 0; }
    .dropdown a:hover { background: rgba(255,255,255,0.05); color: #fff !important; }
    .nav-item:hover > .dropdown, .nav-item:focus-within > .dropdown { display: block !important; visibility: visible; opacity: 1; }
    .hero h1 { font-size: 1.55em; }
    .hero { padding: 32px 16px 28px; }
    .quick-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
    .featured-grid { grid-template-columns: 1fr; }
    .toc ul { columns: 1; }
}
@media (max-width: 600px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .content { padding: 18px; }
    .content h1 { font-size: 1.35em; }
    .access-line { flex-direction: column; align-items: flex-start; }
    .logo { font-size: 1em; }
    .quick-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .quick-card { padding: 12px; gap: 10px; }
    .hero-buttons { flex-direction: column; align-items: center; }
}

/* Access btn fix */
.sidebar-widget .access-btn, .access-btn { color: #fff !important; }
.sidebar-widget .access-btn:hover, .access-btn:hover { color: #fff !important; }
