/* ==========================================================================
   SHARAF MASTER — UNIFIED NORDIC NEON SHELL & CATEGORIZED MENU ARCHITECTURE
   Zero External Font/CDN Dependencies • Mobile-First -> 4K Desktop
   ========================================================================== */
:root {
    /* Core Obsidian & Charcoal Palette */
    --bg-obsidian: #0B0C10;
    --bg-charcoal: #1F2833;
    --bg-charcoal-deep: #141A22;
    --bg-charcoal-elevated: #263240;
    --bg-card-glass: rgba(31, 40, 51, 0.78);
    --bg-card-hover: rgba(38, 50, 64, 0.95);
    --bg-glass-subtle: rgba(11, 12, 16, 0.75);

    /* High-Contrast Electric Accents */
    --neon-cyan: #66FCF1;
    --neon-cyan-dim: rgba(102, 252, 241, 0.14);
    --neon-cyan-glow: rgba(102, 252, 241, 0.38);

    --electric-mint: #45A29E;
    --electric-mint-dim: rgba(69, 162, 158, 0.2);
    --electric-mint-glow: rgba(69, 162, 158, 0.4);

    --amber-gold: #D4AF37;
    --amber-gold-dim: rgba(212, 175, 55, 0.15);
    --amber-gold-glow: rgba(212, 175, 55, 0.4);

    --volcanic-crimson: #FF007F;
    --volcanic-crimson-dim: rgba(255, 0, 127, 0.15);
    --volcanic-crimson-glow: rgba(255, 0, 127, 0.45);

    --fusion-violet: #9B59B6;
    --fusion-violet-dim: rgba(155, 89, 182, 0.2);
    --nahwu-emerald: #2ECC71;
    --nahwu-emerald-dim: rgba(46, 204, 113, 0.14);

    /* Neutral & Typography Tokens */
    --text-primary: #F8FAFC;
    --text-secondary: #C5C6C7;
    --text-muted: #8E96A0;
    --border-subtle: rgba(102, 252, 241, 0.14);
    --border-cyan: rgba(102, 252, 241, 0.22);
    --border-mint: rgba(69, 162, 158, 0.32);
    --border-gold: rgba(212, 175, 55, 0.35);

    /* Zero-Dependency System Font Stack */
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-arabic: 'Traditional Arabic', 'Amiri', 'Scheherazade New', 'Geeza Pro', 'Arial', serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, monospace;

    /* Fluid Typography Scale */
    --fs-2xs: clamp(0.68rem, 0.64rem + 0.18vw, 0.78rem);
    --fs-xs: clamp(0.72rem, 0.68rem + 0.2vw, 0.84rem);
    --fs-sm: clamp(0.82rem, 0.78rem + 0.25vw, 0.95rem);
    --fs-base: clamp(0.94rem, 0.88rem + 0.3vw, 1.08rem);
    --fs-md: clamp(1.08rem, 1rem + 0.45vw, 1.3rem);
    --fs-lg: clamp(1.25rem, 1.12rem + 0.65vw, 1.65rem);
    --fs-xl: clamp(1.55rem, 1.3rem + 1.1vw, 2.35rem);
    --fs-arabic-lg: clamp(1.5rem, 1.3rem + 1vw, 2.25rem);
    --fs-arabic-md: clamp(1.2rem, 1.08rem + 0.6vw, 1.6rem);

    /* Fluid Spacing & Radii */
    --space-2xs: clamp(0.25rem, 0.2vw, 0.4rem);
    --space-xs: clamp(0.5rem, 0.4rem + 0.3vw, 0.75rem);
    --space-sm: clamp(0.75rem, 0.6rem + 0.5vw, 1.15rem);
    --space-md: clamp(1rem, 0.85rem + 0.8vw, 1.65rem);
    --space-lg: clamp(1.5rem, 1.2rem + 1.2vw, 2.5rem);
    --space-xl: clamp(2rem, 1.5rem + 2vw, 3.5rem);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 9999px;

    --transition-fast: 180ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-smooth: 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    background-color: var(--bg-obsidian);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
}

body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    background-color: var(--bg-obsidian);
    background-image:
        radial-gradient(circle at 12% 18%, rgba(102, 252, 241, 0.06) 0%, transparent 38%),
        radial-gradient(circle at 88% 12%, rgba(212, 175, 55, 0.06) 0%, transparent 35%),
        radial-gradient(circle at 50% 85%, rgba(69, 162, 158, 0.07) 0%, transparent 45%),
        linear-gradient(180deg, #0B0C10 0%, #12161F 50%, #0B0C10 100%);
    display: flex;
    flex-direction: column;
}

/* Subtle geometric philological grid overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(102, 252, 241, 0.024) 1px, transparent 1px),
        linear-gradient(90deg, rgba(102, 252, 241, 0.024) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

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

button, input, select, textarea {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
}

button {
    cursor: pointer;
}

.arabic-text,
.arabic {
    font-family: var(--font-arabic);
    direction: rtl;
    unicode-bidi: isolate;
    line-height: 1.48;
}

/* ==========================================================================
   STICKY GLOBAL HEADER
   ========================================================================== */
.global-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background: rgba(11, 12, 16, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.65rem clamp(0.85rem, 2.2vw, 1.75rem);
    transition: box-shadow var(--transition-smooth), border-color var(--transition-smooth);
}

.global-header.scrolled {
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(102, 252, 241, 0.25);
}

.header-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.header-brand-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

/* Sidebar Menu Toggle Button (Mobile Drawer + Desktop Collapse) */
.menu-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: rgba(31, 40, 51, 0.85);
    border: 1px solid var(--border-cyan);
    color: var(--neon-cyan);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.menu-toggle-btn:hover {
    background: var(--neon-cyan-dim);
    box-shadow: 0 0 14px var(--neon-cyan-dim);
}

.brand-identity {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    user-select: none;
}

.logo-emblem {
    position: relative;
    width: clamp(38px, 3.6vw, 48px);
    height: clamp(38px, 3.6vw, 48px);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--bg-charcoal) 0%, #141B24 100%);
    border: 1.5px solid var(--neon-cyan);
    box-shadow: 0 0 18px var(--neon-cyan-dim), inset 0 0 10px rgba(102, 252, 241, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    flex-shrink: 0;
}

.brand-identity:hover .logo-emblem {
    transform: rotate(-4deg) scale(1.05);
    box-shadow: 0 0 24px var(--neon-cyan-glow);
}

.logo-arabic-root {
    font-family: var(--font-arabic);
    font-size: clamp(1.05rem, 1.25vw, 1.35rem);
    font-weight: 700;
    color: var(--amber-gold);
    text-shadow: 0 0 10px var(--amber-gold-glow);
}

.brand-titles {
    display: flex;
    flex-direction: column;
}

.brand-title-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.brand-name {
    font-size: clamp(1.05rem, 1.3vw, 1.35rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #FFFFFF 0%, var(--neon-cyan) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.version-pill {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--amber-gold-dim);
    border: 1px solid var(--border-gold);
    color: var(--amber-gold);
    font-weight: 600;
    text-transform: uppercase;
}

.brand-subtitle {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

/* Global Search / Quick Jump Box */
.search-wrapper {
    position: relative;
    width: 100%;
    flex: 1 1 280px;
    display: flex;
    align-items: center;
}

.search-input-box {
    width: 100%;
    display: flex;
    align-items: center;
    background: rgba(31, 40, 51, 0.85);
    border: 1.5px solid rgba(102, 252, 241, 0.22);
    border-radius: var(--radius-pill);
    padding: 0.46rem 0.9rem;
    gap: 0.6rem;
    transition: all var(--transition-fast);
}

.search-input-box:focus-within {
    background: rgba(31, 40, 51, 1);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 0 4px var(--neon-cyan-dim), 0 0 22px rgba(102, 252, 241, 0.25);
}

.search-icon {
    width: 17px;
    height: 17px;
    color: var(--neon-cyan);
    flex-shrink: 0;
}

.global-search-input {
    width: 100%;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    outline: none;
}

.global-search-input::placeholder {
    color: var(--text-muted);
}

.search-shortcut-badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-secondary);
    background: rgba(11, 12, 16, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 0.12rem 0.42rem;
    white-space: nowrap;
    cursor: pointer;
}

.search-clear-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    font-size: 0.72rem;
}

.search-clear-btn.visible {
    display: inline-flex;
}

/* Header Right Cluster: Quick Category Pills + User Status Badge */
.header-right-cluster {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.user-status-badge {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: linear-gradient(135deg, rgba(31, 40, 51, 0.92), rgba(20, 27, 36, 0.92));
    border: 1px solid rgba(69, 162, 158, 0.45);
    border-radius: var(--radius-pill);
    padding: 0.34rem 0.8rem 0.34rem 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-status-badge:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 18px var(--neon-cyan-dim);
    transform: translateY(-1px);
}

.status-avatar-ring {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--amber-gold-dim), var(--bg-obsidian));
    border: 1.5px solid var(--amber-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.status-online-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background-color: var(--neon-cyan);
    border: 2px solid var(--bg-obsidian);
    box-shadow: 0 0 8px var(--neon-cyan);
    animation: pulseGlow 2.2s infinite;
}

.status-info {
    display: flex;
    flex-direction: column;
    line-height: 1.18;
}

.status-rank-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--amber-gold);
    font-weight: 700;
}

.status-level-title {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.xp-mini-track {
    width: 52px;
    height: 5px;
    background: rgba(11, 12, 16, 0.8);
    border-radius: var(--radius-pill);
    overflow: hidden;
    border: 1px solid rgba(102, 252, 241, 0.2);
}

.xp-mini-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--electric-mint), var(--neon-cyan));
    border-radius: var(--radius-pill);
    transition: width 360ms ease;
}

/* ==========================================================================
   UNIFIED SINGLE-SCREEN WORKSPACE SHELL (CATEGORIZED SIDEBAR + STAGE)
   ========================================================================== */
.app-shell-body {
    position: relative;
    z-index: 1;
    width: 100%;
    flex: 1;
    display: flex;
    align-items: stretch;
    min-width: 0;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(5, 7, 11, 0.72);
    backdrop-filter: blur(5px);
}

.sidebar-backdrop.open {
    display: block;
}

/* Categorized Menu Sidebar */
.category-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 130;
    width: 268px;
    background: rgba(14, 18, 26, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
    transform: translateX(-104%);
    transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), width 240ms ease;
}

.category-sidebar.mobile-open {
    transform: translateX(0);
}

.sidebar-inner {
    padding: 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.sidebar-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-desktop-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.4rem;
}

.sidebar-kicker {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--neon-cyan);
}

.sidebar-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cat-nav {
    display: flex;
    flex-direction: column;
    gap: 1.05rem;
}

.cat-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.cat-group-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cat-dot.cyan { background: var(--neon-cyan); box-shadow: 0 0 8px var(--neon-cyan); }
.cat-dot.mint { background: var(--electric-mint); box-shadow: 0 0 8px var(--electric-mint); }
.cat-dot.gold { background: var(--amber-gold); box-shadow: 0 0 8px var(--amber-gold); }
.cat-dot.crimson { background: var(--volcanic-crimson); box-shadow: 0 0 8px var(--volcanic-crimson); }

.cat-items-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cat-item-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.52rem 0.65rem;
    border-radius: 11px;
    border: 1px solid transparent;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.cat-item-link:hover {
    background: rgba(38, 50, 64, 0.65);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.08);
}

.cat-item-link.active.accent-cyan {
    background: rgba(102, 252, 241, 0.11);
    border-color: rgba(102, 252, 241, 0.5);
    color: var(--neon-cyan);
    box-shadow: 0 0 16px rgba(102, 252, 241, 0.12);
}

.cat-item-link.active.accent-mint {
    background: rgba(69, 162, 158, 0.14);
    border-color: rgba(69, 162, 158, 0.55);
    color: var(--neon-cyan);
}

.cat-item-link.active.accent-gold {
    background: rgba(212, 175, 55, 0.12);
    border-color: rgba(212, 175, 55, 0.55);
    color: var(--amber-gold);
}

.cat-item-link.active.accent-crimson {
    background: rgba(255, 0, 127, 0.11);
    border-color: rgba(255, 0, 127, 0.55);
    color: #FF66B2;
}

.cat-item-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cat-item-label {
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-item-sub {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 800;
    padding: 0.1rem 0.38rem;
    border-radius: 5px;
    background: rgba(69, 162, 158, 0.2);
    border: 1px solid rgba(69, 162, 158, 0.45);
    color: var(--neon-cyan);
    flex-shrink: 0;
}

.cat-code-tag {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(8, 10, 14, 0.65);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.sidebar-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Main Content Stage */
.app-main-stage {
    flex: 1;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-x: hidden;
}

.stage-content-slot {
    flex: 1;
    width: 100%;
    min-width: 0;
}

/* Unified Footer */
.portal-footer {
    width: 100%;
    background: rgba(11, 12, 16, 0.95);
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    align-items: center;
    justify-content: space-between;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    z-index: 1;
}

/* ==========================================================================
   ANIMATIONS & RESPONSIVE SHELL BREAKPOINTS
   ========================================================================== */
@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.28); opacity: 0.65; }
}

@media screen and (max-width: 479px) {
    .global-header {
        padding: 0.55rem 0.75rem;
    }
    .search-shortcut-badge {
        display: none;
    }
    .brand-subtitle {
        display: none;
    }
}

@media screen and (min-width: 640px) {
    .portal-footer {
        flex-direction: row;
    }
}

@media screen and (min-width: 1024px) {
    .header-container {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .search-wrapper {
        max-width: 440px;
        margin: 0 0.75rem;
    }
    .category-sidebar {
        position: sticky;
        top: 66px;
        height: calc(100vh - 66px);
        transform: translateX(0);
        flex-shrink: 0;
        background: rgba(14, 18, 26, 0.72);
    }
    body.sidebar-collapsed .category-sidebar {
        display: none;
    }
    .sidebar-mobile-head {
        display: none;
    }
    .sidebar-desktop-head {
        display: flex;
    }
}
