@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@200;300;400;500;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&display=swap');

/* =========================================
   VARIABLES & THEME CONFIG
   ========================================= */
:root {
    --bg-color: #f4f4f4;
    --surface-color: #ffffff;
    --text-main: #1a1a1a;
    --text-dim: #666666;
    --border-color: #e0e0e0;
    --accent-color: #000000;
    --highlight: #dadada;
    --code-bg: #e8e8e8;
    --font-head: 'Rajdhani', "Cairo", sans-serif;
    --font-body: 'Inter', "Tajawal", sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --nav-height: 70px;
    --side-width: 260px;
}

[data-theme="light"] {
    /* Core surfaces */
    --bg-color: #f4fff9;          /* soft mint-white */
    --surface-color: #ffffff;     /* cards / sidebar */
    --highlight: #e6f7ef;         /* hover / active */

/* Text */
    --text-main: #0c1b16;         /* deep green text */
    --text-dim: #4f6f63;          /* muted green-gray */

    /* Borders & dividers */
    --border-color: #cde8dc;      /* subtle mint border */

    /* Accent */
    --accent-color: #0c6b4f;      /* darker mint-green */
    --accent-soft: #4fbf9a;       /* softer accent */

    /* Code */
    --code-bg: #e9f6f0;
    --code-border: #b6e2d1;
}

[data-theme="dark"] {
    /* Core surfaces */
    --bg-color: #0c1b16;          /* main background */
    --surface-color: #10231c;     /* cards / sidebar */
    --highlight: #16352a;         /* hover / active */

    /* Text */
    --text-main: #eafaf3;         /* primary text */
    --text-dim: #b7d6c8;          /* secondary / meta */

    /* Borders & dividers */
    --border-color: #1f4a3a;      /* subtle green border */

    /* Accent */
    --accent-color: #e0fff0;      /* mint highlight */
    --accent-soft: #7fdcc1;       /* muted accent */

    /* Code */
    --code-bg: #0f2a21;
    --code-border: #1e5b45;
}

/*[data-theme="dark"] {
    --bg-color: #0c1b16;
    --surface-color: #141414;
    --text-main: #eeeeee;
    --text-dim: #eee0e0;
    --border-color: #333333;
    /*--accent-color: #ccff00;
    --accent-color: #e0fff0;
    --highlight: #2a2a2a;
    --code-bg: #1f1f1f;
}*

/* =========================================
   RESET & GLOBAL
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: none; /* Firefox */
}

*::-webkit-scrollbar { 
    display: none; /* Chrome/Safari */
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    padding-top: var(--nav-height);
    transition: background 0.3s ease, color 0.3s ease;
    unicode-bidi: plaintext;
}

a { 
    text-decoration: none; 
    color: inherit; 
}

/* =========================================
   NAVIGATION
   ========================================= */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.navbar.nav-hidden {
    transform: translateY(-100%);
}

.brand {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    border: 2px solid var(--text-main);
    padding: 0.1rem 0.5rem;
    white-space: nowrap;
}

.nav-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-ui {
    cursor: pointer;
    text-transform: uppercase;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 8px;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-ui:hover { 
    color: var(--accent-color); 
    border-color: var(--border-color); 
}

/* Language Dropdown */
#lang-toggle {
    position: relative;
}

.lang-list {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    min-width: 80px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lang-list li {
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease, color 0.2s ease;
}

.lang-list li::before {
    display: none;
}

.lang-list li:hover {
    background: var(--highlight);
    color: var(--accent-color);
}

.lang-list.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Mobile Menu Button */
.mobile-btn {
    display: none;
}

/* =========================================
   TRI-COLUMN LAYOUT
   ========================================= */
.container {
    display: grid;
    grid-template-columns: var(--side-width) 1fr var(--side-width);
    max-width: 1600px;
    margin: 2rem auto;
    gap: 2rem;
    padding: 0 1.5rem;
}

/* =========================================
   SIDEBARS
   ========================================= */
.docs-sidebar, .sidebar-toc {
    position: sticky;
    top: calc(var(--nav-height) + 2rem);
    height: calc(100vh - var(--nav-height) - 4rem);
    overflow-y: auto;
    font-size: 0.9rem;
}

.docs-sidebar { 
    border-right: 1px solid var(--border-color); 
    padding-right: 1rem; 
}

.sidebar-toc { 
    border-left: 1px solid var(--border-color); 
    padding-left: 1rem; 
}

.sidebar-header {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 1rem;
    letter-spacing: 1px;
}

/* Filesystem Tree */
.fs-tree ul { 
    list-style: none; 
    padding-left: 1rem; 
    margin-bottom: 0;
}

.fs-tree > ul { 
    padding-left: 0; 
}

.fs-tree li {
    border: none;
    padding: 0;
    display: block;
}

.fs-tree li::before {
    display: none;
}

.fs-folder {
    cursor: pointer;
    color: var(--text-dim);
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.fs-folder:hover {
    color: var(--text-main);
}

.fs-file {
    display: block;
    padding: 6px 12px;
    margin: 2px 0;
    border-radius: 4px;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.fs-file:hover {
    background: var(--highlight);
}

.fs-file.active {
    background: var(--highlight);
    color: var(--accent-color);
    font-weight: bold;
}

/* Table of Contents */
.toc-list {
    list-style: none;
    border-left: 1px solid var(--border-color);
    margin-bottom: 0;
}

.toc-list li {
    margin-bottom: 0;
    padding: 0;
    border: none;
    display: block;
}

.toc-list li::before {
    display: none;
}

.toc-link {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: var(--text-dim);
    border-left: 2px solid transparent;
    margin-left: -2px;
    transition: all 0.2s;
}

.toc-link:hover, .toc-link.active {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    background: linear-gradient(90deg, var(--highlight) 0%, transparent 100%);
    padding-left: 1.5rem;
}

/* =========================================
   MAIN CONTENT
   ========================================= */
main { 
    min-width: 0; 
    overflow-wrap: break-word; 
}

/* Hero Card */
.hero-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 2.5rem;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--accent-color);
}

.hero-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-color);
}

.stat-badge {
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.1);
}

.description {
    font-size: 1.1rem;
    color: var(--text-dim);
    max-width: 600px;
}

/* Typography */
h1 {
    font-family: var(--font-head);
    font-size: clamp(2rem, 5vw, 3.5rem);
    text-transform: uppercase;
    line-height: 0.9;
    margin-bottom: 1.5rem;
}

h2 {
    font-family: var(--font-head);
    font-size: 1.8rem;
    text-transform: uppercase;
    margin: 3rem 0 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
    position: relative;
}

h2::before {
    content: '#';
    color: var(--accent-color);
    margin-right: 10px;
}

h3 {
    position: relative;
}

.anchor-link {
    position: absolute;
    transform: translateX(-120%);
    color: var(--accent-color);
    opacity: 0;
    font-family: var(--font-mono);
    transition: opacity 0.2s ease;
}

h2:hover .anchor-link, 
h3:hover .anchor-link {
    opacity: 0.5;
}

p {
    margin-bottom: 1.5rem;
    color: var(--text-dim);
}

hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 2rem 0;
    opacity: 0.6;
}

/* Article Links */
#article a:not(.anchor-link) {
    color: var(--accent-soft);
    text-decoration: none;
    background-image: linear-gradient(var(--accent-color), var(--accent-color));
    background-position: 0% 100%;
    background-repeat: no-repeat;
    background-size: 0% 2px;
    transition: background-size 0.3s;
}

#article a:not(.anchor-link):hover {
    background-size: 100% 2px;
}

/* Lists */
#article ul {
    list-style: none;
    margin-bottom: 2rem;
}

#article ul li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
}

#article ul li::before {
    content: '>';
    color: var(--accent-color);
    font-family: var(--font-mono);
    font-weight: bold;
    margin-right: 1rem;
    flex-shrink: 0;
}

/* Images */
#article img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto 0.5rem;
    border: 1px solid var(--border-color);
}

#article img + em, 
#article .caption {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-dim);
    margin-bottom: 2rem;
}

/* AUTO BIDI */
#article p,
#article li,
#article blockquote,
#article h1,
#article h2,
#article h3,
#article h4,
#article h5,
#article h6 {
    direction: auto;
    unicode-bidi: plaintext;
    text-align: start;
}

#article th,
#article td {
    direction: auto;
    unicode-bidi: plaintext;
    text-align: start;
}

#article code,
#article pre {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Blockquotes */
blockquote {
    background: var(--highlight);
    border-left: 4px solid var(--accent-color);
    padding: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    font-family: var(--font-head);
    font-size: 1.2rem;
    color: var(--text-main);
}

/* Code */
pre {
    background: var(--code-bg);
    padding: 1.2rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 2rem;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent-color);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

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

th {
    background: var(--highlight);
    text-transform: uppercase;
    color: var(--text-main);
}

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

table {
    table-layout: fixed;
}

th, td {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

th {
    white-space: nowrap;
}

/* =========================================
   NAVIGATION CARDS
   ========================================= */
.nav-cards {
    display: flex;
    flex-direction: column;
    margin: 2rem 0;
    font-family: var(--font-body);
}

.nav-card {
    padding: 1rem 1.5rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: 8px;
    transition: all 0.2s ease;
    max-width: 400px;
    min-width: 250px;
    margin: 0.25rem 0;
}

.nav-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-color);
}

.prev-card {
    align-self: flex-start;
    text-align: left;
}

.next-card {
    align-self: flex-end;
    text-align: right;
}

.nav-card span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
}

.nav-card a {
    font-family: var(--font-body);
    font-weight: bold;
    color: var(--accent-color);
    text-decoration: none;
    display: block;
}

/* =========================================
   PROGRESS BAR
   ========================================= */
.progress-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: var(--bg-color);
    z-index: 1001;
}

.progress-bar {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    box-shadow: 0 0 10px var(--accent-color);
}

.progress-text {
    position: absolute;
    right: 10px;
    bottom: 10px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    background: var(--bg-color);
    padding: 2px 5px;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

/* =========================================
   FOOTER
   ========================================= */
footer {
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 4rem;
}

/* =========================================
   UTILITY CLASSES
   ========================================= */
.hidden {
    display: none !important;
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= 
@media (max-width: 1100px) {
    .container {
        grid-template-columns: 220px 1fr;
    }

    .sidebar-toc {
        display: none;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }

    /* Mobile Sidebars - Hidden by Default 
    .docs-sidebar, .sidebar-toc {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 2000;
        background: var(--surface-color);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border: none;
        padding: 2rem;
        border-right: 1px solid var(--border-color);
    }

    .docs-sidebar.active, .sidebar-toc.active {
        transform: translateX(0);
    }

    /* ToC specifically positioned from right 
    .sidebar-toc {
        left: auto;
        right: 0;
        transform: translateX(100%);
        border-right: none;
        border-left: 1px solid var(--border-color);
    }

    .sidebar-toc.active {
        transform: translateX(0);
    }

    /* Mobile Menu Button 
    .mobile-btn {
        display: block !important;
    }

    /* Anchor Links Hidden on Mobile 
    .anchor-link {
        display: none;
    }

    h1 {
        font-size: 2.2rem;
    }

    .brand {
        font-size: 1rem;
    }

    .nav-controls {
        gap: 0.5rem;
    }
}*/

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 1100px) {
    .container {
        grid-template-columns: 220px 1fr;
    }

    .sidebar-toc {
        display: none;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }

    /* Mobile Sidebars - Hidden by Default */
    .docs-sidebar, .sidebar-toc {
        display: block !important;
        position: fixed;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 2000;
        background: var(--surface-color);
        transition: transform 0.3s ease;
        border: none;
        padding: 2rem;
        overflow-y: auto;
    }

    .docs-sidebar {
        left: 0;
        transform: translateX(-100%);
        border-right: 1px solid var(--border-color);
    }

    .docs-sidebar.active {
        transform: translateX(0);
    }

    /* ToC specifically positioned from right */
    .sidebar-toc {
        left: auto;
        right: 0;
        transform: translateX(100%);
        border-left: 1px solid var(--border-color);
    }

    .sidebar-toc.active {
        transform: translateX(0);
    }

    /* Mobile Menu Button */
    .mobile-btn {
        display: block !important;
    }

    /* Anchor Links Hidden on Mobile */
    .anchor-link {
        display: none;
    }

    h1 {
        font-size: 2.2rem;
    }

    .brand {
        font-size: 1rem;
    }

    .nav-controls {
        gap: 0.5rem;
    }
}
