/* ============================================================================
 * HapoFilterBar — Modern unified filter/search/sort/group component
 * Glassmorphism dark theme with blue accents, smooth animations.
 * ========================================================================= */

.hfb {
    --hfb-bg: rgba(15, 23, 42, 0.65);
    --hfb-bg-solid: #0f172a;
    --hfb-border: rgba(148, 163, 184, 0.18);
    --hfb-border-hover: rgba(56, 189, 248, 0.45);
    --hfb-text: #e2e8f0;
    --hfb-muted: #94a3b8;
    --hfb-accent: #38bdf8;
    --hfb-accent-glow: rgba(56, 189, 248, 0.35);
    --hfb-chip-bg: rgba(30, 41, 59, 0.85);
    --hfb-chip-active-bg: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    --hfb-radius: 14px;
    --hfb-radius-sm: 8px;

    position: relative;
    border-radius: var(--hfb-radius);
    background: var(--hfb-bg);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid var(--hfb-border);
    color: var(--hfb-text);
    padding: 14px 16px 10px 16px;
    box-shadow: 0 8px 32px rgba(2, 6, 23, 0.35);
    margin-bottom: 1rem;
    transition: border-color .25s ease, box-shadow .25s ease;
}
.hfb:focus-within {
    border-color: var(--hfb-border-hover);
    box-shadow: 0 8px 32px rgba(2, 6, 23, 0.5), 0 0 0 3px rgba(56, 189, 248, 0.08);
}

/* ── Top row: search + actions ─────────────────────────────────────────── */
.hfb-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.hfb-search {
    position: relative;
    flex: 1 1 260px;
    min-width: 220px;
    max-width: 460px;
}
.hfb-search input {
    width: 100%;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--hfb-border);
    border-radius: 999px;
    color: var(--hfb-text);
    padding: 8px 36px 8px 38px;
    font-size: 0.92rem;
    transition: all .2s ease;
    outline: none;
}
.hfb-search input:focus {
    border-color: var(--hfb-accent);
    box-shadow: 0 0 0 3px var(--hfb-accent-glow);
}
.hfb-search input::placeholder { color: rgba(148,163,184,0.55); }
.hfb-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hfb-muted);
    pointer-events: none;
    font-size: 0.95rem;
}
.hfb-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    color: var(--hfb-muted);
    width: 26px; height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
}
.hfb-search-clear:hover { background: rgba(148,163,184,0.15); color: var(--hfb-text); }
.hfb-search.has-value .hfb-search-clear { display: inline-flex; }
.hfb-search-shortcut {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hfb-muted);
    font-size: 0.7rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: rgba(148,163,184,0.12);
    border-radius: 4px;
    padding: 1px 6px;
    pointer-events: none;
    opacity: 0.7;
}
.hfb-search.has-value .hfb-search-shortcut { display: none; }

/* ── Action buttons ───────────────────────────────────────────────────── */
.hfb-action {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid var(--hfb-border);
    color: var(--hfb-text);
    border-radius: var(--hfb-radius-sm);
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all .15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
    white-space: nowrap;
}
.hfb-action:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: var(--hfb-border-hover);
    color: #fff;
    transform: translateY(-1px);
}
.hfb-action:active { transform: translateY(0); }
.hfb-action.primary {
    background: var(--hfb-chip-active-bg);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 10px rgba(14, 165, 233, 0.35);
}
.hfb-action i { font-size: 0.95rem; }

/* ── Dropdowns ────────────────────────────────────────────────────────── */
.hfb-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--hfb-bg-solid);
    border: 1px solid var(--hfb-border-hover);
    border-radius: var(--hfb-radius-sm);
    padding: 6px;
    min-width: 220px;
    max-height: 360px;
    overflow-y: auto;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
    z-index: 1050;
    display: none;
}
.hfb-menu.open { display: block; animation: hfb-menu-in .15s ease; }
@keyframes hfb-menu-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.hfb-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.86rem;
    color: var(--hfb-text);
    cursor: pointer;
    transition: background .12s ease;
    user-select: none;
}
.hfb-menu-item:hover { background: rgba(56, 189, 248, 0.12); }
.hfb-menu-item.active {
    background: rgba(56, 189, 248, 0.18);
    color: var(--hfb-accent);
}
.hfb-menu-item .check { width: 14px; opacity: 0; transition: opacity .12s ease; }
.hfb-menu-item.active .check { opacity: 1; }
.hfb-menu-divider { height: 1px; background: var(--hfb-border); margin: 4px 0; }
.hfb-menu-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--hfb-muted);
    padding: 6px 10px 4px;
}

.hfb-action-wrap { position: relative; display: inline-block; }

/* ── Filter chips row ─────────────────────────────────────────────────── */
.hfb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.hfb-chip {
    background: var(--hfb-chip-bg);
    border: 1px solid var(--hfb-border);
    color: var(--hfb-text);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all .18s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.4;
    user-select: none;
}
.hfb-chip:hover {
    border-color: var(--hfb-border-hover);
    transform: translateY(-1px);
}
.hfb-chip.active {
    background: var(--hfb-chip-active-bg);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(14, 165, 233, 0.4);
}
.hfb-chip-count {
    background: rgba(255,255,255,0.16);
    border-radius: 999px;
    padding: 0 7px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}
.hfb-chip:not(.active) .hfb-chip-count { background: rgba(56,189,248,0.18); color: var(--hfb-accent); }

/* ── Active-filter summary bar ────────────────────────────────────────── */
.hfb-summary {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(56, 189, 248, 0.06);
    border: 1px dashed rgba(56, 189, 248, 0.25);
    border-radius: var(--hfb-radius-sm);
    font-size: 0.8rem;
}
.hfb-summary.show { display: flex; animation: hfb-fade .2s ease; }
@keyframes hfb-fade { from { opacity: 0; } to { opacity: 1; } }
.hfb-summary-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px 2px 10px;
    background: rgba(56, 189, 248, 0.18);
    border-radius: 999px;
    color: var(--hfb-accent);
    font-weight: 500;
}
.hfb-summary-tag button {
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity .15s;
}
.hfb-summary-tag button:hover { opacity: 1; }
.hfb-summary-clear {
    margin-left: auto;
    background: transparent;
    border: 0;
    color: var(--hfb-muted);
    cursor: pointer;
    font-size: 0.78rem;
    text-decoration: underline;
    text-decoration-color: rgba(148,163,184,0.4);
    transition: color .15s;
}
.hfb-summary-clear:hover { color: var(--hfb-accent); }

/* ── Result count ─────────────────────────────────────────────────────── */
.hfb-count {
    color: var(--hfb-muted);
    font-size: 0.82rem;
    margin-left: auto;
    white-space: nowrap;
}
.hfb-count strong { color: var(--hfb-accent); font-weight: 700; }

/* ── Loading state ────────────────────────────────────────────────────── */
.hfb-loading {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--hfb-accent), transparent);
    background-size: 200% 100%;
    animation: hfb-loading-bar 1.1s linear infinite;
    border-radius: var(--hfb-radius) var(--hfb-radius) 0 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
}
.hfb.is-loading .hfb-loading { opacity: 1; }
@keyframes hfb-loading-bar {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Match highlight (in row content) ─────────────────────────────────── */
.hfb-hit {
    background: linear-gradient(120deg, rgba(250, 204, 21, 0.35) 0%, rgba(250, 204, 21, 0.55) 100%);
    color: #fef9c3;
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 600;
}

/* ── Pagination footer ────────────────────────────────────────────────── */
.hfb-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--hfb-border);
}
.hfb-pagination-info { color: var(--hfb-muted); font-size: 0.82rem; }
.hfb-pagination-info strong { color: var(--hfb-accent); }
.hfb-pagination-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.hfb-page-btn {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--hfb-border);
    color: var(--hfb-text);
    border-radius: 6px;
    min-width: 32px;
    height: 30px;
    padding: 0 9px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all .15s;
}
.hfb-page-btn:hover:not(:disabled) {
    border-color: var(--hfb-accent);
    color: var(--hfb-accent);
}
.hfb-page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.hfb-page-btn.active {
    background: var(--hfb-chip-active-bg);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(14,165,233,0.4);
}
.hfb-page-ellipsis { color: var(--hfb-muted); padding: 0 4px; }
.hfb-pagination-size {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--hfb-muted);
    font-size: 0.78rem;
}
.hfb-pagination-size select {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid var(--hfb-border);
    color: var(--hfb-text);
    border-radius: 6px;
    padding: 3px 24px 3px 8px;
    font-size: 0.8rem;
    cursor: pointer;
}
.hfb-pagination-size select:focus { outline: none; border-color: var(--hfb-accent); }

/* ── Empty state for connected list ───────────────────────────────────── */
.hfb-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--hfb-muted);
}
.hfb-empty i { font-size: 2.4rem; opacity: 0.4; display: block; margin-bottom: 10px; }
.hfb-empty .hfb-empty-title { font-size: 1.05rem; color: var(--hfb-text); margin-bottom: 4px; }
.hfb-empty .hfb-empty-hint { font-size: 0.85rem; }

/* ── Light-theme override (optional) ──────────────────────────────────── */
.hfb.theme-light {
    --hfb-bg: rgba(255, 255, 255, 0.85);
    --hfb-bg-solid: #ffffff;
    --hfb-text: #0f172a;
    --hfb-muted: #64748b;
    --hfb-border: rgba(15, 23, 42, 0.08);
    --hfb-chip-bg: rgba(241, 245, 249, 0.9);
}

/* ── Compact preset save dialog ───────────────────────────────────────── */
.hfb-preset-input {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--hfb-border);
    color: var(--hfb-text);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
    width: 100%;
    margin: 4px 0;
    outline: none;
}
.hfb-preset-input:focus { border-color: var(--hfb-accent); }

@media (max-width: 600px) {
    .hfb { padding: 12px; }
    .hfb-search { max-width: 100%; flex: 1 1 100%; }
    .hfb-count { margin-left: 0; flex: 1 1 100%; text-align: right; }
    .hfb-search-shortcut { display: none; }
}
