.toolbar {
    height: 48px;
    background-color: var(--color-shell-surface, var(--color-surface-primary-variant));
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-level1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    z-index: 90;
    /* REMOVED: transition that was causing slide-in animation on resize */
}

/* Toolbar left container for module-specific controls */
.toolbar-left {
    display: flex;
    align-items: center;
}

/* ===========================================
 * Custom Select Dropdown (Kalender-Ansicht)
 * Ersetzt natives <select> für bessere Kontrolle
 * =========================================== */

.custom-select {
    position: relative;
    width: 165px;
    min-width: 165px;
    max-width: 165px;
    flex: 0 0 165px; /* Feste Breite knapp über längstem DE-Label, verhindert springende Breiten durch Optionstexte */
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: var(--form-control-min-height);
    padding: 8px 12px;
    background-color: var(--color-input-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: var(--form-control-font-size);
    font-family: inherit;
    cursor: pointer;
}

.custom-select-trigger:hover {
    border-color: var(--color-text-secondary);
}

.custom-select-trigger:focus {
    outline: none;
    border-color: var(--color-text-secondary);
}

.custom-select-value {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select-arrow {
    width: 16px;
    height: 16px;
    font-size: 16px;
    color: var(--color-text-secondary);
    margin-left: 8px;
    flex-shrink: 0;
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: var(--color-surface-secondary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: var(--shadow-level2);
    z-index: 200;
    display: none;
    max-height: none;
    overflow: visible;
}

.custom-select.open .custom-select-dropdown {
    display: block;
}

.custom-select-option {
    padding: 10px 12px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-primary);
}

.custom-select-option:hover {
    background-color: var(--color-interactive-hover);
    color: var(--color-context-foreground);
}

.custom-select-option.active {
    background-color: var(--color-context-background);
    color: var(--color-context-foreground);
}

.custom-select-option.active:hover {
    background-color: var(--color-interactive-hover);
    color: var(--color-context-foreground);
}

/* Mobile Custom Select (legacy, kept for backwards compatibility) */
.mobile-custom-select {
    min-width: 140px;
    flex-shrink: 0;
}

/* ===========================================
 * Filter Chip (Kalender-Ansicht)
 * Kompakter Chip mit dynamischem Icon und festem Label
 * =========================================== */

.filter-chip {
    position: relative;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    flex: 0 0 160px; /* Fixed width to accommodate longest label (NL: "Weergave") + icon + arrow */
}

.filter-chip-trigger {
    display: flex;
    align-items: center;
    gap: var(--icon-label-gap);
    width: 100%;
    height: var(--form-control-min-height);
    padding: 8px 16px;
    background-color: var(--color-input-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: var(--form-control-font-size);
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.filter-chip-trigger:hover {
    border-color: var(--color-text-secondary);
}

.filter-chip-trigger:focus {
    outline: none;
    border-color: var(--color-text-secondary);
}

.filter-chip-icon {
    width: 18px;
    height: 18px;
    font-size: 18px;
    color: var(--color-text-primary);
    flex-shrink: 0;
}

.filter-chip-label {
    flex: 1;
    text-align: left;
    color: var(--color-text-primary);
}

.filter-chip-arrow {
    width: 16px;
    height: 16px;
    font-size: 16px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.filter-chip-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    background-color: var(--color-surface-secondary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: var(--shadow-level2);
    z-index: 200;
    display: none;
}

.filter-chip.open .filter-chip-dropdown {
    display: block;
}

.filter-chip-option {
    padding: 10px 12px;
    cursor: pointer;
    white-space: nowrap;
    color: var(--color-text-primary);
}

.filter-chip-option:hover {
    background-color: var(--color-interactive-hover);
    color: var(--color-context-foreground);
}

.filter-chip-option.active {
    background-color: var(--color-context-background);
    color: var(--color-context-foreground);
}

.filter-chip-option.active:hover {
    background-color: var(--color-interactive-hover);
    color: var(--color-context-foreground);
}

/* Mobile Filter Chip */
.mobile-filter-chip {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    flex: 0 0 150px; /* Slightly smaller than desktop but still fits all labels */
}

/* Native select for mobile - hidden by default on desktop */
.filter-chip-native-select {
    display: none;
}

/* ===========================================
 * Calendar Navigation Buttons
 * Zurück/Heute/Vor Navigation für Kalender
 * =========================================== */

.calendar-nav {
    display: flex;
    align-items: center;
    margin-left: 12px;
}

.calendar-nav-btn {
    height: var(--form-control-min-height);
    padding: 0 12px;
    background-color: var(--color-input-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 0;
    font-size: var(--form-control-font-size);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: -1px;
    position: relative;
}

.calendar-nav-btn:first-child {
    border-radius: 4px 0 0 4px;
    margin-left: 0;
}

.calendar-nav-btn:last-child {
    border-radius: 0 4px 4px 0;
}

.calendar-nav-btn:hover {
    border-color: var(--color-text-secondary);
    background-color: var(--color-surface-primary-variant);
    z-index: 1;
}

.calendar-nav-btn:focus {
    outline: none;
    border-color: var(--color-text-secondary);
    z-index: 1;
}

.calendar-nav-btn:active {
    background-color: var(--color-interactive-hover);
    color: var(--color-context-foreground);
    z-index: 1;
}

.calendar-nav-today {
    width: 105px;
    min-width: 105px;
    max-width: 105px; /* Fixed width to accommodate longest label (FR: "Aujourd'hui") */
}

.calendar-nav-icon {
    width: 16px;
    height: 16px;
    font-size: 16px;
    color: inherit;
}

/* Mobile Calendar Navigation */
.mobile-calendar-nav {
    margin-left: 8px;
}

.mobile-calendar-nav .calendar-nav-btn {
    height: var(--form-control-min-height);
    padding: 0 10px;
    font-size: 14px;
}

.mobile-calendar-nav .calendar-nav-today {
    width: 95px;
    min-width: 95px;
    max-width: 95px; /* Fixed width proportional to desktop */
}

.toolbar.with-sidenav {
    margin-left: 230px;
}

.toolbar.with-sidenav.sidenav-collapsed {
    margin-left: 64px;
}

@media (max-width: 1023px) {
    .toolbar {
        display: none !important; /* Desktop-Toolbar wird durch mobile-toolbar ersetzt */
    }

    .toolbar.with-sidenav {
        display: none !important;
        margin-left: 0 !important;
    }

    .toolbar.with-sidenav.sidenav-collapsed {
        display: none !important;
        margin-left: 0 !important;
    }
}



.toolbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.btn-cta {
    height: 40px;
    padding: 0 20px;
    background-color: var(--color-context-background);
    color: var(--color-context-foreground);
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    transition: filter 200ms ease;
}

@media (max-width: 1023px) {
    .btn-cta {
        display: none !important; /* Button wird in mobiler Ansicht nicht angezeigt */
    }
}

.btn-cta:hover {
    background-color: var(--color-interactive-cta-hover);
}

.btn-cta:active {
    background-color: var(--color-context-background);
    filter: brightness(1.1);
}

@media (max-width: 1023px) {
    .btn-cta:active {
        background-color: var(--color-interactive-cta-hover);
        filter: brightness(1.1);
        box-shadow: 0 1px 4px rgba(15, 98, 254, 0.15);
    }
}

.btn-icon {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

.btn-cta .cta-icon {
    margin-right: 8px;
}

.toolbar-icon-button {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.toolbar-icon-button:hover {
    background-color: var(--color-interactive-hover);
}

.toolbar-icon {
    width: 20px;
    height: 20px;
    font-size: 20px;
    color: var(--color-text-primary);
}

/* Mobile Toolbar mit Suchfeld */
.mobile-toolbar {
    display: none;
}

@media (max-width: 1023px) {
    .mobile-toolbar {
        display: flex !important;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        height: 48px;
        padding: 4px 16px;
        background-color: var(--color-shell-surface, var(--color-surface-primary-variant));
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-level1);
        z-index: 89;
        align-items: center;
    }

    /* Im Dashboard wird das Suchfeld ausgeblendet */
    .mobile-toolbar.dashboard-mode .module-search-field {
        display: none;
    }

    /* Im Kalender-Modul wird das Suchfeld durch die View-Select ersetzt */
    .mobile-toolbar.calendar-mode .module-search-field {
        display: none;
    }

    .mobile-toolbar-search {
        width: 100%;
        display: flex;
        align-items: center;
        background-color: var(--color-input-surface);
        border: 1px solid var(--color-border);
        border-radius: 4px;
        padding: 0 12px;
        height: var(--form-control-min-height);
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-toolbar-search:focus-within {
        outline: none;
        border-color: var(--color-text-secondary);
        background-color: var(--color-input-surface);
        box-shadow: none;
    }

    .mobile-toolbar-search-icon {
        width: 20px;
        height: 20px;
        font-size: 20px;
        color: var(--color-text-secondary);
        margin-right: 12px;
        flex-shrink: 0;
        pointer-events: none;
    }

    /* Mobile search input - eingebettet in .mobile-toolbar-search Container */
    /* Grundlegende Reset-Styles kommen aus main.css (input.mobile-toolbar-search-input) */
    .mobile-toolbar-search-input {
        flex: 1;
        color: var(--color-text-primary);
        font-size: 14px;
        outline: none;
    }

    .mobile-toolbar-search-input:focus {
        outline: none;
    }

    .mobile-toolbar-search-input::placeholder {
        color: var(--color-text-secondary);
        opacity: 0.7;
    }

    /* Verhindert Autofill-Hintergrund */
    .mobile-toolbar-search-input:-webkit-autofill,
    .mobile-toolbar-search-input:-webkit-autofill:hover,
    .mobile-toolbar-search-input:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0px 1000px var(--color-input-surface) inset;
        -webkit-text-fill-color: var(--color-text-primary);
    }

    .mobile-search-clear-button {
        width: 28px;
        height: 28px;
        margin-left: 8px;
        border: none;
        border-radius: 50%;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: var(--color-text-secondary);
        cursor: pointer;
        opacity: 0;
        pointer-events: none;
        transition: opacity 150ms ease;
    }

    .mobile-search-clear-button .icon {
        width: 16px;
        height: 16px;
        font-size: 16px;
    }

    .mobile-search-clear-button.is-visible {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-search-clear-button:hover,
    .mobile-search-clear-button:focus-visible {
        color: var(--color-text-primary);
        background-color: rgba(var(--color-border-rgb, 224, 224, 224), 0.4);
        outline: none;
    }

    .mobile-search-clear-button:focus-visible {
        box-shadow: 0 0 0 2px rgba(var(--color-border-rgb, 224, 224, 224), 0.6);
    }

    /* Native select overlay for mobile filter-chip
     * The native select is positioned over the trigger button with opacity: 0
     * so it captures touch events and opens the native picker, while the
     * visual appearance remains the custom filter-chip styling */
    .mobile-filter-chip .filter-chip-native-select {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
        z-index: 10;
        /* Ensure native select captures all touch events */
        -webkit-appearance: none;
        appearance: none;
    }

    /* Hide the custom dropdown on mobile - native select takes over */
    .mobile-filter-chip .filter-chip-dropdown {
        display: none !important;
    }

    /* Prevent trigger button click events on mobile (native select handles it) */
    .mobile-filter-chip .filter-chip-trigger {
        pointer-events: none;
    }
}

@media (max-width: 600px) {
    .mobile-toolbar {
        padding: 6px 12px;
        gap: 8px;
    }

    .mobile-toolbar .mobile-filter-chip {
        flex: 0 0 150px;
        width: 150px;
        min-width: 150px;
        max-width: 150px;
    }

    .mobile-toolbar .mobile-filter-chip .filter-chip-trigger {
        height: var(--form-control-min-height);
        min-height: var(--form-control-min-height);
        padding: 10px 12px;
        font-size: var(--form-label-font-size);
    }

    .mobile-toolbar .mobile-filter-chip .filter-chip-icon,
    .mobile-toolbar .mobile-filter-chip .filter-chip-arrow {
        width: 20px;
        height: 20px;
        font-size: 20px;
    }

    .mobile-toolbar .mobile-filter-chip .filter-chip-label {
        font-size: var(--form-label-font-size);
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-toolbar .mobile-filter-chip .filter-chip-dropdown {
        min-width: 100%;
        max-width: calc(100vw - 24px);
    }

    .mobile-toolbar .mobile-filter-chip .filter-chip-option {
        padding: 12px 14px;
        font-size: var(--form-label-font-size);
        line-height: 1.4;
        white-space: normal;
    }

    .mobile-toolbar .mobile-calendar-nav {
        margin-left: 6px;
    }

    .mobile-toolbar .mobile-calendar-nav .calendar-nav-btn {
        height: var(--form-control-min-height);
        min-height: var(--form-control-min-height);
        padding: 0 8px;
        font-size: var(--form-label-font-size);
    }

    .mobile-toolbar .mobile-calendar-nav .calendar-nav-today {
        width: auto;
        min-width: 88px;
        max-width: 120px;
    }
}

/* Floating Action Button */
.fab {
    display: none;
}

@media (max-width: 1023px) {
    .fab {
        display: flex;
        position: fixed;
        bottom: 100px;
        right: 16px;
        width: 56px;
        height: 56px;
        background-color: var(--color-context-background);
        color: var(--color-context-foreground);
        border-radius: 28px;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(15, 98, 254, 0.35);
        z-index: 95;
        cursor: pointer;
        transition: transform 200ms ease, box-shadow 200ms ease, filter 200ms ease;
        border: none;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .fab:active {
        filter: brightness(1.1);
        box-shadow: 0 2px 8px rgba(15, 98, 254, 0.25);
    }

    .fab-icon {
        width: 24px;
        height: 24px;
        font-size: 24px;
        color: var(--color-context-foreground);
    }

    .fab-text {
        display: none;
    }

    /* Erweiterbarer FAB bei Bedarf */
    .fab.extended {
        width: auto;
        padding: 0 20px;
        min-width: 56px;
    }

    .fab.extended .fab-text {
        display: inline;
        margin-left: 8px;
        font-size: 15px;
        font-weight: 600;
    }
}
