/*!
 * Sidebar Navigation Component
 * Version: 2.0.0
 * Hierarchiczne menu kategorii dla sidebara
 * BEM methodology, mobile-first, WCAG 2.1 AA compliant
 */

/* ==========================================================================
   BASE STYLES
   ========================================================================== */

.sidebar-nav {
    font-size: 0.9375rem; /* 15px */
    line-height: 1.5;
}

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

.sidebar-nav__list--root {
    /* Root level - no extra spacing */
}

.sidebar-nav__list--submenu {
    padding-left: 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s ease-out;
}

.sidebar-nav__list--submenu:not(.sidebar-nav__list--collapsed) {
    opacity: 1;
}

.sidebar-nav__list--collapsed {
    max-height: 0 !important;
    opacity: 0;
}

/* ==========================================================================
   MENU ITEMS
   ========================================================================== */

.sidebar-nav__item {
    position: relative;
    border-bottom: 1px solid var(--color-bg-light);
}

.sidebar-nav__item:last-child {
    border-bottom: none;
}

/* Child items - indented with left padding */
.sidebar-nav__item--child {
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-nav__item--child .sidebar-nav__link {
    padding-left: 2.5rem;
    font-size: 0.875rem;
}

/* Deeper nesting */
.sidebar-nav__item--depth-2 .sidebar-nav__link {
    padding-left: 3.5rem;
    font-size: 0.8125rem;
}

.sidebar-nav__item--depth-3 .sidebar-nav__link {
    padding-left: 4.5rem;
}

/* ==========================================================================
   LINK WRAPPER (contains toggle + link)
   ========================================================================== */

.sidebar-nav__link-wrapper {
    display: flex;
    align-items: stretch;
    position: relative;
}

/* ==========================================================================
   TOGGLE BUTTON (expand/collapse) - Arrow Right
   ========================================================================== */

.sidebar-nav__toggle {
    flex-shrink: 0;
    width: 2.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 2;
}

.sidebar-nav__toggle:hover {
    background-color: transparent;
    color: var(--color-primary);
}

.sidebar-nav__toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

/* Toggle icon - Arrow pointing RIGHT when collapsed */
.sidebar-nav__toggle-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    transform: rotate(0deg); /* Right arrow by default (collapsed) */
}

/* Expanded state - Arrow pointing DOWN */
.sidebar-nav__toggle[aria-expanded="true"] .sidebar-nav__toggle-icon {
    transform: rotate(90deg); /* Rotate to point down */
}

/* ==========================================================================
   MENU LINKS
   ========================================================================== */

.sidebar-nav__link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 0.75rem 0.875rem 0.75rem;
    color: var(--color-text-primary);
    text-decoration: none;
    background-color: transparent;
    transition: all 0.2s ease;
    position: relative;
    font-weight: 500;
}

/* Links with toggle button - add left padding for button space */
.sidebar-nav__item--has-children .sidebar-nav__link {
    padding-left: 2.5rem;
}

/* Child items with parent that has toggle - extra padding */
.sidebar-nav__item--child.sidebar-nav__item--has-children .sidebar-nav__link {
    padding-left: 4.5rem;
}

.sidebar-nav__item--child .sidebar-nav__toggle {
    left: 2rem;
}

/* Root level links */
.sidebar-nav__list--root > .sidebar-nav__item > .sidebar-nav__link-wrapper > .sidebar-nav__link {
    font-weight: 600;
}

/* Hover state - subtle background */
.sidebar-nav__link:hover {
    background-color: #f9f9f9;
    color: var(--color-primary);
}

/* Focus state */
.sidebar-nav__link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    background-color: #f9f9f9;
}

/* Current page - highlighted with primary color background */
.sidebar-nav__link--current {
    background-color: var(--color-primary);
    color: var(--color-bg-white);
    font-weight: 600;
}

.sidebar-nav__link--current:hover {
    background-color: #6b3420;
    color: var(--color-bg-white);
}

/* Ancestor of current page - primary color text */
.sidebar-nav__item--ancestor > .sidebar-nav__link-wrapper > .sidebar-nav__link {
    color: var(--color-primary);
    font-weight: 600;
}

/* ==========================================================================
   ICONS
   ========================================================================== */

.sidebar-nav__icon {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.sidebar-nav__link:hover .sidebar-nav__icon,
.sidebar-nav__link--current .sidebar-nav__icon {
    opacity: 1;
}

/* ==========================================================================
   TEXT & COUNT
   ========================================================================== */

.sidebar-nav__text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav__count {
    flex-shrink: 0;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    opacity: 0.8;
    font-weight: 500;
    margin-left: auto;
}

.sidebar-nav__link--current .sidebar-nav__count {
    color: var(--color-bg-white);
    opacity: 0.9;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/* Tablet and up */
@media (min-width: 768px) {
    .sidebar-nav {
        font-size: 1rem; /* 16px */
    }

    .sidebar-nav__link {
        padding: 1rem 0.875rem;
    }

    .sidebar-nav__item--has-children .sidebar-nav__link {
        padding-left: 2.75rem;
    }

    .sidebar-nav__toggle {
        width: 2.75rem;
    }
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .sidebar-nav__toggle-icon,
    .sidebar-nav__list--submenu,
    .sidebar-nav__link,
    .sidebar-nav__toggle {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .sidebar-nav__link {
        border: 1px solid transparent;
    }

    .sidebar-nav__link:hover,
    .sidebar-nav__link:focus-visible {
        border-color: currentColor;
    }

    .sidebar-nav__item {
        border-bottom-width: 2px;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .sidebar-nav__toggle {
        display: none;
    }

    .sidebar-nav__list--collapsed {
        max-height: none !important;
        opacity: 1;
    }

    .sidebar-nav__link {
        background-color: transparent !important;
        color: #000 !important;
    }

    .sidebar-nav__item {
        border-bottom: 1px solid #ddd;
    }
}

/* ==========================================================================
   WIDGET WRAPPER STYLES
   ========================================================================== */

.widget-sidebar-nav {
    background-color: var(--color-bg-white);
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-bg-light);
    overflow: hidden;
}

.widget-sidebar-nav .widget-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
    padding: 1.25rem 1.5rem;
    border-bottom: 2px solid var(--color-bg-light);
    background-color: #fafafa;
}

.widget-sidebar-nav .sidebar-nav {
    padding: 0;
}

/* Mobile: Reduce padding */
@media (max-width: 767px) {
    .widget-sidebar-nav {
        border-radius: 6px;
    }

    .widget-sidebar-nav .widget-title {
        font-size: 1.125rem;
        padding: 1rem 1.25rem;
    }
}
