/* ==========================================================================
   DoxKing — sidebar.css
   Slide-in sidebar + floating Tools button.
   Updated: RTL support, dark mode, 6-language compatible.
   ========================================================================== */

.site-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    max-width: 88vw;
    height: 100vh;
    background: var(--card);
    border-right: 1px solid var(--border);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.08);
}

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

/* ---------- Header ---------- */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 2;
}

.sidebar-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

.sidebar-title svg {
    color: var(--primary);
}

.sidebar-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-close:hover {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
}

/* ---------- Nav ---------- */
.sidebar-nav {
    padding: 12px 12px 24px;
    flex: 1 1 auto;
    overflow-y: auto;
}

.sidebar-group {
    margin-bottom: 14px;
}

.sidebar-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}

.sidebar-group-title:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-group-title svg {
    transition: transform 0.2s ease;
}

.sidebar-group.collapsed .sidebar-group-title svg {
    transform: rotate(-90deg);
}

.sidebar-group.collapsed .sidebar-list {
    display: none;
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
}

.sidebar-list li {
    margin-bottom: 1px;
}

/* Submenu items — normal color */
.sidebar-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
    line-height: 1.3;
}

.sidebar-list a:hover {
    background: var(--primary-light);
    color: var(--primary);
    text-decoration: none;
}

/* Selected (current page) — blue with left line */
.sidebar-list a.active {
    background: rgba(79, 70, 229, 0.12);
    color: var(--primary);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--primary);
    padding-left: 13px;
}

.sidebar-list a svg {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    color: var(--ink-soft);
    opacity: 0.75;
    transition: color 0.12s ease, opacity 0.12s ease;
}

.sidebar-list a:hover svg {
    color: var(--primary);
    opacity: 1;
}

.sidebar-list a.active svg {
    color: var(--primary);
    opacity: 1;
}

.sidebar-tool-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   DARK MODE
   ============================================================ */
html[data-theme="dark"] .sidebar-list a {
    color: #cbd5e1;
}

html[data-theme="dark"] .sidebar-list a svg {
    color: #94a3b8;
    opacity: 0.85;
}

html[data-theme="dark"] .sidebar-list a:hover {
    background: rgba(129, 140, 248, 0.1);
    color: #a5b4fc;
}

html[data-theme="dark"] .sidebar-list a:hover svg {
    color: #a5b4fc;
    opacity: 1;
}

html[data-theme="dark"] .sidebar-list a.active {
    background: rgba(129, 140, 248, 0.18);
    color: #a5b4fc;
    box-shadow: inset 3px 0 0 #818cf8;
    padding-left: 13px;
}

html[data-theme="dark"] .sidebar-list a.active svg {
    color: #a5b4fc;
    opacity: 1;
}

html[data-theme="dark"] .sidebar-group-title {
    color: #94a3b8;
}

html[data-theme="dark"] .sidebar-group-title:hover {
    background: rgba(129, 140, 248, 0.1);
    color: #a5b4fc;
}

/* ---------- FLOATING TOOLS BUTTON ---------- */
.sidebar-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 998;
    padding: 12px 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-family: var(--font);
}

.sidebar-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
}

@media (max-width: 1100px) {
    .sidebar-toggle {
        display: inline-flex;
    }
}

/* Floating button — dark mode */
html[data-theme="dark"] .sidebar-toggle {
    box-shadow: 0 6px 20px rgba(129, 140, 248, 0.35);
}

html[data-theme="dark"] .sidebar-toggle:hover {
    box-shadow: 0 8px 24px rgba(129, 140, 248, 0.5);
}

/* ---------- Backdrop ---------- */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- Push content on desktop ---------- */
@media (min-width: 1101px) {
    body.sidebar-open main {
        margin-left: 320px;
        transition: margin-left 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
    }
}

/* ---------- Small mobile ---------- */
@media (max-width: 600px) {
    .site-sidebar {
        width: 300px;
    }

    .sidebar-nav {
        padding: 10px 10px 20px;
    }

    .sidebar-list a {
        padding: 10px 10px;
        font-size: 0.9rem;
    }

    .sidebar-list a.active {
        padding-left: 13px;
    }

    .sidebar-toggle {
        bottom: 16px;
        left: 16px;
        padding: 11px 16px;
        font-size: 0.85rem;
    }
}

/* ============================================================
   RTL SUPPORT (Arabic)
   ============================================================ */
html[dir="rtl"] .site-sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    box-shadow: -6px 0 32px rgba(0, 0, 0, 0.08);
}

html[dir="rtl"] .site-sidebar.open {
    transform: translateX(0);
}

html[dir="rtl"] .sidebar-toggle {
    left: auto;
    right: 20px;
}

html[dir="rtl"] .sidebar-list a.active {
    box-shadow: inset -3px 0 0 var(--primary);
    padding-left: 10px;
    padding-right: 13px;
}

html[dir="rtl"] .sidebar-group.collapsed .sidebar-group-title svg {
    transform: rotate(90deg);
}

@media (min-width: 1101px) {
    html[dir="rtl"] body.sidebar-open main {
        margin-left: 0;
        margin-right: 320px;
    }
}

@media (max-width: 1100px) {
    html[dir="rtl"] .sidebar-toggle {
        left: auto;
        right: 16px;
    }
}