/* ═══════════════════════════════════════════════════════════════
 * Advanced Filter v4.2 — Toggle + Inline Slide-In
 * v4.2: Fixed-width fields + ellipsis, no dynamic minWidth
 * ═══════════════════════════════════════════════════════════════ */

/* ── Toggle Button ─────────────────────────────────────────── */
.af-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    background: #f0f7ff;
    color: #3b82f6;
    cursor: pointer;
    border: 1.5px solid #bfdbfe;
    transition: all 0.15s ease;
    user-select: none;
    flex-shrink: 0;
    position: relative;
}
.af-toggle svg {
    width: 15px; height: 15px;
    stroke: #3b82f6;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.af-toggle:hover {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    box-shadow: 0 1px 4px rgba(59,130,246,0.25);
}
.af-toggle:hover svg { stroke: #fff; }

.af-toggle.open {
    color: #fff;
    background: #3b82f6;
    border-color: #3b82f6;
    box-shadow: 0 1px 4px rgba(59,130,246,0.25);
}
.af-toggle.open svg { stroke: #fff; }

/* Badge */
.af-badge {
    min-width: 16px; height: 16px;
    background: #ef4444; color: #fff;
    font-size: 0.55rem; font-weight: 700;
    border-radius: 8px;
    display: none;
    align-items: center; justify-content: center;
    padding: 0 4px; line-height: 1;
}
.af-badge.visible { display: inline-flex; }
.af-toggle.open .af-badge { background: #fca5a5; color: #7f1d1d; }

/* ── Inline Fields Container ───────────────────────────────── */
.af-inline {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                visibility 0s 0.3s;
    padding: 0 1.25rem;
    box-sizing: border-box;
}
.af-inline.open {
    max-height: 50px;
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
    visibility: visible;
    padding: 0.4rem 1.25rem;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                visibility 0s 0s;
}

/* ── Shared Input Base ─────────────────────────────────────── */
.af-field {
    height: 30px;
    padding: 0 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.76rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    box-sizing: border-box;
}
.af-field:hover { border-color: #cbd5e1; background: #fff; }
.af-field:focus {
    border-color: #93c5fd; background: #fff;
    box-shadow: 0 0 0 1.5px rgba(59,130,246,0.08);
}
.af-field::placeholder { color: #94a3b8; font-size: 0.74rem; }

/* ── Field Types ───────────────────────────────────────────── */
.af-field--search { width: 100px; flex-shrink: 1; min-width: 70px; }

.af-field--text {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Date */
.af-field--date {
    width: 105px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 0.72rem;
    color: #64748b;
}

/* ── Kunde Wrap ────────────────────────────────────────────── */
.af-kunde-wrap {
    position: relative;
    flex: 1 1 160px;
    min-width: 100px;
    max-width: 400px;
}
.af-kunde-wrap .af-field--text {
    width: 100%;
}

/* ── Dropdown Wraps (Hersteller, Gerät, DL, Status) ───────── */
.af-dropdown-wrap {
    position: relative;
    flex-shrink: 0;
}
.af-dropdown-wrap .af-field--text {
    width: 100%;
    cursor: pointer;
    padding-right: 20px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}
.af-dropdown-wrap .af-field--text.has-value {
    color: #1e293b;
    font-weight: 500;
    text-overflow: clip;
    overflow: visible;
}

/* Per-field widths (min, grow with content) */
#afHersteller     { min-width: 90px; width: auto; }
#afGeraet         { min-width: 70px; width: auto; }
#afDienstleister  { min-width: 90px; width: auto; }
#afStatus         { min-width: 90px; width: auto; }

/* Status: Icon ersetzt Chevron */
#afStatus.has-value {
    padding-left: 28px;
    background-image: none;
    min-width: 140px;
}

/* ── Dropdown Panels ───────────────────────────────────────── */
.af-kunde-dropdown {
    display: none;
    position: fixed;
    min-width: 220px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    max-height: 200px;
    overflow-y: auto;
}
.af-kunde-dropdown.show { display: block; }
.af-kunde-dropdown .af-kd-item {
    padding: 6px 10px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}
.af-kunde-dropdown .af-kd-item:last-child { border-bottom: none; }
.af-kunde-dropdown .af-kd-item:hover { background: #f0f7ff; }
.af-kunde-dropdown .af-kd-name {
    font-weight: 500; font-size: 0.78rem; color: #1e293b;
}
.af-kunde-dropdown .af-kd-info {
    font-size: 0.67rem; color: #94a3b8; margin-top: 1px;
}
.af-kunde-dropdown .af-kd-info span { margin-right: 8px; }
.af-kunde-dropdown .af-kd-empty {
    padding: 8px 10px; text-align: center;
    color: #94a3b8; font-size: 0.75rem;
}

.af-custom-dropdown {
    display: none;
    position: fixed;
    min-width: 160px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    max-height: 220px;
    overflow-y: auto;
}
.af-custom-dropdown.show { display: block; }
.af-custom-dropdown .af-dd-item {
    padding: 7px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.78rem;
    color: #1e293b;
    transition: background 0.1s;
}
.af-custom-dropdown .af-dd-item:last-child { border-bottom: none; }
.af-custom-dropdown .af-dd-item:hover { background: #f0f7ff; }
.af-custom-dropdown .af-dd-item.selected { background: #eff6ff; font-weight: 600; color: #2563eb; }
.af-custom-dropdown .af-dd-item.af-dd-reset {
    color: #94a3b8; font-style: italic; font-size: 0.72rem;
}
.af-custom-dropdown .af-dd-empty {
    padding: 8px 12px; text-align: center;
    color: #94a3b8; font-size: 0.75rem;
}
#afStatusDropdown { max-height: none; }

/* ── Reset Button ──────────────────────────────────────────── */
.af-reset-btn {
    width: 32px; height: 32px;
    border: 1px solid #93c5fd; background: #eff6ff; cursor: pointer;
    color: #3b82f6; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; flex-shrink: 0; padding: 0;
}
.af-reset-btn svg { width: 16px; height: 16px; }
.af-reset-btn:hover { color: #ef4444; background: #fef2f2; border-color: #fca5a5; }
.af-reset-btn.has-filter {
    color: #3b82f6; border-color: #93c5fd; background: #eff6ff;
}
.af-reset-btn.has-filter:hover { color: #ef4444; background: #fef2f2; border-color: #fca5a5; }

/* ── Info-Bar ──────────────────────────────────────────────── */
.af-info-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px;
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
    margin: 6px 0;
    animation: af-fade-in 0.25s ease;
}
@keyframes af-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.af-info-left {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.76rem; font-weight: 600; color: #1e40af;
}
.af-info-left svg { width: 14px; height: 14px; color: #3b82f6; flex-shrink: 0; }
.af-info-pill {
    background: #3b82f6; color: #fff;
    font-size: 0.6rem; font-weight: 700;
    padding: 1px 7px; border-radius: 8px; line-height: 1.5;
}
.af-info-meta { font-size: 0.7rem; color: #64748b; font-weight: 400; }
.af-info-close {
    background: none; border: 1px solid #bfdbfe;
    cursor: pointer; color: #3b82f6;
    font-size: 0.7rem; font-weight: 600;
    padding: 3px 8px; border-radius: 4px;
    transition: all 0.12s; white-space: nowrap;
}
.af-info-close:hover { background: #dbeafe; color: #1e40af; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1200px) {
    #afHersteller     { min-width: 80px; width: auto; }
    #afGeraet         { min-width: 65px; width: auto; }
    #afDienstleister  { min-width: 75px; width: auto; }
    #afStatus         { min-width: 80px; width: auto; }
    .af-field--date   { width: 95px; }
}
@media (max-width: 1000px) {
    .af-field--date { display: none; }
    .af-field--search { width: 100px; }
}
@media (max-width: 768px) {
    .af-inline { flex-wrap: wrap; }
    .af-inline.open { max-height: 120px; }
    .af-field--search { width: 100%; }
}
