/**
 * Thanos Theme - Advanced Search Component
 *
 * Search with filters and instant results
 * @package Thanos_Theme
 */

/* =========================================
   Search Container
   ========================================= */
.thanos-advanced-search {
    position: relative;
}

/* =========================================
   Search Input
   ========================================= */
.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 14px 50px 14px 50px;
    background: var(--thanos-surface);
    border: 2px solid var(--thanos-border);
    border-radius: 12px;
    color: var(--thanos-text);
    font-size: 1rem;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--thanos-primary);
    background: var(--thanos-bg-dark);
}

.search-input::placeholder {
    color: var(--thanos-text-muted);
}

.search-icon {
    position: absolute;
    left: 16px;
    width: 22px;
    height: 22px;
    color: var(--thanos-text-muted);
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 14px;
    width: 28px;
    height: 28px;
    background: var(--thanos-border);
    border: none;
    border-radius: 50%;
    color: var(--thanos-text);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.search-clear:hover {
    background: var(--thanos-primary);
}

.search-clear svg {
    width: 14px;
    height: 14px;
}

.search-input:not(:placeholder-shown) + .search-icon + .search-clear {
    display: flex;
}

/* =========================================
   Filter Bar
   ========================================= */
.search-filters {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.filter-group {
    position: relative;
}

.filter-select {
    padding: 10px 40px 10px 14px;
    background: var(--thanos-surface);
    border: 1px solid var(--thanos-border);
    border-radius: 8px;
    color: var(--thanos-text);
    font-size: 0.9rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    min-width: 130px;
    transition: all 0.2s;
}

.filter-select:hover,
.filter-select:focus {
    border-color: var(--thanos-primary);
    outline: none;
}

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

.filter-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--thanos-surface);
    border: 1px solid var(--thanos-border);
    border-radius: 20px;
    color: var(--thanos-text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip:hover,
.filter-chip.active {
    background: var(--thanos-primary);
    border-color: var(--thanos-primary);
    color: #fff;
}

.filter-chip svg {
    width: 14px;
    height: 14px;
}

/* =========================================
   Search Results Dropdown
   Note: Using .thanos-instant-results to avoid conflict
   with WordPress body.search-results class
   ========================================= */
.thanos-instant-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--thanos-surface);
    border: 1px solid var(--thanos-border);
    border-radius: 12px;
    margin-top: 8px;
    max-height: 500px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.thanos-instant-results.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.thanos-instant-results .search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--thanos-border);
}

.search-results-count {
    font-size: 0.85rem;
    color: var(--thanos-text-muted);
}

.search-results-view-all {
    color: var(--thanos-primary);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.search-results-view-all svg {
    width: 14px;
    height: 14px;
}

/* Result Items */
.search-result-item {
    display: flex;
    gap: 14px;
    padding: 12px 16px;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--thanos-surface-hover);
}

.search-result-item:not(:last-child) {
    border-bottom: 1px solid var(--thanos-border);
}

.result-thumb {
    width: 100px;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-thumb .duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.65rem;
}

.result-info {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-weight: 500;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--thanos-text-muted);
}

.result-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--thanos-primary);
    color: #fff;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Loading State */
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 10px;
    color: var(--thanos-text-muted);
}

.search-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--thanos-border);
    border-top-color: var(--thanos-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* No Results */
.search-no-results {
    text-align: center;
    color: var(--thanos-text-muted);
}

.search-no-results p {
    margin-bottom: 15px;
}

/* =========================================
   Search Page Layout
   ========================================= */
.search-page-header {
    margin-bottom: 30px;
}

.search-page-title {
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.search-page-title .highlight {
    color: var(--thanos-primary);
}

.search-active-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.active-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--thanos-primary);
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
}

.active-filter .remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    display: flex;
}

.active-filter .remove svg {
    width: 14px;
    height: 14px;
}

.clear-all-filters {
    color: var(--thanos-text-muted);
    font-size: 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.clear-all-filters:hover {
    color: var(--thanos-text);
}

/* Sort Options */
.search-sort {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.sort-label {
    color: var(--thanos-text-muted);
    font-size: 0.9rem;
}

.sort-options {
    display: flex;
    gap: 8px;
}

.sort-btn {
    padding: 8px 14px;
    background: var(--thanos-surface);
    border: 1px solid var(--thanos-border);
    border-radius: 6px;
    color: var(--thanos-text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sort-btn:hover {
    border-color: var(--thanos-primary);
}

.sort-btn.active {
    background: var(--thanos-primary);
    border-color: var(--thanos-primary);
    color: #fff;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 768px) {
    .search-input {
        padding: 12px 45px 12px 45px;
        font-size: 0.95rem;
    }

    .search-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }

    .filter-select {
        min-width: 110px;
        white-space: nowrap;
    }

    .search-result-item {
        padding: 10px 12px;
    }

    .result-thumb {
        width: 80px;
    }

    .search-sort {
        flex-direction: column;
        align-items: flex-start;
    }

    .sort-options {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .sort-btn {
        white-space: nowrap;
    }
}

/* =========================================
   Light Mode Styles
   ========================================= */
[data-theme="light"] .thanos-instant-results,
body.light-mode .thanos-instant-results {
    background: #ffffff;
    border-color: #e5e7eb;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .thanos-instant-results .search-results-header,
body.light-mode .thanos-instant-results .search-results-header {
    border-bottom-color: #e5e7eb;
}

[data-theme="light"] .search-input,
body.light-mode .search-input {
    background: #f9fafb;
    border-color: #e5e7eb;
    color: #111827;
}

[data-theme="light"] .search-input:focus,
body.light-mode .search-input:focus {
    background: #ffffff;
    border-color: var(--thanos-primary);
}

[data-theme="light"] .search-input::placeholder,
body.light-mode .search-input::placeholder {
    color: #9ca3af;
}

[data-theme="light"] .filter-select,
body.light-mode .filter-select {
    background: #f9fafb;
    border-color: #e5e7eb;
    color: #111827;
}

[data-theme="light"] .filter-chip,
body.light-mode .filter-chip {
    background: #f9fafb;
    border-color: #e5e7eb;
    color: #374151;
}

[data-theme="light"] .search-result-item:hover,
body.light-mode .search-result-item:hover {
    background: #f3f4f6;
}

[data-theme="light"] .search-result-item:not(:last-child),
body.light-mode .search-result-item:not(:last-child) {
    border-bottom-color: #e5e7eb;
}

[data-theme="light"] .result-title,
body.light-mode .result-title {
    color: #111827;
}

[data-theme="light"] .result-meta,
body.light-mode .result-meta {
    color: #6b7280;
}

[data-theme="light"] .search-results-count,
body.light-mode .search-results-count {
    color: #6b7280;
}

[data-theme="light"] .search-loading,
body.light-mode .search-loading {
    color: #6b7280;
}

[data-theme="light"] .search-no-results,
body.light-mode .search-no-results {
    color: #6b7280;
}

[data-theme="light"] .sort-btn,
body.light-mode .sort-btn {
    background: #f9fafb;
    border-color: #e5e7eb;
    color: #374151;
}

[data-theme="light"] .sort-btn:hover,
body.light-mode .sort-btn:hover {
    border-color: var(--thanos-primary);
}

[data-theme="light"] .search-clear,
body.light-mode .search-clear {
    background: #e5e7eb;
    color: #374151;
}
