/* 
 * PadniSi Design System - Search
 * ------------------------------
 * Search box, query pills, and suggestions.
 */

/* Inline Search Box */
.search-box {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    z-index: 1001;
    border: 1px solid var(--gray-light);
    width: 100%;
}

.search-box:focus-within {
    box-shadow: var(--shadow);
    border-color: var(--gray-light);
}

.search-box input {
    flex: 1;
    min-width: 150px;
    width: auto;
    border: none;
    padding: 12px 25px;
    font-size: 15px;
    outline: none;
    font-family: inherit;
    background: transparent;
}

.search-box.header-search {
    flex: 1;
    height: 44px;
    margin: 0 40px;
    flex-wrap: nowrap;
    max-width: none;
}

.search-box.header-search input {
    padding: 0 20px;
    height: 100%;
}

.search-focus-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 16, 35, 0.24);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1090;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.search-focus-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .search-focus-backdrop {
        transition: none;
    }
}

.search-scope-selector {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    align-self: center;
    height: 34px;
    min-width: 0;
    max-width: 178px;
    margin-left: 6px;
    border-radius: 16px;
    background: #f4f6fb;
    box-shadow: inset 0 0 0 1px rgba(31, 42, 68, 0.06);
    color: #26324d;
}

.search-scope-selector:focus-within {
    background: #eef2f8;
    box-shadow: inset 0 0 0 1px rgba(80, 104, 191, 0.18);
}

.search-scope-trigger {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    height: 100%;
    min-width: 0;
    padding: 0 11px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.search-scope-flag {
    display: inline-flex;
    position: relative;
    flex: 0 0 18px;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(31, 42, 68, 0.16);
    color: #44516f;
    font-size: 7px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    line-height: 1;
}

.search-scope-flag::after {
    content: attr(data-fallback);
}

.search-scope-flag-bg {
    background: linear-gradient(to bottom, #fff 0 33.333%, #00966e 33.333% 66.666%, #d62612 66.666% 100%);
}

.search-scope-flag-en {
    background:
        linear-gradient(to bottom, transparent 0 41%, #cf142b 41% 59%, transparent 59% 100%),
        linear-gradient(to right, transparent 0 41%, #cf142b 41% 59%, transparent 59% 100%),
        #fff;
}

.search-scope-flag-bg::after,
.search-scope-flag-en::after {
    content: "";
}

.search-scope-label {
    min-width: 0;
    max-width: 96px;
    overflow: hidden;
    color: #26324d;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-scope-chevron {
    flex: 0 0 auto;
    margin-left: auto;
    color: #98a2bd;
    font-size: 14px;
    line-height: 1;
    transition: transform 0.16s ease;
}

.search-scope-selector.is-open .search-scope-chevron {
    transform: rotate(180deg);
}

.search-scope-native {
    display: none;
}

.search-scope-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: 220px;
    padding: 6px;
    border: 1px solid #dfe6f3;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
    z-index: 2100;
}

.search-scope-menu[hidden] {
    display: none;
}

.search-scope-option {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-width: 132px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #26324d;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.search-scope-option:hover,
.search-scope-option:focus-visible {
    background: #f3f6fd;
    outline: none;
}

.search-scope-option[aria-selected="true"] {
    background: #eaf1ff;
    color: #1d4ed8;
    font-weight: 700;
}

.search-scope-option-label {
    white-space: nowrap;
}

.search-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    background: transparent;
    z-index: 20;
    order: 2;
    padding-right: 6px;
}

.search-icon-static {
    background: transparent;
    color: var(--gray);
    border: none;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: none;
}

/* Search Pills (Active Filters) */
.search-query-pill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    overflow: hidden;
    background: var(--light);
    margin: 8px;
    padding: 10px 20px;
    border-radius: 6px;
    border: 2px solid #1e3a8a;
    color: #1e3a8a;
    font-weight: 700;
    font-size: 15px;
    animation: fadeInPill 0.3s ease-out;
}

.search-box.header-search .search-query-pill {
    margin: 4px;
    padding: 6px 15px;
    font-size: 14px;
}

@keyframes fadeInPill {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.search-query-pill span {
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.search-query-pill span::before {
    content: '\f002';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    margin-right: 10px;
    color: #1e3a8a;
    font-size: 14px;
}

.search-query-pill i.clear-search {
    flex: 0 0 auto;
    cursor: pointer;
    color: var(--gray);
    transition: all 0.2s;
    font-size: 18px;
    margin-left: 15px;
}

.search-query-pill i.clear-search:hover {
    color: var(--danger);
    transform: scale(1.1);
}

/* Suggestion Chips */
.suggestion-chip {
    padding: 8px 16px;
    background: var(--light);
    color: var(--primary-dark);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--gray-light);
    display: inline-flex;
    margin-right: 5px;
    margin-bottom: 5px;
}

.suggestion-chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.search-discovery-section {
    margin-bottom: 14px;
}

.search-discovery-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.search-discovery-chip {
    border: 1px solid var(--gray-light);
    background: var(--light);
    color: var(--primary);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.search-discovery-chip:hover,
.search-discovery-chip:focus-visible {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    outline: none;
}

/* Suggestions Overlay Styles */
.search-suggestions-overlay {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    margin-top: 5px;
    padding: 20px;
    z-index: 2000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.suggestions-section.category-suggestions {
    background-color: #f8faff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    margin-bottom: 15px;
}

.suggestions-section.category-suggestions .section-header {
    background: #f1f5f9;
    padding: 8px 12px;
    margin: 0;
    border-bottom: 1px solid #e2e8f0;
}

.suggestions-section.category-suggestions h6 {
    margin: 0;
    color: var(--secondary-dark);
}

.category-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.category-item:last-child {
    border-bottom: none;
}

.category-item:hover {
    background-color: #eef2ff;
}

.suggestion-content {
    display: flex;
    flex-direction: column;
}

.suggestion-text {
    font-size: 14px;
    color: var(--dark);
}

.highlight-category {
    font-weight: 700;
    color: var(--primary-color);
}

.suggestion-count {
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px;
}

.category-item i.fa-search-plus {
    color: #cbd5e1;
    font-size: 14px;
}

.category-item:hover i.fa-search-plus {
    color: var(--primary);
}

.suggestions-section h6 {
    color: var(--gray);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggestions-section h6 i {
    color: rgb(52, 152, 219);
}

.suggestions-separator {
    height: 1px;
    background: var(--gray-light);
    margin: 15px 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* Vehicle-type tiles in the search overlay (structured attributes, Phase 5) */
.vehicle-type-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 2px;
}

.vehicle-type-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    border: 1px solid var(--gray-light);
    background: var(--light);
    border-radius: 8px;
    padding: 12px 6px 10px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    min-height: 84px;
}

.vehicle-type-tile i {
    font-size: 22px;
    color: var(--primary);
}

.vehicle-type-tile .tile-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.vehicle-type-tile .tile-count {
    font-size: 11px;
    color: #64748b;
    min-height: 13px;
}

.vehicle-type-tile:hover,
.vehicle-type-tile:focus-visible {
    border-color: var(--primary);
    background: #eff6ff;
}

.vehicle-type-tile.selected {
    border-color: var(--primary);
    background: var(--primary);
}

.vehicle-type-tile.selected i,
.vehicle-type-tile.selected .tile-label,
.vehicle-type-tile.selected .tile-count {
    color: #fff;
}

.vehicle-type-tile.tile-empty {
    opacity: 0.55;
}

.btn-clear-recent {
    background: none;
    border: none;
    color: rgb(52, 152, 219);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.btn-clear-recent:hover {
    background: var(--light);
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.recent-item {
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--dark);
    font-size: 15px;
}

.recent-item:hover {
    background: var(--light);
}

.recent-item i {
    color: var(--gray);
    font-size: 14px;
}

@media (max-width: 576px) {
    .search-scope-selector {
        height: 32px;
        max-width: 132px;
        margin-left: 5px;
        border-radius: 15px;
    }

    .search-scope-trigger {
        gap: 6px;
        padding: 0 9px;
    }

    .search-scope-flag {
        flex-basis: 16px;
        width: 16px;
        height: 16px;
        font-size: 6px;
    }

    .search-scope-label {
        max-width: 68px;
        font-size: 12px;
    }

    .search-scope-chevron {
        font-size: 12px;
    }

    .search-scope-menu {
        min-width: 148px;
    }
}
