/* CSS Variables for Light Mode */
:root {
    --primary: #e31e24;
    --primary-rgb: 227, 30, 36;
    --primary-hover: #c4191f;
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text-main: #1d1d1f;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --code-bg: #f1f5f9;
    --code-color: #0f172a;
    --alert-info-bg: #eff6ff;
    --alert-info-border: #bfdbfe;
    --alert-info-text: #1e3a8a;
    --alert-warning-bg: #fffbeb;
    --alert-warning-border: #fde68a;
    --alert-warning-text: #78350f;
    --alert-tip-bg: #ecfdf5;
    --alert-tip-border: #a7f3d0;
    --alert-tip-text: #064e3b;
    --sidebar-width: 320px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Override */
body.dark-theme {
    --bg-main: #0b0f19;
    --bg-card: #151c2c;
    --bg-sidebar: #111827;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --code-bg: #1e293b;
    --code-color: #f1f5f9;
    --alert-info-bg: rgba(30, 58, 138, 0.2);
    --alert-info-border: rgba(59, 130, 246, 0.3);
    --alert-info-text: #93c5fd;
    --alert-warning-bg: rgba(120, 53, 15, 0.2);
    --alert-warning-border: rgba(245, 158, 11, 0.3);
    --alert-warning-text: #fde047;
    --alert-tip-bg: rgba(6, 78, 59, 0.2);
    --alert-tip-border: rgba(16, 185, 129, 0.3);
    --alert-tip-text: #6ee7b7;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Core Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

/* Header bar */
.header-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    transition: var(--transition);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
}

.logo-box {
    width: 36px;
    height: 36px;
    background-color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 800;
    font-size: 18px;
}

.logo-text {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-badge {
    font-size: 11px;
    font-weight: 700;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
}

/* Search bar */
.search-container {
    position: relative;
    width: 100%;
    max-width: 460px;
    margin: 0 16px;
}

.search-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 12px;
    gap: 8px;
    transition: var(--transition);
}

.search-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.search-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
}

.search-icon {
    color: var(--text-muted);
    font-size: 18px !important;
}

/* Search Results Dropdown */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 110;
}

.search-results-dropdown.active {
    display: block;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--bg-main);
}

.result-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.result-category {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
    display: inline-block;
}

.result-description {
    font-size: 12px;
    color: var(--text-muted);
}

.search-highlight {
    background-color: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: bold;
}

.no-results {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Controls section */
.controls-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--bg-card);
    transition: var(--transition);
}

.btn-back:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-main);
}

/* Main Layout */
.main-wrapper {
    display: flex;
    margin-top: 70px;
    height: calc(100vh - 70px);
}

/* Sidebar navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    overflow-y: auto;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-category {
    margin-bottom: 24px;
}

.sidebar-category-title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-left: 12px;
}

.sidebar-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-link:hover {
    color: var(--text-main);
    background-color: var(--bg-main);
}

.sidebar-link.active {
    color: var(--primary);
    background-color: rgba(var(--primary-rgb), 0.05);
    font-weight: 700;
}

.sidebar-link span.material-symbols-outlined {
    font-size: 20px;
}

/* Content Pane */
.content-pane {
    flex-grow: 1;
    background-color: var(--bg-card);
    padding: 48px 64px;
    overflow-y: auto;
    position: relative;
    max-width: calc(100% - var(--sidebar-width));
}

.article-container {
    max-width: 820px;
    margin-left: 0;
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

.article-container.fade {
    opacity: 0;
}

.article-category {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.article-title {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.8px;
    line-height: 1.2;
    margin-bottom: 16px;
}

.article-description {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.5;
    border-bottom: 1px solid var(--border);
    padding-bottom: 24px;
}

/* Documentation Content Styling */
.doc-content h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
    margin-top: 36px;
    margin-bottom: 16px;
}

.doc-content p {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.7;
}

.doc-content strong {
    color: var(--text-main);
}

.doc-content ul {
    list-style: none;
    margin-bottom: 24px;
    padding-left: 8px;
}

.doc-content ul li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 10px;
    font-size: 15px;
    color: var(--text-muted);
}

.doc-content ul li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 4px;
    top: 0;
    font-size: 16px;
}

.doc-content ol {
    margin-bottom: 24px;
    padding-left: 24px;
    color: var(--text-muted);
}

.doc-content ol li {
    margin-bottom: 10px;
    font-size: 15px;
    padding-left: 4px;
}

/* Alerts and Callouts */
.doc-alert {
    padding: 16px 20px;
    border-radius: 12px;
    border-left: 4px solid;
    margin: 24px 0;
}

.doc-alert-info {
    background-color: var(--alert-info-bg);
    border-color: var(--alert-info-border);
    color: var(--alert-info-text);
}

.doc-alert-warning {
    background-color: var(--alert-warning-bg);
    border-color: var(--alert-warning-border);
    color: var(--alert-warning-text);
}

.doc-alert-tip {
    background-color: var(--alert-tip-bg);
    border-color: var(--alert-tip-border);
    color: var(--alert-tip-text);
}

.doc-alert-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-alert p {
    color: inherit;
    font-size: 14px;
    margin-bottom: 0;
    line-height: 1.5;
}

/* Code Snippets */
.code-container {
    position: relative;
    background-color: var(--code-bg);
    border-radius: 12px;
    padding: 16px;
    margin: 24px 0;
    border: 1px solid var(--border);
    overflow-x: auto;
}

.code-container pre {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13.5px;
    color: var(--code-color);
    white-space: pre;
    word-wrap: normal;
}

.code-copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.code-copy-btn:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* Steps list UI */
.doc-steps {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: 24px 0;
}

.doc-step-item {
    display: flex;
    gap: 16px;
}

.doc-step-number {
    width: 28px;
    height: 28px;
    background-color: var(--primary);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.doc-step-body h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main);
}

.doc-step-body p {
    margin-bottom: 0;
    font-size: 14.5px;
}

/* Mobile Sidebar Menu Button */
.menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text-main);
}

/* Sidebar Backdrop overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Responsive UI adjustments */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 70px;
        bottom: 0;
        z-index: 95;
        background: var(--bg-sidebar);
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    .menu-btn {
        display: flex;
    }
    
    .content-pane {
        padding: 32px 24px;
        max-width: 100%;
    }
    
    .search-container {
        max-width: 280px;
    }
}

@media (max-width: 600px) {
    .header-bar {
        padding: 0 16px;
    }
    .logo-text, .logo-badge {
        display: none;
    }
    .search-container {
        margin: 0 8px;
    }
    .btn-back {
        padding: 8px 10px;
    }
    .btn-back span:last-child {
        display: none;
    }
}

/* Language Selector Select Dropdown */
.lang-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--bg-card);
    transition: var(--transition);
    cursor: pointer;
    outline: none;
    height: 36px;
    font-family: inherit;
}

.lang-select:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* RTL and Cairo typography overrides for Arabic translation */
body.lang-ar,
body.lang-ar h1,
body.lang-ar h2,
body.lang-ar h3,
body.lang-ar h4,
body.lang-ar h5,
body.lang-ar h6,
body.lang-ar p,
body.lang-ar a,
body.lang-ar li,
body.lang-ar span:not(.material-symbols-outlined),
body.lang-ar div:not(.code-container):not(.code-copy-btn):not(pre):not(code),
body.lang-ar input,
body.lang-ar select,
body.lang-ar button {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

body.lang-ar .sidebar,
body.lang-ar .sidebar-category-title,
body.lang-ar .sidebar-link,
body.lang-ar .content-pane,
body.lang-ar .article-container,
body.lang-ar .article-category,
body.lang-ar .article-title,
body.lang-ar .article-description,
body.lang-ar .doc-content,
body.lang-ar .search-result-item,
body.lang-ar .search-results-dropdown {
    direction: rtl;
    text-align: right;
}

/* Sidebar adjustments in Arabic RTL */
body.lang-ar .sidebar-category-title {
    padding-left: 0;
    padding-right: 12px;
}

/* Bullet list alignment fixes in Arabic RTL */
body.lang-ar .doc-content ul {
    padding-left: 0;
    padding-right: 8px;
}

body.lang-ar .doc-content ul li {
    padding-left: 0;
    padding-right: 20px;
}

body.lang-ar .doc-content ul li::before {
    left: auto;
    right: 4px;
}

/* Ordered list alignment fixes in Arabic RTL */
body.lang-ar .doc-content ol {
    padding-left: 0;
    padding-right: 24px;
}

body.lang-ar .doc-content ol li {
    padding-left: 0;
    padding-right: 4px;
}

/* Timeline / step number alignment fixes in Arabic RTL */
body.lang-ar .doc-step-item {
    flex-direction: row; /* Flex naturally flows right-to-left under direction: rtl */
}

/* Callout alert borders in Arabic RTL */
body.lang-ar .doc-alert {
    border-left: none;
    border-right: 4px solid;
}
