/**
 * Archive filters — front-end styles.
 *
 * Mirrors the colour tokens defined by the sibling plugin
 * `couvrelles-event-helpers/assets/css/couvrelles-event.css` so the
 * components feel native on the same archive page.
 *
 * @package CourvellesEvents
 */

/* Local fallbacks — keep the component usable when the sibling kit
   isn't enqueued (e.g. headless preview, theme override). The values
   are mirrored from the sibling :root to stay in sync visually. */
.ce-archive-filters {
    --ceaf-primary:   var(--c-primary, #b7995d);
    --ceaf-accent:    var(--c-accent,  #6b5f3a);
    --ceaf-dark:      var(--c-dark,    #101828);
    --ceaf-text:      var(--c-text,    #364153);
    --ceaf-muted:     var(--c-muted,   #6a7282);
    --ceaf-border:    var(--c-border,  #e5e7eb);
    --ceaf-graybg:    var(--c-graybg,  #f9fafb);
    --ceaf-radius:    10px;
    --ceaf-radius-sm: 6px;
    --ceaf-shadow:    0 1px 2px rgba(16, 24, 40, .06);

    color: var(--ceaf-text);
    margin: 0 0 28px;
    font-family: inherit;
}

/* ─── Dynamic filter sentence (rendered by the shortcode) ──────────── */

/* The wrapper sits inside whatever container the editor placed the
   shortcode in (typically the Elementor hero) — we want the colour
   and typography to inherit from that context (so the sentence reads
   white on a dark hero, dark on a light section, etc.) instead of
   forcing a brand colour. */
.ce-af-dynamic-description {
    margin: 0;
    color: inherit;
    font-size: inherit;
    font-weight: 500;
    letter-spacing: .01em;
}

/* ─── Top bar (search + filter toggle) ─────────────────────────────── */

.ce-af-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ce-af-search {
    position: relative;
    flex: 1 1 320px;
    min-width: 240px;
}

.ce-af-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ceaf-muted);
    pointer-events: none;
    display: flex;
}

.ce-af-search input[type="search"] {
    width: 100%;
    padding: 12px 14px 12px 42px;
    background: #fff;
    border: 1px solid var(--ceaf-border);
    border-radius: var(--ceaf-radius);
    font-size: 15px;
    color: var(--ceaf-text);
    box-shadow: var(--ceaf-shadow);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.ce-af-search input[type="search"]::placeholder {
    color: var(--ceaf-muted);
}

.ce-af-search input[type="search"]:focus {
    outline: none;
    border-color: var(--ceaf-primary);
    box-shadow: 0 0 0 3px rgba(183, 153, 93, .18);
}

/* "Filtrer" — gold, matching the primary "Sauvegarder" button. The
   !important flags are required to override the theme / Elementor button
   styles — notably the stray red focus ring (outline / box-shadow). */
.ce-af-toggle,
.ce-af-toggle:hover,
.ce-af-toggle:focus,
.ce-af-toggle:active {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px 18px !important;
    border-radius: var(--ceaf-radius) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    transform: none !important;
    background: var(--ceaf-primary) !important;
    border: 1px solid var(--ceaf-primary) !important;
    color: #fff !important;
    outline: none !important;
    box-shadow: none !important;
    transition: background-color .15s ease, border-color .15s ease;
}

.ce-af-toggle:hover,
.ce-af-toggle:focus {
    background: var(--ceaf-accent) !important;
    border-color: var(--ceaf-accent) !important;
}

/* "Rechercher" — white, matching the ghost "Réinitialiser" button. */
.ce-af-search-submit,
.ce-af-search-submit:hover,
.ce-af-search-submit:focus,
.ce-af-search-submit:active {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px 18px !important;
    border-radius: var(--ceaf-radius) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    transform: none !important;
    background: #fff !important;
    border: 1px solid var(--ceaf-border) !important;
    color: var(--ceaf-text) !important;
    outline: none !important;
    box-shadow: none !important;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.ce-af-search-submit:hover,
.ce-af-search-submit:focus {
    border-color: var(--ceaf-primary) !important;
    color: var(--ceaf-accent) !important;
}

/* Icons inherit the button's text colour so they always match it
   (white on "Filtrer", dark on "Rechercher"). */
.ce-af-toggle-icon,
.ce-af-search-submit-icon {
    display: inline-flex;
    color: inherit;
}

.ce-af-toggle-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    margin-left: 4px;
    background: var(--ceaf-primary);
    color: #fff;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

/* ─── Active filter chips ──────────────────────────────────────────── */

.ce-af-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.ce-af-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 6px 12px;
    background: rgba(183, 153, 93, .12);
    border: 1px solid rgba(183, 153, 93, .35);
    color: var(--ceaf-accent);
    border-radius: 999px;
    font-size: 13px;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}

.ce-af-chip:hover,
.ce-af-chip:focus {
    background: rgba(183, 153, 93, .22);
    border-color: var(--ceaf-primary);
    color: var(--ceaf-accent);
    outline: none;
}

.ce-af-chip-remove {
    font-size: 16px;
    line-height: 1;
    color: var(--ceaf-accent);
    opacity: .7;
}

.ce-af-chip:hover .ce-af-chip-remove {
    opacity: 1;
}

.ce-af-chip--reset {
    background: transparent;
    border: none;
    color: var(--ceaf-muted);
    text-decoration: underline;
    padding: 6px 4px;
    font-size: 13px;
}

.ce-af-chip--reset:hover {
    background: transparent;
    color: var(--ceaf-accent);
}

/* ─── Drawer (collapsed by default) ────────────────────────────────── */

.ce-af-drawer {
    display: none;
    margin-top: 14px;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--ceaf-border);
    border-radius: var(--ceaf-radius);
    box-shadow: var(--ceaf-shadow);
}

.ce-archive-filters.is-open .ce-af-drawer {
    display: block;
}

.ce-af-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.ce-af-group {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.ce-af-group-title {
    display: block;
    margin: 0 0 12px;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ceaf-muted);
}

.ce-af-group-empty {
    margin: 0;
    color: var(--ceaf-muted);
    font-size: 13px;
    font-style: italic;
}

.ce-af-options {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
    display: grid;
    gap: 4px;
}

.ce-af-options::-webkit-scrollbar {
    width: 8px;
}
.ce-af-options::-webkit-scrollbar-thumb {
    background: var(--ceaf-border);
    border-radius: 4px;
}

.ce-af-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--ceaf-radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--ceaf-text);
    transition: background-color .12s ease;
}

.ce-af-option:hover {
    background: var(--ceaf-graybg);
}

.ce-af-option input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 1.5px solid var(--ceaf-border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    position: relative;
    transition: background-color .12s ease, border-color .12s ease;
}

.ce-af-option input[type="checkbox"]:hover {
    border-color: var(--ceaf-primary);
}

.ce-af-option input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--ceaf-primary);
    outline-offset: 2px;
}

.ce-af-option input[type="checkbox"]:checked {
    background: var(--ceaf-primary);
    border-color: var(--ceaf-primary);
}

.ce-af-option input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.ce-af-option-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ce-af-option-count {
    flex-shrink: 0;
    color: var(--ceaf-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.ce-af-option input[type="checkbox"]:checked ~ .ce-af-option-label {
    color: var(--ceaf-accent);
    font-weight: 500;
}

/* ─── Date pickers ─────────────────────────────────────────────────── */

.ce-af-group--dates {
    grid-column: 1 / -1;
}

.ce-af-date-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ce-af-date-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
}

.ce-af-date-label {
    font-size: 12px;
    color: var(--ceaf-muted);
    font-weight: 500;
}

.ce-af-date-field input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--ceaf-border);
    border-radius: var(--ceaf-radius-sm);
    background: #fff;
    color: var(--ceaf-text);
    font-size: 14px;
    box-shadow: var(--ceaf-shadow);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.ce-af-date-field input[type="date"]:focus {
    outline: none;
    border-color: var(--ceaf-primary);
    box-shadow: 0 0 0 3px rgba(183, 153, 93, .18);
}

/* ─── Action buttons ───────────────────────────────────────────────── */

.ce-af-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--ceaf-border);
}

/* Buttons. The `!important` flags here override Elementor / theme
   "default button" rules that otherwise leak a coloured outline (red
   focus ring on the gold primary, double border on the ghost). */
.ce-af-btn,
.ce-af-btn:hover,
.ce-af-btn:focus,
.ce-af-btn:active {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    padding: 11px 22px !important;
    border-radius: var(--ceaf-radius) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    transform: none !important;
    border: 1px solid transparent !important;
    outline: none !important;
    box-shadow: none !important;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.ce-af-btn-icon {
    display: inline-flex;
    align-items: center;
    color: inherit;
}

.ce-af-btn--ghost,
.ce-af-btn--ghost:visited {
    background: transparent !important;
    border-color: var(--ceaf-border) !important;
    color: var(--ceaf-text) !important;
}

.ce-af-btn--ghost:hover,
.ce-af-btn--ghost:focus {
    background: transparent !important;
    border-color: var(--ceaf-primary) !important;
    color: var(--ceaf-accent) !important;
}

.ce-af-btn--primary,
.ce-af-btn--primary:visited {
    background: var(--ceaf-primary) !important;
    color: #fff !important;
    border-color: var(--ceaf-primary) !important;
}

.ce-af-btn--primary:hover,
.ce-af-btn--primary:focus {
    background: var(--ceaf-accent) !important;
    border-color: var(--ceaf-accent) !important;
    color: #fff !important;
}

.ce-af-btn--primary .ce-af-btn-icon {
    color: #fff !important;
}

/* ─── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .ce-af-bar {
        gap: 10px;
    }

    .ce-af-toggle,
    .ce-af-search-submit {
        flex: 1;
        justify-content: center;
    }

    .ce-af-drawer {
        padding: 18px;
    }

    .ce-af-date-row {
        grid-template-columns: 1fr;
    }

    .ce-af-actions {
        flex-direction: column-reverse;
    }

    .ce-af-btn {
        width: 100%;
    }
}
