/* ==========================================================================
   Capital Razors — Sidebar Navigation Styles
   BLI-0002007 | Sprint-0000200-CR-Foundation-Auth

   Uses design tokens from cr-design-tokens.css (--cr-* variables).
   Mobile-first: off-canvas slide-out → fixed sidebar on md+.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. SIDEBAR HEADER (User Info)
   -------------------------------------------------------------------------- */

.cr-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--cr-border, #2A2A38);
}

.cr-sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cr-sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--cr-radius-full, 9999px);
    background: var(--cr-gold-dim, rgba(201, 168, 76, 0.15));
    color: var(--cr-gold, #C9A84C);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.cr-sidebar-avatar--collapsed {
    margin: 0 auto;
}

.cr-sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cr-sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cr-text-primary, #F5F0E8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cr-sidebar-user-role {
    font-size: 0.6875rem;
    color: var(--cr-gold, #C9A84C);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   2. NAVIGATION CONTAINER
   -------------------------------------------------------------------------- */

.cr-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

/* --------------------------------------------------------------------------
   3. SECTION GROUPS
   -------------------------------------------------------------------------- */

.cr-sidebar-section {
    padding: 4px 0;
}

.cr-sidebar-section + .cr-sidebar-section {
    border-top: 1px solid var(--cr-border-light, rgba(255, 255, 255, 0.04));
    margin-top: 4px;
    padding-top: 8px;
}

.cr-sidebar-section--bottom {
    margin-top: auto;
}

.cr-sidebar-section-label {
    display: block;
    padding: 12px 16px 4px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--cr-text-muted, #6B665E);
    user-select: none;
}

/* --------------------------------------------------------------------------
   4. NAV ITEMS
   -------------------------------------------------------------------------- */

.cr-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 1px 8px;
    border-radius: var(--cr-radius-md, 8px);
    color: var(--cr-text-secondary, #9A958D);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 400;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    cursor: pointer;
    min-height: 40px;
}

.cr-sidebar-item:hover {
    background: var(--cr-bg-card-hover, #22222C);
    color: var(--cr-text-primary, #F5F0E8);
}

.cr-sidebar-item.is-active {
    background: var(--cr-gold-dim, rgba(201, 168, 76, 0.15));
    color: var(--cr-gold, #C9A84C);
    font-weight: 600;
    border-left-color: var(--cr-gold, #C9A84C);
}

.cr-sidebar-item.is-active .cr-sidebar-icon {
    color: var(--cr-gold, #C9A84C);
}

/* --------------------------------------------------------------------------
   5. ICONS
   -------------------------------------------------------------------------- */

.cr-sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

/* --------------------------------------------------------------------------
   6. LABELS (hideable on collapse)
   -------------------------------------------------------------------------- */

.cr-sidebar-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

/* --------------------------------------------------------------------------
   7. COLLAPSE TOGGLE (Desktop)
   -------------------------------------------------------------------------- */

.cr-sidebar-collapse-toggle {
    padding: 8px;
    border-top: 1px solid var(--cr-border-light, rgba(255, 255, 255, 0.04));
}

.cr-sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px;
    border-radius: var(--cr-radius-md, 8px);
    color: var(--cr-text-muted, #6B665E);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
}

.cr-sidebar-collapse-btn:hover {
    background: var(--cr-bg-card-hover, #22222C);
    color: var(--cr-text-primary, #F5F0E8);
}

/* --------------------------------------------------------------------------
   8. COLLAPSED STATE (Desktop only — md+)
   -------------------------------------------------------------------------- */

@media (min-width: 768px) {
    .cr-sidebar {
        display: flex;
        flex-direction: column;
    }

    .cr-sidebar.is-collapsed {
        width: 72px;
    }

    .cr-sidebar.is-collapsed .cr-sidebar-label,
    .cr-sidebar.is-collapsed .cr-sidebar-section-label,
    .cr-sidebar.is-collapsed .cr-sidebar-user-info {
        display: none;
    }

    .cr-sidebar.is-collapsed .cr-sidebar-user {
        justify-content: center;
    }

    .cr-sidebar.is-collapsed .cr-sidebar-item {
        justify-content: center;
        padding: 10px;
        margin: 1px 4px;
        gap: 0;
        border-left-width: 0;
        border-bottom: 2px solid transparent;
    }

    .cr-sidebar.is-collapsed .cr-sidebar-item.is-active {
        border-left-color: transparent;
        border-bottom-color: var(--cr-gold, #C9A84C);
    }

    .cr-sidebar.is-collapsed .cr-sidebar-header {
        padding: 12px 8px;
    }

    /* Tooltip on hover when collapsed */
    .cr-sidebar.is-collapsed .cr-sidebar-item {
        position: relative;
    }

    .cr-sidebar.is-collapsed .cr-sidebar-item::after {
        content: attr(title);
        position: absolute;
        left: calc(100% + 8px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--cr-bg-card, #1A1A22);
        color: var(--cr-text-primary, #F5F0E8);
        padding: 6px 12px;
        border-radius: var(--cr-radius-sm, 4px);
        font-size: 0.75rem;
        white-space: nowrap;
        box-shadow: var(--cr-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.4));
        border: 1px solid var(--cr-border, rgba(255, 255, 255, 0.08));
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s ease;
        z-index: 50;
    }

    .cr-sidebar.is-collapsed .cr-sidebar-item:hover::after {
        opacity: 1;
    }

    /* Adjust main content for collapsed sidebar */
    .cr-sidebar.is-collapsed ~ .cr-main {
        padding-left: 72px;
    }
}

/* --------------------------------------------------------------------------
   9. MOBILE ENHANCEMENTS
   -------------------------------------------------------------------------- */

@media (max-width: 767px) {
    .cr-sidebar-item {
        padding: 12px 16px;
        min-height: 44px; /* Touch-friendly */
    }

    .cr-sidebar-collapse-toggle {
        display: none;
    }

    /* Close button at top of mobile sidebar */
    .cr-sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}

/* --------------------------------------------------------------------------
   10. SCROLLBAR (thin, themed)
   -------------------------------------------------------------------------- */

.cr-sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.cr-sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.cr-sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--cr-border, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
}

.cr-sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--cr-text-muted, #6B665E);
}
