/**
 * Meilisearch Frontend Search Styles
 */

/* ========================================
   Header Live Search
   ======================================== */

.header-search {
    position: relative;
}

.header-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #26403c;
    border: 1px solid #d4c53b;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: 8px;
    max-height: 80vh;
    overflow-y: auto;
    display: none;
}

.live-search-results {
    padding: 0;
}

.live-search-section {
    padding: 16px;
    border-bottom: 1px solid #f0f0f1;
}

.live-search-section:last-of-type {
    border-bottom: none;
}

.live-search-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    text-align: left;
}

.live-search-item {
    display: flex;
    gap: 12px;
    padding: 8px;
    border-radius: 4px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    text-align: left;
}

.live-search-item:hover {
    background: #f6f7f7;
}

.live-search-image {
    width: 60px;
    height: 60px;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    flex-shrink: 0;
}

.live-search-content {
    flex: 1;
    min-width: 0;
}

.live-search-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-search-excerpt {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.live-search-footer {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f1;
    text-align: center;
}

.view-all-link {
    display: inline-block;
    font-weight: 600;
    text-decoration: none;
    color: #2271b1;
}

.view-all-link:hover {
    text-decoration: underline;
}

.live-search-empty {
    padding: 24px;
    text-align: center;
    color: #666;
}

/* ========================================
   Search Results Page
   ======================================== */

.search-results__information {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #f0f0f1;
}

.search-results__information-left {
    display: flex;
    gap: 0;
}

.search-results__information-tab {
    padding: 16px 24px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
    font-weight: 500;
    color: #666;
}

.search-results__information-tab:hover {
    color: #2271b1;
    background: #f6f7f7;
}

.search-results__information-tab.active {
    color: #2271b1;
    border-bottom-color: #2271b1;
    background: transparent;
}

.search-results__information-tab span {
    font-weight: 600;
    margin-left: 4px;
}

.search-results__information-right {
    padding: 16px 0;
}

.search-results__pages {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* ========================================
   Search Tab Layout
   ======================================== */

.search-tab {
    display: none;
}

.search-tab.active {
    display: block;
}

.search-tab > .container,
.search-tab {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 40px;
    align-items: start;
}

@media (max-width: 992px) {
    .search-tab > .container,
    .search-tab {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* ========================================
   Filters
   ======================================== */

.filters {
    position: sticky;
    top: 20px;
}

.filters__filter {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}

.filters__filter > li {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    overflow: hidden;
}

.filters__filter--title {
    padding: 12px 16px;
    font-weight: 400;
    cursor: pointer;
    background: #f6f7f7;
    border-bottom: 1px solid #ccd0d4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    line-height: 1.5rem;
}

.filters__filter--title:hover {
    background: #f0f0f1;
}

.filters__filter--title::after {
    content: '⌄';
    font-size: 10px;
    transition: transform 0.3s;
}

.filters__filter > li[aria-expanded="true"] .filters__filter--title::after {
    transform: rotate(180deg);
}

.filters__filter--options {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.filters__filter--options li {
    padding: 0;
}

.filters__filter--options label {
    display: block;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.filters__filter--options label:hover {
    background: #f6f7f7;
}

.filters__filter--options input[type="checkbox"] {
    margin-right: 8px;
}

/* ========================================
   Search Results Grid
   ======================================== */

.search-results__posts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .search-results__posts {
        grid-template-columns: 1fr;
    }
}

.search-results__post {
    display: block;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s, box-shadow 0.3s;
}

.search-results__post:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.search-results__image {
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background-size: cover;
    background-position: center;
    background-color: #f0f0f1;
}

.search-results__image--aspect--16x9 {
    padding-bottom: 56.25%;
}

.search-results__image--aspect--4x3 {
    padding-bottom: 75%;
}

.search-results__image--aspect--1x1 {
    padding-bottom: 100%;
}

.search-results__content {
    padding: 20px;
}

.search-results__date {
    color: #666;
    margin-bottom: 8px;
    font-size: 13px;
}

.search-results__content h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    line-height: 1.4;
    color: #1a1a1a;
}

.search-results__content p {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.search-results__details {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #2271b1;
    font-size: 13px;
}

.search-results__details--chevron {
    width: 16px;
    height: 16px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%232271b1" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>') center/contain no-repeat;
}

/* ========================================
   Pagination
   ======================================== */

.search-results__pagination {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    text-decoration: none;
    color: #2271b1;
    font-weight: 500;
    transition: all 0.2s;
}

.pagination a:hover {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.pagination-current {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.pagination-dots {
    border: none;
    color: #666;
}

.pagination-prev,
.pagination-next {
    font-size: 20px;
}

/* ========================================
   Loading & Empty States
   ======================================== */

.search-loading {
    padding: 60px 20px;
    text-align: center;
    color: #666;
    font-size: 16px;
}

.search-loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 20px auto 0;
    border: 4px solid #f0f0f1;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.search-empty {
    padding: 60px 20px;
    text-align: center;
    color: #666;
    font-size: 16px;
}

/* ========================================
   Filter Accordion Behavior
   ======================================== */

.filters__filter > li {
    cursor: pointer;
}

.filters__filter > li .filters__filter--options {
    display: none;
}

.filters__filter > li.open .filters__filter--options,
.filters__filter > li[aria-expanded="true"] .filters__filter--options {
    display: block;
}