﻿
/* =========================================================
   SILENCE - GLOBAL SIDEBAR
   Master Page Sidebar
   RTL / Persian
   ========================================================= */


/* =========================================================
   1. VARIABLES
   ========================================================= */

:root {
    --sidebar-width: 286px;
    --sidebar-compact-width: 76px;
    --sidebar-tab-width: 42px;

    --sidebar-bg: #183d38;
    --sidebar-bg-deep: #12312e;
    --sidebar-bg-hover: rgba(255, 255, 255, 0.075);
    --sidebar-bg-active: rgba(255, 255, 255, 0.13);

    --sidebar-text: #e8f0ed;
    --sidebar-text-muted: #a9c0b8;
    --sidebar-accent: #d5b477;

    --sidebar-border: rgba(255, 255, 255, 0.10);
    --sidebar-shadow: 0 12px 35px rgba(0, 0, 0, 0.20);

    --sidebar-radius: 10px;
    --sidebar-item-height: 46px;
    --sidebar-transition: 240ms ease;
}


/* =========================================================
   2. BASE SIDEBAR
   شروع از زیر نوار مسترپیج
   ========================================================= */

.sidebar {
    position: fixed;

    top: var(--site-header-height, 100px);
    right: 0;
    bottom: 0;

    width: var(--sidebar-width);
    height: auto;

    z-index: 1000;

    direction: rtl;
    text-align: right;

    color: var(--sidebar-text);
    background: var(--sidebar-bg);

    box-shadow: var(--sidebar-shadow);

    display: flex;
    flex-direction: column;

    /* رنگ پس‌زمینه نباید انیمیشن داشته باشد */
    transition:
        width var(--sidebar-transition),
        transform var(--sidebar-transition),
        box-shadow var(--sidebar-transition);

    isolation: isolate;
}

.sidebar,
.sidebar * {
    box-sizing: border-box;
}


/* =========================================================
   3. INNER
   ========================================================= */

.sidebar-inner {
    width: 100%;
    height: 100%;
    min-height: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}


/* =========================================================
   4. NAVIGATION
   ========================================================= */

.sidebar-navigation {
    flex: 1 1 auto;
    min-height: 0;

    padding: 12px 10px 24px;

    overflow-x: hidden;
    overflow-y: auto;

    scrollbar-width: thin;
    scrollbar-color:
        rgba(255, 255, 255, 0.22)
        transparent;
}

.sidebar-navigation::-webkit-scrollbar {
    width: 5px;
}

.sidebar-navigation::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-navigation::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.20);
    border-radius: 10px;
}

.sidebar-navigation::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}


/* =========================================================
   5. MENU STRUCTURE
   ========================================================= */

.sidebar-menu,
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-item {
    position: relative;
    width: 100%;
    min-width: 0;
}

.sidebar-separator {
    height: 1px;
    margin: 10px 8px;
    background: var(--sidebar-border);
}


/* =========================================================
   6. MENU ROW
   ========================================================= */

.sidebar-item-row {
    position: relative;

    display: flex;
    align-items: center;

    width: 100%;
    min-height: var(--sidebar-item-height);

    padding: 0 10px;
    gap: 9px;

    border-radius: var(--sidebar-radius);

    transition:
        background var(--sidebar-transition),
        color var(--sidebar-transition);

    cursor: pointer;
}

.sidebar-item-row:hover {
    background: var(--sidebar-bg-hover);
}

.sidebar-item.is-open > .sidebar-item-row {
    background: var(--sidebar-bg-active);
}


/* =========================================================
   7. ICON
   ========================================================= */

.sidebar-item-icon {
    flex: 0 0 28px;

    width: 28px;
    height: 28px;

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--sidebar-accent);

    font-size: 19px;
    line-height: 1;
}

.sidebar-default-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    color: var(--sidebar-accent);

    font-family: serif;
    font-size: 23px;
    line-height: 1;
}

.sidebar-custom-icon {
    display: block;

    width: 22px;
    height: 22px;

    object-fit: contain;
}


/* =========================================================
   8. LINK AND LABEL
   ========================================================= */

.sidebar-item-link,
.sidebar-item-label {
    flex: 1 1 auto;
    min-width: 0;

    display: flex;
    align-items: center;

    min-height: 40px;

    color: var(--sidebar-text);

    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.8;

    text-decoration: none;
    overflow: hidden;
}

.sidebar-item-link {
    cursor: pointer;

    transition:
        color var(--sidebar-transition),
        opacity var(--sidebar-transition);
}

.sidebar-item-link:hover {
    color: #ffffff;
}

.sidebar-item-link:focus-visible {
    outline: 2px solid var(--sidebar-accent);
    outline-offset: 3px;
    border-radius: 5px;
}

.sidebar-item-title {
    display: block;
    width: 100%;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* =========================================================
   9. SUBMENU BUTTON
   ========================================================= */

.sidebar-branch-toggle {
    flex: 0 0 26px;

    width: 26px;
    height: 30px;

    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 7px;

    color: var(--sidebar-text-muted);
    background: transparent;

    cursor: pointer;

    transition:
        background var(--sidebar-transition),
        color var(--sidebar-transition);
}

.sidebar-branch-toggle:hover {
    color: #ffffff;
    background: var(--sidebar-bg-hover);
}

.sidebar-branch-toggle:focus-visible {
    outline: 2px solid var(--sidebar-accent);
    outline-offset: 2px;
}

.sidebar-branch-arrow {
    display: block;

    width: 8px;
    height: 8px;

    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;

    transform: rotate(45deg);

    transition: transform var(--sidebar-transition);
}

.sidebar-item.is-open >
.sidebar-item-row >
.sidebar-branch-toggle >
.sidebar-branch-arrow {
    transform: rotate(-45deg);
}


/* =========================================================
   10. INLINE SUBMENU
   ========================================================= */

.sidebar-submenu {
    position: relative;

    display: flex;
    flex-direction: column;

    gap: 2px;

    margin: 4px 0 7px;
    padding: 4px 12px 4px 0;

    border-right: 1px solid rgba(213, 180, 119, 0.30);
}

.sidebar-submenu[hidden] {
    display: none !important;
}

.sidebar-submenu.is-open {
    display: flex;
}

.sidebar-submenu .sidebar-item-row {
    min-height: 40px;

    padding-right: 9px;
    padding-left: 7px;
}

.sidebar-submenu .sidebar-item-icon {
    flex-basis: 24px;

    width: 24px;
    height: 24px;
}

.sidebar-submenu .sidebar-item-link,
.sidebar-submenu .sidebar-item-label {
    font-size: 12px;
}

.sidebar-submenu .sidebar-default-icon {
    font-size: 19px;
}

.sidebar-submenu .sidebar-custom-icon {
    width: 19px;
    height: 19px;
}


/* =========================================================
   11. FLYOUT SUBMENU
   ========================================================= */

.sidebar-submenu.is-flyout-open {
    position: fixed;

    direction: rtl;
    text-align: right;
    font-family: inherit;
    color: var(--sidebar-text);

    top: 0;
    right: 0;
    left: auto;

    width: 245px;
    max-width: calc(100vw - 16px);

    max-height: min(70vh, 520px);

    margin: 0;
    padding: 9px;

    overflow-x: hidden;
    overflow-y: auto;

    background: var(--sidebar-bg-deep);

    border: 1px solid var(--sidebar-border);
    border-radius: 10px;

    border-right: 2px solid var(--sidebar-accent);

    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);

    z-index: 2000;

    scrollbar-width: thin;
    scrollbar-color:
        rgba(255, 255, 255, 0.22)
        transparent;
}

.sidebar-submenu.is-flyout-open[hidden] {
    display: none !important;
}

.sidebar-submenu.is-flyout-open .sidebar-item {
    position: relative;
}


/* =========================================================
   12. EXPANDED STATE
   ========================================================= */

.sidebar.is-expanded {
    width: var(--sidebar-width);
    transform: translateX(0);
}

.sidebar.is-expanded .sidebar-inner {
    opacity: 1;
    visibility: visible;
}

.sidebar.is-expanded .sidebar-item-title {
    opacity: 1;
    visibility: visible;
}


/* =========================================================
   13. COMPACT STATE
   ========================================================= */

.sidebar.is-compact {
    width: var(--sidebar-compact-width);
    transform: translateX(0);
}

.sidebar.is-compact .sidebar-navigation {
    padding-right: 8px;
    padding-left: 8px;
}

.sidebar.is-compact .sidebar-item-row {
    justify-content: center;
    padding: 0 5px;
    gap: 0;
}

.sidebar.is-compact .sidebar-item-icon {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
}

.sidebar.is-compact .sidebar-item-link,
.sidebar.is-compact .sidebar-item-label {
    flex: 0 0 0;
    width: 0;
    min-width: 0;
    overflow: hidden;
}

.sidebar.is-compact .sidebar-item-title {
    display: none;
}

.sidebar.is-compact .sidebar-branch-toggle {
    display: none;
}

.sidebar.is-compact .sidebar-submenu:not(.is-flyout-open) {
    display: none !important;
}

.sidebar.is-compact .sidebar-separator {
    margin-right: 5px;
    margin-left: 5px;
}


/* =========================================================
   14. CLOSED STATE
   ========================================================= */

.sidebar.is-closed {
    width: var(--sidebar-width);

    transform: translateX(
        calc(100% - var(--sidebar-tab-width))
    );

    /*
       پس‌زمینه در حالت بسته هم سبز می‌ماند.
       دیگر رنگ کرمی صفحه از زیر سایدبار دیده نمی‌شود.
    */
    background: var(--sidebar-bg);

    box-shadow: none;
}

.sidebar.is-closed .sidebar-inner {
    visibility: hidden;
    pointer-events: none;
}


/* =========================================================
   15. STATE TAB
   ========================================================= */

.sidebar-state-tab {
    position: absolute;

    top: 12px;
    left: calc(var(--sidebar-tab-width) * -1);

    width: var(--sidebar-tab-width);
    min-height: 78px;

    padding: 6px 3px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;

    border: 1px solid var(--sidebar-border);
    border-right: 0;
    border-radius: 10px 0 0 10px;

    color: var(--sidebar-accent);
    background: var(--sidebar-bg);

    box-shadow: -5px 4px 15px rgba(0, 0, 0, 0.13);

    z-index: 1002;
}


/* پایه دکمه‌های زبانه */

.sidebar-tab-button {
    width: 100%;
    min-height: 28px;

    padding: 2px 6px 2px 7px;

    display: flex;
    align-items: center;
    justify-content: flex-start;

    gap: 1px;

    border: 0;
    border-radius: 6px;

    color: var(--sidebar-accent);
    background: transparent;

    cursor: pointer;

    transition:
        color var(--sidebar-transition),
        background var(--sidebar-transition);
}

.sidebar-tab-button:hover {
    color: #ffffff;
    background: var(--sidebar-bg-hover);
}

.sidebar-tab-button:focus-visible {
    outline: 2px solid var(--sidebar-accent);
    outline-offset: 1px;
}


/* آیکون اصلی */

.sidebar-tab-button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-family: Arial, sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}


/* زیگزاگ کنار آیکون */

.sidebar-tab-button-text-mark {
    display: inline-block;

    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1;
}

.sidebar-compact-button .sidebar-tab-button-text-mark,
.sidebar-visibility-button .sidebar-tab-button-text-mark {
    display: none;
}


/* =========================================================
   15-A. CLOSED
   ========================================================= */

.sidebar.is-closed .sidebar-state-tab {
    left: 0;

    border: 1px solid var(--sidebar-border);
    border-right: 0;

    border-radius: 10px 0 0 10px;

    box-shadow: -5px 4px 15px rgba(0, 0, 0, 0.13);
}

.sidebar.is-closed .sidebar-compact-button,
.sidebar.is-closed .sidebar-expanded-button {
    display: flex;
}

.sidebar.is-closed .sidebar-visibility-button {
    display: none;
}


/* =========================================================
   15-B. COMPACT
   ========================================================= */

.sidebar.is-compact .sidebar-compact-button {
    display: none;
}

.sidebar.is-compact .sidebar-expanded-button {
    display: flex;
}

.sidebar.is-compact .sidebar-visibility-button {
    display: flex;
}


/* =========================================================
   15-C. EXPANDED
   ========================================================= */

.sidebar.is-expanded .sidebar-expanded-button {
    display: none;
}

.sidebar.is-expanded .sidebar-compact-button {
    display: flex;
}

.sidebar.is-expanded .sidebar-visibility-button {
    display: flex;
}


/* =========================================================
   15-D. TAB BUTTON COLORS
   ========================================================= */

.sidebar.is-closed .sidebar-tab-button {
    color: #ffffff;
}

.sidebar.is-closed .sidebar-tab-button:hover {
    background: rgba(255, 255, 255, 0.12);
}


/* =========================================================
   16. MOBILE BACKDROP
   ========================================================= */

.sidebar-backdrop {
    position: fixed;
    inset: 0;

    z-index: 990;

    background: rgba(8, 20, 18, 0.55);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity var(--sidebar-transition),
        visibility var(--sidebar-transition);
}


/* =========================================================
   17. RESPONSIVE
   ========================================================= */

@media (max-width: 767px) {

    .sidebar {
        width: min(
            var(--sidebar-width),
            calc(100vw - 48px)
        );
    }

    .sidebar.is-expanded {
        width: min(
            var(--sidebar-width),
            calc(100vw - 48px)
        );

        transform: translateX(0);
    }

    .sidebar.is-compact {
        width: min(
            var(--sidebar-compact-width),
            calc(100vw - 48px)
        );
    }

    .sidebar.is-closed {
        width: min(
            var(--sidebar-width),
            calc(100vw - 48px)
        );

        transform: translateX(
            calc(100% - var(--sidebar-tab-width))
        );

        background: var(--sidebar-bg);
        box-shadow: none;
    }

    body.sidebar-expanded .sidebar-backdrop,
    body.sidebar-compact .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body.sidebar-closed .sidebar-backdrop {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .sidebar-state-tab {
        position: absolute;

        top: 12px;
        left: calc(var(--sidebar-tab-width) * -1);

        width: var(--sidebar-tab-width);
        min-height: 78px;

        padding: 6px 3px;

        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;

        border: 1px solid var(--sidebar-border);
        border-right: 0;
        border-radius: 10px 0 0 10px;

        color: var(--sidebar-accent);
        background: var(--sidebar-bg);

        box-shadow: -5px 4px 15px rgba(0, 0, 0, 0.13);

        z-index: 1002;
    }

    .sidebar-submenu.is-flyout-open {
        width: min(245px, calc(100vw - 16px));
        max-height: 60vh;
    }
}


/* =========================================================
   18. SMALL MOBILE
   ========================================================= */

@media (max-width: 420px) {

    .sidebar {
        width: calc(100vw - 42px);
    }

    .sidebar.is-expanded,
    .sidebar.is-closed {
        width: calc(100vw - 42px);
    }

    .sidebar-navigation {
        padding-right: 8px;
        padding-left: 8px;
    }
}


/* =========================================================
   19. ACCESSIBILITY
   ========================================================= */

.sidebar button {
    font-family: inherit;
}

.sidebar button:focus-visible,
.sidebar a:focus-visible {
    outline-color: var(--sidebar-accent);
}

.sidebar a,
.sidebar button {
    -webkit-tap-highlight-color: transparent;
}


/* =========================================================
   20. CHANGE ANIMATION
   ========================================================= */

.sidebar-navigation.is-changing .sidebar-item-row {
    animation: sidebar-row-change 520ms ease both;
}

@keyframes sidebar-row-change {

    0% {
        transform: translateX(0);
        background-color: transparent;
    }

    30% {
        transform: translateX(-3px);
        background-color: rgba(213, 180, 119, 0.20);
    }

    65% {
        transform: translateX(2px);
        background-color: rgba(213, 180, 119, 0.10);
    }

    100% {
        transform: translateX(0);
        background-color: transparent;
    }
}


/* =========================================================
   21. REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .sidebar,
    .sidebar *,
    .sidebar-backdrop {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}


/* =========================================================
   DEVELOPER SIDEBAR PAGE LINK
   ========================================================= */

.sidebar-dev-page-link {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: flex-start;

    gap: 10px;

    min-height: 42px;

    margin: 10px 10px 0;
    padding: 8px 12px;

    border: 1px solid rgba(213, 180, 119, 0.35);
    border-radius: 9px;

    color: var(--sidebar-accent);
    background: rgba(213, 180, 119, 0.08);

    text-decoration: none;
    font-size: 13px;
    font-weight: 600;

    transition:
        background var(--sidebar-transition),
        color var(--sidebar-transition),
        border-color var(--sidebar-transition);
}

.sidebar-dev-page-link:hover {
    color: #ffffff;
    background: rgba(213, 180, 119, 0.18);
    border-color: var(--sidebar-accent);
}

.sidebar-dev-page-link:focus-visible {
    outline: 2px solid var(--sidebar-accent);
    outline-offset: 2px;
}

.sidebar-dev-page-icon {
    flex: 0 0 22px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 22px;
    height: 22px;

    font-size: 17px;
}

.sidebar-dev-page-text {
    white-space: nowrap;
}


/* حالت فشرده: فقط آیکون */

.sidebar.is-compact .sidebar-dev-page-link {
    justify-content: center;

    margin-right: 7px;
    margin-left: 7px;

    padding-right: 0;
    padding-left: 0;
}

.sidebar.is-compact .sidebar-dev-page-text {
    display: none;
}
