/**
 * Themenbereiche Sidebar - Wiederverwendbare Komponente
 * =====================================================
 * Linke Navigationsleiste mit den FID-Themenbereichen.
 * Wird per {% include %} eingebunden.
 *
 * CSS-Klassen-Prefix: tb-  (fuer "Themenbereiche")
 */

/* ============================================
   SIDEBAR CONTAINER
   ============================================ */

.tb-sidebar {
    width: 280px;
    min-width: 280px;
    background: transparent !important;
    border-right: 1px solid var(--border-light, #e9ecef);
    padding: 2rem 0;
    position: sticky;
    top: 100px;
    height: fit-content;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}

.tb-sidebar::-webkit-scrollbar {
    width: 6px;
}

.tb-sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-color, #8ED1B0);
    border-radius: 3px;
}

.tb-sidebar.tb-sidebar--sort {
    padding: 0;
    border-bottom: 1px solid var(--border-light, #e9ecef);
    overflow: visible;
}

.tb-sidebar.tb-sidebar--sort + .tb-sidebar {
    padding-top: 0;
}

.tb-sidebar.tb-sidebar--sort nav {
    padding: 0 1.5rem 0.35rem;
    position: relative;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-control {
    position: relative;
    z-index: 20;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-control.is-open {
    z-index: 40;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-summary {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.65rem;
    min-height: 56px;
    padding: 0.64rem 0.76rem;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-dark, #1a202c);
    box-shadow: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-control.is-open .tb-sort-summary {
    border-color: var(--accent-color, #8ED1B0);
    box-shadow: none;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-summary:focus,
.tb-sidebar.tb-sidebar--sort .tb-sort-summary:focus-visible {
    outline: none;
    border-color: var(--accent-color, #8ED1B0);
    box-shadow: 0 0 0 3px rgba(142, 209, 176, 0.25);
}

.tb-sidebar.tb-sidebar--sort .tb-sort-summary-copy {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 0.12rem;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-label {
    color: var(--text-muted, #6b7280);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-current {
    overflow: hidden;
    color: var(--text-dark, #1a202c);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-chevron {
    flex-shrink: 0;
    color: var(--primary-color, #00618F);
    font-size: 1rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-control.is-open .tb-sort-chevron {
    color: var(--accent-color, #8ED1B0);
    transform: rotate(180deg);
}

.tb-sidebar.tb-sidebar--sort .tb-sort-popover {
    display: none;
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    left: 0;
    z-index: 50;
    overflow: hidden;
    padding: 0.35rem 0;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 14px 30px rgba(7, 31, 49, 0.16);
}

.tb-sidebar.tb-sidebar--sort .tb-sort-control.is-open .tb-sort-popover {
    display: block;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link {
    min-height: 42px;
    padding: 0.72rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link:hover,
.tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link:focus {
    background: linear-gradient(90deg, rgba(142, 209, 176, 0.1) 0%, transparent 100%);
    border-left-color: var(--accent-color, #8ED1B0);
    padding-left: 1.18rem;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active,
.tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active:hover,
.tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active:focus {
    background: linear-gradient(90deg, var(--accent-color, #8ED1B0) 0%, rgba(142, 209, 176, 0.2) 100%);
    border-left-color: var(--accent-color, #8ED1B0);
    color: #ffffff;
    font-weight: 700;
    padding-left: 1rem;
}

.tb-sidebar.tb-sidebar--sort .tb-sort-link span {
    min-width: 0;
    flex: 1;
}

/* ============================================
   SECTION HEADERS
   ============================================ */

.tb-sidebar .tb-nav-header {
    padding: 0 1.5rem 0.5rem;
    border-bottom: none;
    margin-bottom: 0.5rem;
}

/* MAIN HEADER - schlicht, passt zur Sidebar */
.tb-sidebar .tb-nav-header--main {
    margin: 0 var(--tb-sidebar-row-x, 1.5rem) 1.25rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.72rem;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.tb-sidebar .tb-nav-header--main::before {
    display: none;
}

.tb-sidebar .tb-nav-header h5 {
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    margin: 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Main-Header-Titel: etwas prominenter, aber konsistent */
.tb-sidebar .tb-nav-header--main h5 {
    font-size: 1.10rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-dark, #1a202c);
    line-height: 1.2;
}

.tb-sidebar .tb-nav-header-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 97, 143, 0.1);
    color: var(--primary-color, #00618F);
    font-size: 1rem;
    flex-shrink: 0;
}

.tb-sidebar .tb-nav-header-icon i {
    line-height: 1;
}

/* Sub-Header: gleicher Stil wie Main, aber mit Abstand nach oben */
.tb-sidebar .tb-nav-header--sub {
    margin-top: 1.5rem;
    padding-top: 0;
}

/* ============================================
   NAVIGATION ITEMS
   ============================================ */
.tb-sidebar .tb-nav-item {
    margin: 0.25rem 0;
}

.tb-sidebar .tb-nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: var(--text-dark, #1a202c);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
}

.tb-sidebar .tb-nav-link i {
    font-size: 1.2rem;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
    color: var(--primary-color, #2c3e50);
    transition: all 0.3s ease;
}

/* Hover */
.tb-sidebar .tb-nav-link:hover {
    background: linear-gradient(90deg, rgba(142,209,176,0.1) 0%, transparent 100%);
    border-left-color: var(--accent-color, #8ED1B0);
    padding-left: 1.75rem;
}

.tb-sidebar .tb-nav-link:hover i {
    color: var(--accent-color, #8ED1B0);
    transform: scale(1.1);
}

/* Active */
.tb-sidebar .tb-nav-link.active {
    background: linear-gradient(90deg, var(--accent-color, #8ED1B0) 0%, rgba(142,209,176,0.2) 100%);
    border-left-color: var(--accent-color, #8ED1B0);
    color: white;
    font-weight: 700;
}

.tb-sidebar .tb-nav-link.active i {
    color: white;
}

/* Focus - clean */
.tb-sidebar .tb-nav-link:focus,
.tb-sidebar .tb-nav-link:focus-visible {
    outline: none !important;
    box-shadow: none;
    border-top: none !important;
    border-bottom: none !important;
}

[data-theme="dark"] .tb-sidebar,
.dark-mode .tb-sidebar {
    border-right-color: var(--border-light, #3a3b3c);
}

[data-theme="dark"] .tb-sidebar.tb-sidebar--sort .tb-sort-label,
.dark-mode .tb-sidebar.tb-sidebar--sort .tb-sort-label {
    color: var(--text-muted, #a0aec0);
}

[data-theme="dark"] .tb-sidebar.tb-sidebar--sort .tb-sort-summary,
.dark-mode .tb-sidebar.tb-sidebar--sort .tb-sort-summary {
    border-color: var(--border-light, #2f3944);
    background: #121820;
    color: var(--text-dark, #f4f7fa);
    box-shadow: none;
}

[data-theme="dark"] .tb-sidebar.tb-sidebar--sort .tb-sort-control.is-open .tb-sort-summary,
.dark-mode .tb-sidebar.tb-sidebar--sort .tb-sort-control.is-open .tb-sort-summary {
    border-color: var(--accent-color, #9ee1c0);
    box-shadow: none;
}

[data-theme="dark"] .tb-sidebar.tb-sidebar--sort .tb-sort-current,
.dark-mode .tb-sidebar.tb-sidebar--sort .tb-sort-current {
    color: var(--text-dark, #f4f7fa);
}

[data-theme="dark"] .tb-sidebar.tb-sidebar--sort .tb-sort-popover,
.dark-mode .tb-sidebar.tb-sidebar--sort .tb-sort-popover {
    border-color: var(--border-light, #2f3944);
    background: #121820;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.36);
}

[data-theme="dark"] .tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active,
[data-theme="dark"] .tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active:hover,
[data-theme="dark"] .tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active:focus,
.dark-mode .tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active,
.dark-mode .tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active:hover,
.dark-mode .tb-sidebar.tb-sidebar--sort .tb-sort-popover .tb-sort-link.active:focus {
    background: linear-gradient(90deg, var(--accent-color, #9ee1c0) 0%, rgba(158, 225, 192, 0.35) 100%);
    border-left-color: var(--accent-color, #9ee1c0);
    color: #113629;
}

[data-theme="dark"] .tb-sidebar .tb-nav-header h5,
.dark-mode .tb-sidebar .tb-nav-header h5,
[data-theme="dark"] .tb-sidebar .tb-nav-link,
.dark-mode .tb-sidebar .tb-nav-link {
    color: var(--text-dark, #e8e9ea);
}

[data-theme="dark"] .tb-sidebar .tb-nav-header h5,
.dark-mode .tb-sidebar .tb-nav-header h5 {
    color: var(--text-muted, #a0aec0);
}

[data-theme="dark"] .tb-sidebar .tb-nav-link i,
.dark-mode .tb-sidebar .tb-nav-link i {
    color: var(--primary-color, #6bb0f8);
}

[data-theme="dark"] .tb-sidebar .tb-nav-header--main,
.dark-mode .tb-sidebar .tb-nav-header--main {
    border-color: #2f3944;
    background: #121820;
    box-shadow: none;
}

[data-theme="dark"] .tb-sidebar .tb-nav-header--main h5,
.dark-mode .tb-sidebar .tb-nav-header--main h5 {
    color: #f4f7fa;
}

[data-theme="dark"] .tb-sidebar .tb-nav-header-icon,
.dark-mode .tb-sidebar .tb-nav-header-icon {
    background: rgba(159, 210, 255, 0.12);
    color: var(--primary-color, #9fd2ff);
}

[data-theme="dark"] .tb-sidebar .tb-nav-link:hover i,
.dark-mode .tb-sidebar .tb-nav-link:hover i {
    color: var(--accent-color, #9ee1c0);
}

[data-theme="dark"] .tb-sidebar .tb-nav-link.active,
.dark-mode .tb-sidebar .tb-nav-link.active {
    background: linear-gradient(90deg, var(--accent-color, #9ee1c0) 0%, rgba(158, 225, 192, 0.35) 100%);
    border-left-color: var(--accent-color, #9ee1c0);
    color: #113629;
}

[data-theme="dark"] .tb-sidebar .tb-nav-link.active i,
.dark-mode .tb-sidebar .tb-nav-link.active i {
    color: #113629;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
    .tb-sidebar {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-light, #e9ecef);
        position: relative;
        top: 0;
        max-height: none;
        padding: 1rem 0;
    }

    [data-theme="dark"] .tb-sidebar,
    .dark-mode .tb-sidebar {
        border-bottom-color: #3a3b3c;
    }
}
