/* ==========================================================================
   IDE-030 — Odoo's search panel on the lists (Components/Shared/Grid: GridSearchPanel, GridSearchBox,
   GridSearchFacets): the search box with its facets, the "Filters ▾" button, and the drop-down's three
   columns — Filters · Group by · Favourites. Theme tokens only (light and dark come with them).
   ========================================================================== */

/* ─── The search box with its facets (the control row's search) ───────────── */

.dxg-searchbox {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px 4px;
    min-height: 28px;
    max-width: min(560px, 46vw);
    margin-right: 4px;
    padding: 2px 8px 2px 8px;
    box-sizing: border-box;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--dxg-surface, var(--panel));
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.dxg-searchbox.has-facets { border-radius: 14px; }
.dxg-searchbox:hover { border-color: var(--muted-2); }
.dxg-searchbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.dxg-searchbox__glyph { display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.dxg-searchbox__glyph svg { width: 14px; height: 14px; }
.dxg-searchbox input {
    flex: 1 1 90px;
    min-width: 90px;
    width: 120px;
    height: 22px;
    padding: 0 2px;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 0.84rem;
}
.dxg-searchbox input:focus { outline: none; width: 180px; }
.dxg-searchbox input::placeholder { color: var(--muted-2); }
.dxg-searchbox input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* A facet: what is on, removable — the filters in the brand's tint, the grouping in the ink's. */
.grid-facet {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 260px;
    height: 22px;
    padding: 0 2px 0 7px;
    border-radius: 7px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.grid-facet--group { background: var(--panel-hover); color: var(--ink-soft); }
.grid-facet__icon { display: inline-grid; place-items: center; flex: none; }
.grid-facet__icon svg { width: 12px; height: 12px; }
.grid-facet__text { overflow: hidden; text-overflow: ellipsis; }
.grid-facet__x {
    display: inline-grid;
    place-items: center;
    width: 18px; height: 18px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.75;
}
.grid-facet__x svg { width: 11px; height: 11px; }
.grid-facet__x:hover { opacity: 1; background: var(--panel); }
.grid-facet__x:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }

/* Facets beside a page's own search (Bank Matching's control row). */
.grid-facets { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; }

/* ─── The Filters ▾ button ───────────────────────────────────────────────── */

.row-menu-button.grid-search__button { height: 28px; padding: 0 9px; border-radius: 999px; font-size: 0.8rem; gap: 6px; }
.row-menu-button.grid-search__button.is-active { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }

/* ─── The drop-down: three columns ───────────────────────────────────────── */

.row-menu-panel.grid-search-panel {
    max-width: min(780px, calc(100vw - 16px));
    max-height: min(560px, calc(100dvh - 16px));
    padding: 10px 6px;
    white-space: normal;
}
.grid-search {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) minmax(220px, 1.2fr);
    gap: 0;
}
.grid-search.grid-search--no-groups, .grid-search.grid-search--no-favourites { grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr); }
.grid-search.grid-search--no-groups.grid-search--no-favourites { grid-template-columns: minmax(200px, 1fr); }
.grid-search__col {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    padding: 0 8px;
}
.grid-search__col + .grid-search__col { border-left: 1px solid var(--line); }
.grid-search__head {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 6px;
    padding: 0 6px;
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 0.86rem;
    font-weight: 700;
}
.grid-search__glyph { display: inline-grid; place-items: center; color: var(--brand); }
.grid-search__glyph svg { width: 15px; height: 15px; }
.grid-search__glyph--star { color: var(--accent); font-size: 0.95rem; line-height: 1; }

/* A group of toggles; a rule between groups (Odoo's separators). */
.grid-search__group { display: flex; flex-direction: column; gap: 1px; }
.grid-search__group + .grid-search__group { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); }

.row-menu-panel .grid-search__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 8px;
    color: var(--ink);
    font-size: 0.85rem;
    cursor: pointer;
}
.row-menu-panel .grid-search__item:hover { background: var(--panel-hover); }
.row-menu-panel .grid-search__item input { margin: 0; flex: none; accent-color: var(--brand); }
.row-menu-panel .grid-search__item.is-on > span:first-of-type { color: var(--brand-strong); font-weight: 600; }
.grid-search__level {
    display: inline-grid;
    place-items: center;
    min-width: 16px; height: 16px;
    margin-left: auto;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 0.68rem;
    font-weight: 700;
}
.grid-search__empty { margin: 2px 6px 6px; color: var(--muted); font-size: 0.8rem; white-space: normal; }
.grid-search__problem { color: var(--danger); }

.row-menu-panel button.grid-search__add {
    margin-top: 6px;
    padding: 5px 6px;
    color: var(--brand);
    font-size: 0.82rem;
    font-weight: 600;
}

.grid-search__custom { display: flex; flex-direction: column; gap: 3px; margin: 8px 6px 0; color: var(--muted); font-size: 0.78rem; }
.grid-search__custom select {
    height: 28px;
    padding: 0 6px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--dxg-surface, var(--panel));
    color: var(--ink);
    font: inherit;
    font-size: 0.82rem;
}
.grid-search__custom select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--ring); }

/* ─── Favourites ─────────────────────────────────────────────────────────── */

.grid-search__fav { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.grid-search__fav:hover { background: var(--panel-hover); }
.row-menu-panel .grid-search__fav > .grid-search__fav-apply { flex: 1 1 auto; min-width: 0; gap: 6px; padding: 5px 6px; font-size: 0.85rem; }
.grid-search__fav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-search__fav.is-current .grid-search__fav-name { color: var(--brand-strong); font-weight: 700; }
.grid-search__fav-note { flex: none; color: var(--muted); font-size: 0.72rem; font-weight: 500; }
.row-menu-panel button.grid-search__star, .grid-search__star {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 24px; height: 24px;
    padding: 0;
    color: var(--muted-2);
    font-size: 0.95rem;
    line-height: 1;
}
.row-menu-panel button.grid-search__star.is-on, .grid-search__star.is-on { color: var(--accent); }
.grid-search__star.is-readonly { cursor: default; }
.row-menu-panel .grid-search__fav-delete { flex-direction: row; flex: none; }
.row-menu-panel button.grid-search__fav-x { width: 24px; height: 24px; padding: 0; justify-content: center; color: var(--muted); }
.row-menu-panel button.grid-search__fav-x svg { width: 12px; height: 12px; }
.row-menu-panel button.grid-search__fav-x:hover { color: var(--danger); background: var(--danger-soft); }
.row-menu-panel .grid-search__fav-delete > .row-menu-confirm-go { width: auto; padding: 3px 8px; font-size: 0.78rem; border-radius: 7px; }
.grid-search__fav.is-theirs .grid-search__fav-name { font-style: italic; }

.grid-search__save {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}
.grid-search__subhead { padding: 0 6px 4px; color: var(--ink); font-size: 0.82rem; font-weight: 700; }
.grid-search__name {
    height: 28px;
    margin: 0 6px 4px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--dxg-surface, var(--panel));
    color: var(--ink);
    font: inherit;
    font-size: 0.84rem;
}
.grid-search__name:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--ring); }
.row-menu-panel button.grid-search__save-button {
    justify-content: center;
    width: auto;
    margin: 6px 6px 0;
    padding: 5px 12px;
    background: var(--solid);
    color: var(--solid-ink);
    font-weight: 600;
}
.row-menu-panel button.grid-search__save-button:hover:not(:disabled) { background: var(--solid-hover); color: var(--solid-ink); }
.row-menu-panel button.grid-search__save-button:disabled { background: var(--panel-hover); color: var(--muted-2); }

/* A narrow window: the columns one under the other. */
@media (max-width: 720px) {
    .grid-search, .grid-search.grid-search--no-groups, .grid-search.grid-search--no-favourites { grid-template-columns: 1fr; }
    .grid-search__col + .grid-search__col { border-left: 0; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
    .dxg-searchbox { max-width: 100%; }
}

@media print {
    .grid-search__button, .grid-facet__x { display: none !important; }
}
