/* ============================================================
   search.css — Styles specific to Search Results.html
   ============================================================ */

/* ----- Top search bar ----- */
.search-bar-wrap {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    padding: 30px 0;
}

.search-bar-wrap .inner {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 2rem;
}

.search-bar {
    background: white;
    padding: 8px;
    border-radius: var(--radius);
    display: flex;
    gap: 8px;
    box-shadow: var(--shadow-lg);
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 18px;
    font-family: inherit;
    font-size: var(--fs-base);
    min-width: 0;
}

.search-country {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border-inline-end: 1px solid var(--border-soft);
    color: var(--primary-dark);
    flex: 0 0 auto;
    max-width: 200px;
}

.search-country i {
    color: var(--primary-light);
    font-size: var(--fs-base);
}

.search-country select {
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: var(--fs-base);
    color: var(--primary-dark);
    font-weight: 600;
    cursor: pointer;
    padding: 12px 4px;
    max-width: 160px;
}

@media (max-width: 700px) {
    .search-bar { flex-wrap: wrap; }
    .search-country {
        order: 2;
        flex-basis: 100%;
        border-inline-end: none;
        border-top: 1px solid var(--border-soft);
        padding: 6px 10px;
    }
    .search-country select { max-width: 100%; flex: 1; }
}

/* ----- Layout ----- */
.results-layout {
    max-width: var(--container);
    margin: 30px auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
}

/* ----- Sidebar filters ----- */
.filters-sidebar {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 90px;
    align-self: flex-start;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

.filter-group {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-soft);
}

.filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-title {
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 10px;
    font-size: var(--fs-base);
}

.filter-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    cursor: pointer;
    font-size: var(--fs-sm);
}

.filter-options input { accent-color: var(--primary); }

/* ----- Activity tree (hierarchical filter) ----- */
.activity-tree {
    /* Viewport-relative height: comfortable on tall screens, graceful on short ones */
    max-height: clamp(320px, 55vh, 640px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scroll-padding-block: 8px;
    padding-inline-end: 10px;
    /* Firefox scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
    /* Scroll-shadow indicators: top/bottom soft fades that appear only when content
       is hidden above/below the viewport. Two "cover" gradients (local) ride with
       the content and mask the shadow gradients (scroll) when at the start/end. */
    background:
        linear-gradient(#fff 30%, rgba(255, 255, 255, 0)),
        linear-gradient(rgba(255, 255, 255, 0), #fff 70%) 0 100%,
        radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)),
        radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) 0 100%;
    background-repeat: no-repeat;
    background-size: 100% 24px, 100% 24px, 100% 8px, 100% 8px;
    background-attachment: local, local, scroll, scroll;
}
/* Webkit (Chrome / Edge / Safari) themed scrollbar */
.activity-tree::-webkit-scrollbar { width: 8px; }
.activity-tree::-webkit-scrollbar-track {
    background: transparent;
    margin-block: 6px;
}
.activity-tree::-webkit-scrollbar-thumb {
    background-color: var(--border-soft);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background-color 0.2s ease;
}
.activity-tree:hover::-webkit-scrollbar-thumb { background-color: var(--primary); }
.activity-tree::-webkit-scrollbar-thumb:hover,
.activity-tree::-webkit-scrollbar-thumb:active {
    background-color: var(--primary-dark);
}
.activity-tree .act-node[data-depth="1"] { padding-inline-start: 18px; }
.activity-tree .act-node[data-depth="2"] { padding-inline-start: 36px; }
.activity-tree .act-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: var(--fs-sm);
    cursor: pointer;
}
.activity-tree .act-name { flex: 1; }
.activity-tree .act-toggle {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    font-size: var(--fs-xs);
    transition: transform 0.18s ease;
}
.activity-tree .act-toggle.act-toggle-spacer { cursor: default; }
.activity-tree .act-toggle.open { transform: rotate(90deg); color: var(--primary); }
[dir="ltr"] .activity-tree .act-toggle.open { transform: rotate(90deg); }
.activity-tree .act-children {
    border-inline-start: 1px dashed var(--border-soft);
    margin-inline-start: 8px;
}

/* ----- Results header ----- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.results-count         { color: var(--text-muted); font-size: var(--fs-base); }
.results-count strong  { color: var(--primary-dark); }

/* ----- Result cards ----- */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: grid;
    grid-template-columns: 130px 1fr auto;
    gap: 18px;
    align-items: center;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.result-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    color: inherit;
}

.result-card .img {
    width: 130px;
    height: 130px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-soft);
}

.result-card .info h3 {
    color: var(--primary-dark);
    font-size: var(--fs-md);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.result-card .info p {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-card .meta-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.result-card .meta-row i {
    color: var(--primary-light);
    margin-inline-end: 4px;
}

/* ----- Responsive ----- */
@media (max-width: 900px) {
    .results-layout    { grid-template-columns: 1fr; }
    .filters-sidebar   { position: static !important; }
}

@media (max-width: 700px) {
    .result-card                  { grid-template-columns: 90px 1fr; }
    .result-card .img             { width: 90px; height: 90px; }
    .result-card .arrow-cell      { display: none; }
}

/* ============================================================
   === Polish Layer ===
   ============================================================ */

/* Search bar focus */
.search-bar {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.search-bar:focus-within {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(230, 126, 34, 0.2);
    transform: translateY(-1px);
}

/* Filters sidebar scrollbar */
.filters-sidebar::-webkit-scrollbar {
    width: 6px;
}
.filters-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.filters-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.filters-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}
.filters-sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Filter option hover polish */
.filter-options label {
    border-radius: 6px;
    padding: 6px 8px;
    margin: 0 -8px;
    transition: background 0.2s ease, color 0.2s ease;
}
.filter-options label:hover {
    background: var(--bg-soft);
    color: var(--primary);
}
.filter-options label:has(input:checked) {
    color: var(--primary);
    font-weight: 600;
}

/* Filter group title with icon */
.filter-title {
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-title::before {
    content: '';
    width: 4px;
    height: 14px;
    background: linear-gradient(180deg, var(--primary), var(--primary-light));
    border-radius: 2px;
}

/* Active filters chip bar */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    flex: 1;
    min-width: 0;
}
.active-filters[hidden] { display: none; }
.active-filters-label {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    font-weight: 600;
    margin-inline-end: 4px;
}
.active-filters .clear-all {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}
.active-filters .clear-all:hover { background: rgba(231, 76, 60, 0.08); }

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: white;
    border: 1px solid var(--border);
    color: var(--primary-dark);
    padding: 5px 10px 5px 12px;
    border-radius: 999px;
    font-size: var(--fs-sm);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(26, 82, 118, 0.06);
    transition: all 0.2s ease;
}

.filter-chip:hover {
    border-color: var(--primary-light);
    box-shadow: 0 4px 12px rgba(26, 82, 118, 0.12);
}

.filter-chip .chip-label {
    color: var(--text-muted);
    font-weight: 500;
    margin-inline-end: 2px;
}

.filter-chip button {
    background: var(--bg-soft);
    border: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    padding: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.filter-chip button:hover {
    background: var(--danger);
    color: white;
}

/* Result card enhanced hover */
.result-card {
    border: 1px solid transparent;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.result-card:hover {
    border-color: rgba(26, 82, 118, 0.1);
    box-shadow: 0 14px 35px rgba(26, 82, 118, 0.15);
}

.result-card .img-wrap {
    position: relative;
    width: 130px;
    height: 130px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-soft);
    flex-shrink: 0;
}
.result-card .img-wrap img,
.result-card .img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.result-card:hover .img-wrap img,
.result-card:hover .img { transform: scale(1.08); }

.result-card .verified-ribbon {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    background: linear-gradient(135deg, var(--success), #2ecc71);
    color: white;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: var(--fs-xs);
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.result-card .arrow-cell {
    color: var(--primary);
    font-size: var(--fs-md);
    transition: transform 0.3s ease, color 0.3s ease;
}
.result-card:hover .arrow-cell {
    color: var(--accent);
    transform: translateX(-4px);
}
body[dir="ltr"] .result-card:hover .arrow-cell { transform: translateX(4px); }

/* Card entrance animation (staggered via JS if desired) */
.result-card {
    animation: cardFadeIn 0.4s ease-out both;
}
@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Skeleton card for loading state */
.skeleton-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 18px;
    align-items: center;
}
.skeleton-card .sk-img {
    width: 130px;
    height: 130px;
    border-radius: var(--radius-sm);
}
.skeleton-card .sk-lines {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
@media (max-width: 700px) {
    .skeleton-card          { grid-template-columns: 90px 1fr; }
    .skeleton-card .sk-img  { width: 90px; height: 90px; }
}

/* Results count polish */
.results-count {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-soft);
    border-radius: 999px;
    font-size: var(--fs-sm);
}

/* View toggle (grid/list) if used */
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.view-toggle button {
    background: white;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}
.view-toggle button.active {
    background: var(--primary);
    color: white;
}
.view-toggle button:hover:not(.active) {
    background: var(--bg-soft);
    color: var(--primary);
}

.result-rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--text-dark);
    background: #fffbea;
    border: 1px solid #f1c40f44;
    border-radius: 999px;
    padding: 2px 8px;
}

/* ----- Verified explanation tooltip (next to filter title) ----- */
.filter-title { display: flex; align-items: center; gap: 6px; }
.tooltip-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
}
.tooltip-icon i { color: var(--text-muted); font-size: var(--fs-sm); }
.tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 150%;
    inset-inline-start: 0;
    background: var(--primary-dark);
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: var(--fs-sm);
    font-weight: 400;
    line-height: 1.6;
    width: max-content;
    max-width: 240px;
    white-space: normal;
    text-align: start;
    box-shadow: 0 6px 20px rgba(0,0,0,0.22);
    z-index: 200;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}
.tooltip-icon:hover .tooltip-text,
.tooltip-icon:focus-within .tooltip-text,
.tooltip-icon.is-open .tooltip-text { visibility: visible; opacity: 1; }

/* ============================================================
   === Collapsible filter groups (per-group accordion) ===
   ============================================================ */
/* Turn each filter title into a full-width toggle button while keeping the
   existing flex layout + colored ::before bar from the base .filter-title. */
.filter-title[data-acc-toggle] {
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 10px;
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: 800;
    color: var(--primary-dark);
    cursor: pointer;
    text-align: start;
    -webkit-user-select: none;
    user-select: none;
}
.acc-chevron {
    margin-inline-start: auto;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    transition: transform 0.3s ease;
}
.filter-title[data-acc-toggle]:hover .acc-chevron { color: var(--primary); }
.filter-group.is-collapsed .acc-chevron { transform: rotate(-90deg); }

/* Smooth height animation via the 0fr↔1fr grid-rows trick (animates to "auto"). */
.filter-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s ease;
}
.filter-group.is-collapsed .filter-body { grid-template-rows: 0fr; }
.filter-body-inner { overflow: hidden; min-height: 0; }
.filter-group.is-collapsed > .filter-title { margin-bottom: 0; }
