/*
 * Advanced Filters — vanilla default theme.
 *
 * Framework-neutral: no Tailwind/Bootstrap dependency. Every rule is scoped under
 * an `af-` class and kept at low specificity so your own styles win easily.
 * Opt out by simply not loading this file; restyle by overriding the `af-*` classes.
 *
 * Tweak the look via these custom properties on `.af-panel` (or :root).
 */
.af-panel {
    --af-accent: #3b82f6;
    --af-accent-contrast: #ffffff;
    --af-border: #d1d5db;
    --af-bg: #ffffff;
    --af-fg: #1f2937;
    --af-muted: #6b7280;
    --af-chip-bg: #eff6ff;
    --af-chip-fg: #1e40af;
    --af-radius: 6px;

    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    color: var(--af-fg);
    font-size: 0.875rem;
}

[x-cloak] { display: none !important; }

/* ----- chips ----- */
.af-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.af-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.25rem 0.125rem 0.5rem;
    background: var(--af-chip-bg);
    color: var(--af-chip-fg);
    border-radius: 999px;
    line-height: 1.4;
}

.af-chip__text em { font-style: normal; font-weight: 600; }

.af-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.af-chip__remove:hover { background: rgba(0, 0, 0, 0.08); }

.af-clear {
    border: 0;
    background: transparent;
    color: var(--af-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.af-clear:hover { color: var(--af-fg); text-decoration: underline; }

/* ----- builder ----- */
.af-builder { position: relative; display: inline-block; }

.af-builder__trigger {
    border: 1px dashed var(--af-border);
    background: var(--af-bg);
    color: var(--af-accent);
    border-radius: var(--af-radius);
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    font-weight: 500;
}

.af-builder__trigger:hover { border-color: var(--af-accent); }

.af-builder__panel {
    position: absolute;
    z-index: 50;
    top: calc(100% + 0.25rem);
    left: 0;
    min-width: 18rem;
    max-width: 24rem;
    max-height: min(70vh, 27rem);
    overflow-y: auto;
    background: var(--af-bg);
    border: 1px solid var(--af-border);
    border-radius: var(--af-radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    padding: 0.5rem;
}

.af-builder__title {
    margin: 0.25rem 0.25rem 0.5rem;
    font-weight: 600;
    color: var(--af-muted);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
}

/* ----- step 1: field list ----- */
.af-field-list { display: flex; flex-direction: column; }

.af-field-item {
    text-align: left;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0.5rem 0.5rem;
    border-radius: var(--af-radius);
    cursor: pointer;
}

.af-field-item:hover { background: var(--af-chip-bg); }

/* ----- step 2: configure ----- */
.af-configure { display: flex; flex-direction: column; gap: 0.625rem; }

.af-field { display: flex; flex-direction: column; gap: 0.25rem; }

.af-field__label {
    font-size: 0.75rem;
    color: var(--af-muted);
}

.af-input-group { display: flex; flex-direction: column; gap: 0.5rem; }

.af-select,
.af-input,
.af-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--af-border);
    border-radius: var(--af-radius);
    background: var(--af-bg);
    color: var(--af-fg);
    padding: 0.4rem 0.5rem;
    font: inherit;
}

.af-select:focus,
.af-input:focus,
.af-textarea:focus {
    outline: 2px solid var(--af-accent);
    outline-offset: -1px;
    border-color: var(--af-accent);
}

.af-select--multiple { min-height: 6rem; }
.af-textarea { resize: vertical; }

.af-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.af-back {
    border: 0;
    background: transparent;
    color: var(--af-muted);
    cursor: pointer;
    padding: 0.375rem 0.5rem;
}

.af-back:hover { color: var(--af-fg); }

.af-btn {
    border: 1px solid var(--af-border);
    background: var(--af-bg);
    color: var(--af-fg);
    border-radius: var(--af-radius);
    padding: 0.375rem 0.875rem;
    cursor: pointer;
    font-weight: 500;
}

.af-btn--primary {
    background: var(--af-accent);
    border-color: var(--af-accent);
    color: var(--af-accent-contrast);
}

.af-btn:disabled { opacity: 0.5; cursor: not-allowed; }
