/* ═══════════════════════════════════════════════════════════════
   ROMPODA STATS — Sidebar
   ═══════════════════════════════════════════════════════════════ */

.rs-sidebar {
    background: var(--rs-bg-sidebar);
    border-right: 1px solid var(--rs-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
}

.rs-sidebar__brand {
    height: var(--rs-topbar-h);
    padding: 0 var(--rs-space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--rs-space-2);
    border-bottom: 1px solid var(--rs-border);
    flex: 0 0 auto;
}

.rs-sidebar__logo {
    display: flex;
    align-items: center;
    gap: var(--rs-space-2);
    text-decoration: none;
    color: var(--rs-dark);
    font-family: var(--rs-font-display);
    font-size: var(--rs-text-lg);
    font-weight: var(--rs-weight-bold);
    letter-spacing: -0.02em;
}

.rs-sidebar__logo-mark {
    width: 28px;
    height: 28px;
    background: var(--rs-gradient-blue-strong);
    border-radius: var(--rs-radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--rs-white);
    font-weight: var(--rs-weight-bold);
    font-size: var(--rs-text-xs);
    box-shadow: var(--rs-shadow-sm);
}

.rs-sidebar__logo-text { font-size: var(--rs-text-md); }
.rs-sidebar__logo-suffix {
    font-size: var(--rs-text-xs);
    color: var(--rs-g600);
    font-weight: var(--rs-weight-medium);
    margin-left: 4px;
    padding: 2px 6px;
    background: var(--rs-g200);
    border-radius: var(--rs-radius-sm);
}

.rs-sidebar__collapse {
    background: transparent;
    border: 0;
    width: 28px;
    height: 28px;
    border-radius: var(--rs-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--rs-g600);
    cursor: pointer;
    transition: all var(--rs-transition-fast);
}
.rs-sidebar__collapse:hover {
    background: var(--rs-g200);
    color: var(--rs-dark);
}

.rs-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--rs-space-3) var(--rs-space-3);
    scrollbar-width: thin;
    scrollbar-color: var(--rs-g300) transparent;
}
.rs-sidebar__nav::-webkit-scrollbar { width: 4px; }
.rs-sidebar__nav::-webkit-scrollbar-thumb { background: var(--rs-g300); border-radius: 4px; }

.rs-sidebar__section {
    margin-top: var(--rs-space-3);
}
.rs-sidebar__section:first-child { margin-top: 0; }

.rs-sidebar__section-title {
    font-size: 10px;
    font-weight: var(--rs-weight-semibold);
    color: var(--rs-g500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.rs-sidebar__section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--rs-space-2) var(--rs-space-3) 4px;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: opacity var(--rs-transition-fast);
}
.rs-sidebar__section-toggle:hover { opacity: 0.7; }
.rs-sidebar__section-toggle:hover .rs-sidebar__section-title { color: var(--rs-g700); }

.rs-sidebar__section-chevron {
    color: var(--rs-g500);
    transition: transform var(--rs-transition-base);
}

.rs-sidebar__section-items {
    overflow: hidden;
    transition: max-height var(--rs-transition-base);
    max-height: 1000px;
}

.rs-sidebar__section.is-collapsed .rs-sidebar__section-items {
    max-height: 0;
}

.rs-sidebar__section.is-collapsed .rs-sidebar__section-chevron {
    transform: rotate(-90deg);
}

.rs-sidebar__item {
    display: flex;
    align-items: center;
    gap: var(--rs-space-3);
    padding: 7px var(--rs-space-3);
    border-radius: var(--rs-radius-md);
    color: var(--rs-g700);
    font-size: var(--rs-text-sm);
    font-weight: var(--rs-weight-medium);
    cursor: pointer;
    transition: all var(--rs-transition-fast);
    margin: 1px 0;
    text-decoration: none;
    position: relative;
}

.rs-sidebar__item:hover {
    background: var(--rs-bg-sidebar-hover);
    color: var(--rs-dark);
}

.rs-sidebar__item.is-active {
    background: var(--rs-bg-surface);
    color: var(--rs-primary);
    box-shadow: var(--rs-shadow-xs);
}
.rs-sidebar__item.is-active::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--rs-primary);
    border-radius: 0 2px 2px 0;
}

.rs-sidebar__item-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    color: currentColor;
    opacity: 0.85;
}
.rs-sidebar__item.is-active .rs-sidebar__item-icon {
    color: var(--rs-primary);
    opacity: 1;
}

.rs-sidebar__item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rs-sidebar__item-badge {
    background: var(--rs-error-bg);
    color: var(--rs-error);
    font-size: 10px;
    font-weight: var(--rs-weight-semibold);
    padding: 1px 6px;
    border-radius: var(--rs-radius-full);
    line-height: 1.4;
}

.rs-sidebar__item-shortcut {
    font-size: 10px;
    color: var(--rs-g500);
    font-family: var(--rs-font-mono);
}

/* ─── Sidebar footer ─────────────────────────────── */

.rs-sidebar__footer {
    padding: var(--rs-space-3);
    border-top: 1px solid var(--rs-border);
    background: var(--rs-bg-sidebar);
    flex: 0 0 auto;
    position: relative;
}

.rs-sidebar__user {
    display: flex;
    align-items: center;
    gap: var(--rs-space-3);
    padding: var(--rs-space-2);
    border-radius: var(--rs-radius-md);
    cursor: pointer;
    transition: background var(--rs-transition-fast);
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    font-family: inherit;
    color: inherit;
}
.rs-sidebar__user:hover { background: var(--rs-bg-sidebar-hover); }

.rs-sidebar__user-chevron {
    color: var(--rs-g500);
    flex: 0 0 14px;
    transition: transform var(--rs-transition-fast);
}
.rs-sidebar__user:hover .rs-sidebar__user-chevron { color: var(--rs-g700); transform: translateX(2px); }

.rs-sidebar__user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--rs-radius-full);
    background: var(--rs-gradient-blue-strong);
    color: var(--rs-white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--rs-text-sm);
    font-weight: var(--rs-weight-semibold);
    flex: 0 0 32px;
}

.rs-sidebar__user-meta {
    flex: 1;
    overflow: hidden;
}
.rs-sidebar__user-name {
    font-size: var(--rs-text-sm);
    font-weight: var(--rs-weight-semibold);
    color: var(--rs-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rs-sidebar__user-role {
    font-size: var(--rs-text-xs);
    color: var(--rs-g600);
}

.rs-sidebar__user-menu {
    background: transparent;
    border: 0;
    width: 24px;
    height: 24px;
    border-radius: var(--rs-radius-sm);
    color: var(--rs-g500);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.rs-sidebar__user-menu:hover { background: var(--rs-g200); color: var(--rs-dark); }

/* ─── Collapsed state ────────────────────────────── */

.rs-app.is-collapsed .rs-sidebar__logo-text,
.rs-app.is-collapsed .rs-sidebar__logo-suffix,
.rs-app.is-collapsed .rs-sidebar__section-title,
.rs-app.is-collapsed .rs-sidebar__item-label,
.rs-app.is-collapsed .rs-sidebar__item-badge,
.rs-app.is-collapsed .rs-sidebar__item-shortcut,
.rs-app.is-collapsed .rs-sidebar__user-meta,
.rs-app.is-collapsed .rs-sidebar__user-menu {
    display: none;
}

.rs-app.is-collapsed .rs-sidebar__brand {
    justify-content: center;
    padding: 0;
}

.rs-app.is-collapsed .rs-sidebar__item {
    justify-content: center;
    padding: 8px 0;
}

.rs-app.is-collapsed .rs-sidebar__user {
    justify-content: center;
    padding: var(--rs-space-2);
}

.rs-app.is-collapsed .rs-sidebar__nav {
    padding: var(--rs-space-3) var(--rs-space-2);
}

/* ─── User menu dropdown ─────────────────────────── */

.rs-user-menu {
    position: absolute;
    bottom: calc(100% + 4px);
    left: var(--rs-space-3);
    right: var(--rs-space-3);
    background: var(--rs-bg-surface);
    border: 1px solid var(--rs-border);
    border-radius: var(--rs-radius-lg);
    box-shadow: var(--rs-shadow-xl);
    overflow: hidden;
    z-index: var(--rs-z-overlay);
    animation: rs-menu-up 180ms cubic-bezier(0.4, 0, 0.2, 1);
}
.rs-user-menu[hidden] { display: none; }

@keyframes rs-menu-up {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.rs-user-menu__header {
    display: flex;
    align-items: center;
    gap: var(--rs-space-3);
    padding: var(--rs-space-4);
    border-bottom: 1px solid var(--rs-border-soft);
    background: var(--rs-g100);
}

.rs-user-menu__name {
    font-size: var(--rs-text-sm);
    font-weight: var(--rs-weight-semibold);
    color: var(--rs-dark);
}
.rs-user-menu__email {
    font-size: var(--rs-text-xs);
    color: var(--rs-g600);
    margin-top: 2px;
}

.rs-user-menu__item {
    display: flex;
    align-items: center;
    gap: var(--rs-space-3);
    padding: 9px var(--rs-space-4);
    color: var(--rs-g800);
    font-size: var(--rs-text-sm);
    cursor: pointer;
    text-decoration: none;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    font-family: inherit;
    transition: background var(--rs-transition-fast);
}
.rs-user-menu__item:hover { background: var(--rs-g100); }
.rs-user-menu__item svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--rs-g600); }
.rs-user-menu__item:hover svg { color: var(--rs-primary); }

.rs-user-menu__item--danger { color: var(--rs-error); }
.rs-user-menu__item--danger:hover { background: var(--rs-error-bg); }
.rs-user-menu__item--danger svg { color: var(--rs-error); }

.rs-user-menu__role-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--rs-radius-full);
    flex: 0 0 8px;
}

.rs-user-menu__role.is-active {
    background: var(--rs-primary-bg);
    color: var(--rs-primary-dark);
    font-weight: var(--rs-weight-semibold);
}

.rs-user-menu__check {
    margin-left: auto;
    color: var(--rs-primary);
    font-weight: var(--rs-weight-bold);
}

.rs-user-menu__divider {
    height: 1px;
    background: var(--rs-border-soft);
    margin: 4px 0;
}

.rs-user-menu__section-title {
    padding: var(--rs-space-2) var(--rs-space-4) 4px;
    font-size: 10px;
    font-weight: var(--rs-weight-semibold);
    color: var(--rs-g500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ─── Mobile (off-canvas) ────────────────────────── */

.rs-topbar__menu-mobile {
    display: none;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--rs-border);
    border-radius: var(--rs-radius-md);
    color: var(--rs-g700);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.rs-topbar__menu-mobile svg { width: 18px; height: 18px; }
.rs-topbar__menu-mobile:hover { background: var(--rs-g100); color: var(--rs-dark); }

@media (max-width: 768px) {
    .rs-app {
        grid-template-columns: 1fr !important;
    }
    .rs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--rs-sidebar-w);
        z-index: var(--rs-z-modal);
        transform: translateX(-100%);
        transition: transform var(--rs-transition-base);
        box-shadow: var(--rs-shadow-2xl);
    }
    .rs-app.is-mobile-open .rs-sidebar {
        transform: translateX(0);
    }
    .rs-app.is-mobile-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(2px);
        z-index: calc(var(--rs-z-modal) - 1);
    }
    .rs-topbar__menu-mobile {
        display: inline-flex;
    }
    .rs-topbar__search-text {
        display: none;
    }
    .rs-main__content { padding: var(--rs-space-4); }
    .rs-main__header { padding: 0 var(--rs-space-4); }
    .rs-page-header__actions { flex-wrap: wrap; }
}
