/*
 * VIPelanlar вЂ” Phase D3: Marketplace Discovery
 * ---------------------------------------------------------------
 * Homepage, category navigation, category landing pages, search
 * results, filter UX. Builds on tokens/base/layout/components вЂ”
 * no new component primitives duplicated here.
 *
 * The search-results/category-landing markup itself lives in
 * vipelanlar-core (SearchFrontend::renderPage(), CategoryPicker,
 * LocationPicker вЂ” presentation-only classes shared with admin).
 * These selectors target the classes that markup renders.
 */

/* ============================================================
 * D3.1 вЂ” Homepage search
 * ============================================================ */

.vip-home-intro {
    padding-block: var(--vip-space-lg);
    background: var(--vip-color-primary-soft);
}

.vip-home-intro h1 { max-width: 640px; margin-bottom: var(--vip-space-3xs); }

.vip-home-intro-description {
    max-width: 560px;
    color: var(--vip-color-text-muted);
    font-size: var(--vip-text-md);
    margin-bottom: var(--vip-space-md);
}

.vip-home-search {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1.2fr auto;
    align-items: start;
    gap: var(--vip-space-2xs);
}

.vip-home-search-field { min-width: 0; }

.vip-home-search-field-query input { min-height: 46px; background: var(--vip-color-surface); }

/* CategoryPicker/LocationPicker each render their own internal label(s);
   this just keeps them from collapsing to 0 width in the search-bar grid. */
.vip-home-search-field-category .vip-category-picker,
.vip-home-search-field-location .vip-location-picker {
    min-width: 0;
}

.vip-home-search-field-location .vip-location-picker {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--vip-space-2xs);
}

.vip-home-search-field-location .vip-location-picker label {
    font-size: var(--vip-text-xs);
    font-weight: var(--vip-weight-semibold);
    color: var(--vip-color-text-muted);
}

.vip-home-search-submit { align-self: end; }

@media (max-width: 1023px) {
    .vip-home-search { grid-template-columns: 1fr 1fr; }
    .vip-home-search-field-query { grid-column: 1 / -1; }
    .vip-home-search-submit { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
    .vip-home-intro { padding-block: var(--vip-space-md); }
    .vip-home-search { grid-template-columns: 1fr; }
    .vip-home-search-field-location .vip-location-picker { grid-template-columns: 1fr; }
    .vip-home-search-submit { width: 100%; }
}

/* ============================================================
 * D3.2 вЂ” Root category cards with child preview
 * ============================================================ */

.vip-root-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--vip-space-sm);
}

.vip-root-category-grid .vip-category-card {
    display: flex;
    flex-direction: column;
    padding: var(--vip-space-xs);
    gap: var(--vip-space-2xs);
}

.vip-category-card-link {
    display: flex;
    align-items: center;
    gap: var(--vip-space-xs);
    color: var(--vip-color-text);
    text-decoration: none;
    font-weight: var(--vip-weight-semibold);
}

.vip-category-card-link:hover { text-decoration: none; color: var(--vip-color-primary); }

.vip-category-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--vip-radius-sm);
    background: var(--vip-color-primary-soft);
    color: var(--vip-color-primary);
}

.vip-category-card-icon svg { width: 20px; height: 20px; }

.vip-category-card-name { font-size: var(--vip-text-base); }

.vip-category-card-children {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding-left: calc(40px + var(--vip-space-xs));
    list-style: none;
}

.vip-category-card-children a {
    display: block;
    padding-block: 2px;
    color: var(--vip-color-text-muted);
    font-size: var(--vip-text-sm);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vip-category-card-children a:hover { color: var(--vip-color-primary); text-decoration: underline; }

.vip-category-card-more { font-weight: var(--vip-weight-semibold); color: var(--vip-color-primary) !important; }

@media (max-width: 767px) {
    .vip-root-category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .vip-category-card-children { display: none; } /* keep mobile cards compact/scannable; child links stay one tap away via the category page */
}

/* ============================================================
 * D3.3 / D3.4 вЂ” Search results & category landing page
 * (markup rendered by VipElanlar\Search\SearchFrontend::renderPage())
 * ============================================================ */

.vip-search { padding-block: var(--vip-space-md); }

.vip-search > h1 { margin-bottom: var(--vip-space-2xs); }

.vip-search-form {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--vip-space-md);
    align-items: start;
}

.vip-search-primary {
    grid-column: 1 / -1;
    display: flex;
    gap: var(--vip-space-2xs);
    flex-wrap: wrap;
    align-items: center;
}

.vip-search-primary input[type="search"] { flex: 1; min-width: 200px; min-height: 46px; }

.vip-search-filter-toggle,
.vip-search-filter-close {
    display: none; /* shown only in the mobile drawer state via .vip-search-js */
}

.vip-search-overlay { max-width: none; }

.vip-search-filters {
    grid-column: 1 / 2;
    display: flex;
    flex-direction: column;
    gap: var(--vip-space-sm);
    padding: var(--vip-space-sm);
    background: var(--vip-color-surface);
    border: 1px solid var(--vip-color-border);
    border-radius: var(--vip-radius-md);
}

.vip-search-filter-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vip-search-filter-heading h2 { margin: 0; font-size: var(--vip-text-md); }

.vip-search-filters > label { font-size: var(--vip-text-sm); font-weight: var(--vip-weight-semibold); }

.vip-search-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--vip-space-2xs);
}

.vip-search-range label { font-size: var(--vip-text-xs); color: var(--vip-color-text-muted); }

/* Dynamic per-category filters (D3.5): semantic grouping via fieldset,
   priority ordering already comes from CategoryService (filterable+sortable first);
   low-priority/secondary groups can be collapsed with <details> without any
   change to field names/values -- purely a presentation wrapper. */
.vip-search-dynamic {
    border: 0;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--vip-space-2xs);
}

.vip-search-dynamic legend {
    font-size: var(--vip-text-sm);
    font-weight: var(--vip-weight-semibold);
    padding: 0;
    margin-bottom: 4px;
}

.vip-search-dynamic-more {
    border-top: 1px solid var(--vip-color-border);
    padding-top: var(--vip-space-2xs);
}

.vip-search-dynamic-more summary {
    cursor: pointer;
    font-size: var(--vip-text-sm);
    font-weight: var(--vip-weight-semibold);
    color: var(--vip-color-primary);
    padding-block: 4px;
}

.vip-search-dynamic-more[open] summary { margin-bottom: var(--vip-space-2xs); }

.vip-search-dynamic-more > .vip-search-dynamic:not(:last-child),
.vip-search-dynamic-more > .vip-search-range:not(:last-child) {
    margin-bottom: var(--vip-space-2xs);
}

/* .vip-category-children (category-landing child-category chips) is
   styled once, in components.css -- it's a reusable component rendered
   by SearchFrontend, not a discovery-page-only class. */

.vip-search-filter-actions {
    display: flex;
    gap: var(--vip-space-2xs);
    margin-top: var(--vip-space-2xs);
}

.vip-search-filter-actions button {
    min-height: 44px;
    padding: 0 var(--vip-space-sm);
    border: 1px solid var(--vip-color-primary);
    border-radius: var(--vip-radius-sm);
    background: var(--vip-color-primary);
    color: var(--vip-color-text-on-primary);
    font-weight: var(--vip-weight-semibold);
    cursor: pointer;
}

.vip-search-filter-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--vip-space-sm);
    border: 1px solid var(--vip-color-border-strong);
    border-radius: var(--vip-radius-sm);
    color: var(--vip-color-text);
    text-decoration: none;
}

.vip-search-toolbar {
    grid-column: 2 / 3;
    display: flex;
    align-items: center;
    gap: var(--vip-space-sm);
    flex-wrap: wrap;
}

.vip-search-toolbar p { margin: 0; color: var(--vip-color-text-muted); font-size: var(--vip-text-sm); }
.vip-search-toolbar label { font-size: var(--vip-text-sm); }
.vip-search-toolbar select { min-width: 160px; }

.vip-search-toolbar > button[type="submit"] {
    margin-left: auto;
    min-height: 44px;
    padding: 0 var(--vip-space-md);
    border: 1px solid var(--vip-color-primary);
    border-radius: var(--vip-radius-sm);
    background: var(--vip-color-primary);
    color: var(--vip-color-text-on-primary);
    font-weight: var(--vip-weight-semibold);
    cursor: pointer;
}

.vip-search-grid {
    grid-column: 2 / 3;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--vip-space-md);
    margin-top: var(--vip-space-sm);
}

.vip-search-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--vip-space-xl) var(--vip-space-md);
    background: var(--vip-color-surface);
    border: 1px dashed var(--vip-color-border-strong);
    border-radius: var(--vip-radius-md);
}

.vip-search-empty p { color: var(--vip-color-text-muted); margin-bottom: var(--vip-space-2xs); }
.vip-search-empty a { font-weight: var(--vip-weight-semibold); }

.vip-search-pagination {
    grid-column: 2 / 3;
    display: flex;
    gap: var(--vip-space-3xs);
    flex-wrap: wrap;
    margin-top: var(--vip-space-md);
}

.vip-search-pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    border-radius: var(--vip-radius-sm);
    color: var(--vip-color-text);
    text-decoration: none;
    border: 1px solid var(--vip-color-border);
}

.vip-search-pagination a[aria-current="page"] {
    background: var(--vip-color-primary);
    border-color: var(--vip-color-primary);
    color: var(--vip-color-text-on-primary);
}

.vip-search-pagination a:hover { border-color: var(--vip-color-border-strong); }

/* Validation notice (invalid filter combination, etc.) */
.vip-search-notice {
    grid-column: 1 / -1;
    padding: var(--vip-space-2xs) var(--vip-space-sm);
    background: var(--vip-color-warning-soft);
    color: var(--vip-color-warning);
    border-radius: var(--vip-radius-sm);
    margin-bottom: var(--vip-space-sm);
}

/* ---- Mobile: filter drawer (drives the same class names the
   inline script already toggles -- .vip-search-js / #vip-search-filters
   .is-open / .vip-search-drawer-open on <body>).
   700px matches SearchFrontend's own mobile() JS threshold exactly --
   keep these in sync if either one changes, or the toggle button can
   show at a width where the JS still treats it as desktop (and
   immediately force-closes the drawer). ---- */
@media (max-width: 700px) {
    .vip-search-form { grid-template-columns: 1fr; }
    .vip-search-toolbar, .vip-search-grid, .vip-search-pagination { grid-column: 1 / -1; }

    .vip-search-js .vip-search-filter-toggle,
    .vip-search-js .vip-search-filter-close {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding: 0 var(--vip-space-sm);
        border-radius: var(--vip-radius-sm);
        border: 1px solid var(--vip-color-border-strong);
        background: var(--vip-color-surface);
        cursor: pointer;
    }

    .vip-search-overlay {
        position: fixed;
        inset: 0;
        z-index: var(--vip-z-backdrop);
        background: var(--vip-color-overlay);
        border: 0;
    }

    .vip-search-js .vip-search-filters {
        position: fixed;
        z-index: var(--vip-z-drawer);
        top: 0;
        right: 0;
        bottom: 0;
        width: min(92vw, 380px);
        border-radius: 0;
        overflow-y: auto;
        transform: translateX(105%);
        transition: transform var(--vip-duration-base) var(--vip-ease);
    }

    .vip-search-js .vip-search-filters.is-open { transform: translateX(0); }

    body.vip-search-drawer-open { overflow: hidden; }
}

@media (max-width: 389px) {
    .vip-search-grid { grid-template-columns: 1fr; }
    .vip-search-range { grid-template-columns: 1fr; }
}


.vip-search-dynamic label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid var(--vip-color-border);
    border-radius: var(--vip-radius-sm);
    background: var(--vip-color-surface);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.vip-search-dynamic label:hover {
    border-color: var(--vip-color-primary);
}

.vip-search-dynamic input[type="checkbox"],
.vip-search-dynamic input[type="radio"] {
    width: 17px;
    height: 17px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--vip-color-primary);
}

.vip-search-dynamic label:has(input:checked) {
    border-color: var(--vip-color-primary);
    background: color-mix(in srgb, var(--vip-color-primary) 7%, var(--vip-color-surface));
}

.vip-search-dynamic-more {
    margin-top: 4px;
}

.vip-search-dynamic-more summary {
    padding: 8px 0;
    list-style: none;
}

.vip-search-dynamic-more summary::-webkit-details-marker {
    display: none;
}

.vip-search-dynamic-more summary::before {
    content: "+";
    display: inline-block;
    width: 18px;
    font-weight: 700;
}

.vip-search-dynamic-more[open] summary::before {
    content: "−";
}
