/**
 * OEM Search Styles (Modernized & User-Focused)
 * Version: 3.0.0
 * @package OEM_System
 */

/* ============================================
   SHARED VARIABLES (yapı aynı, renkler :root / paletten)
   ============================================ */
:root {
    --oem-search-bg: var(--oem-header-bg, #15192B);
    --oem-search-border: var(--oem-gold-border, rgba(197, 160, 89, 0.25));
    --oem-search-text: var(--oem-text-bright, #e0e0e0);
    --oem-search-placeholder: var(--oem-text-muted, #606777);
    --oem-search-shadow: 0 15px 45px rgba(0, 0, 0, 0.4);
    --oem-search-trigger-bg: rgba(197, 160, 89, 0.1);
    --oem-search-trigger-hover-bg: rgba(197, 160, 89, 0.2);
    --oem-search-trigger-focus-ring: 0 0 0 3px rgba(197, 160, 89, 0.3);
    --oem-search-header-bg: var(--oem-header-bg, #15192B);
    --oem-search-container-bg: rgba(21, 25, 43, 0.98);
    --oem-search-container-border: rgba(197, 160, 89, 0.1);
    --oem-search-focus-within-bg: rgba(197, 160, 89, 0.05);
    --oem-search-focus-within-ring: 0 0 0 4px rgba(197, 160, 89, 0.1);
    --oem-search-close-bg: rgba(255, 255, 255, 0.1);
    --oem-search-close-text: var(--oem-text-bright, #e0e0e0);
    --oem-search-filters-bg: rgba(0, 0, 0, 0.15);
    --oem-filter-option-bg: rgba(255, 255, 255, 0.06);
    --oem-filter-option-text: var(--oem-text-muted, #a0a8b8);
    --oem-filter-option-border: rgba(255, 255, 255, 0.1);
}

/* ============================================
   MINIMAL SEARCH (Header/Navbar Style)
   ============================================ */

.oem-search-minimal {
    position: relative;
    display: inline-block;
}

.oem-search-trigger {
    background: var(--oem-search-trigger-bg);
    border: 1px solid var(--oem-gold);
    cursor: pointer;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    min-width: 40px;
    height: 44px;
    box-sizing: border-box;
}

.oem-search-trigger:hover,
.oem-search-trigger:focus {
    background: var(--oem-search-trigger-hover-bg);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.oem-search-trigger:focus-visible {
    outline: 2px solid var(--oem-gold);
    outline-offset: 2px;
}

.oem-search-trigger.active {
    background: var(--oem-gold);
    color: #101419;
    box-shadow: var(--oem-search-trigger-focus-ring);
}

.oem-search-trigger .search-icon {
    width: 20px;
    height: 20px;
    color: var(--oem-gold);
    transition: color 0.3s;
}

.oem-search-trigger.active .search-icon {
    color: #101419;
}

.oem-search-trigger .search-text {
    font-weight: 600;
    font-size: 14px;
    color: var(--oem-gold);
}

.oem-search-trigger.active .search-text {
    color: #101419;
}

/* Gizli iken JS tarafında aria-hidden="true" set edilmeli (screen reader / keyboard). */
.oem-search-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 420px;
    max-width: 90vw;
    background: var(--oem-search-bg);
    border-radius: 12px;
    box-shadow: var(--oem-search-shadow), 0 0 0 1px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.98);
    transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
        visibility 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
        transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: var(--oem-z-dropdown, 300);
    overflow: hidden;
    transform-origin: top right;
    pointer-events: none;
}

.oem-search-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    /* Enable interaction when active */
}

/* Arrow Tip */
.oem-search-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: var(--oem-search-bg);
    transform: rotate(45deg);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 1;
}

.search-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--oem-search-border);
    gap: 10px;
    background: var(--oem-search-header-bg);
    position: relative;
    z-index: 2;
}

.oem-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    color: var(--oem-search-text);
    background: transparent;
    font-weight: 500;
    padding: 5px 0;
}

.oem-search-input:focus {
    outline: none;
}

/* Wrapper’da focus-within ring var; çifte focus olmaması için minimal’da outline. Full’da input outline yok. */
.oem-search-input:focus-visible {
    outline: 2px solid var(--oem-gold);
    outline-offset: 2px;
    border-radius: 4px;
}

.oem-search-input::placeholder {
    color: var(--oem-search-placeholder);
}

.search-close {
    background: var(--oem-search-close-bg, rgba(255, 255, 255, 0.1));
    border: none;
    font-size: 20px;
    color: var(--oem-search-close-text, #e0e0e0);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.search-close:hover {
    background: #ff4757;
    color: #fff;
    transform: rotate(90deg);
}

.search-close:focus-visible {
    outline: 2px solid var(--oem-gold);
    outline-offset: 2px;
}

.search-filters {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: var(--oem-search-filters-bg, rgba(0, 0, 0, 0.15));
    border-bottom: 1px solid var(--oem-search-border);
    overflow-x: auto;
    white-space: nowrap;
    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.search-filters::-webkit-scrollbar {
    display: none;
}

.filter-option {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--oem-filter-option-text, #a0a8b8);
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--oem-filter-option-bg, rgba(255, 255, 255, 0.06));
    border: 1px solid var(--oem-filter-option-border, rgba(255, 255, 255, 0.1));
    transition: all 0.2s;
    user-select: none;
}

.filter-option:hover {
    border-color: var(--oem-gold);
    color: var(--oem-gold);
}

.filter-option:focus-visible {
    outline: 2px solid var(--oem-gold);
    outline-offset: 2px;
}

.filter-option input[type="radio"] {
    display: none;
}

/* Selected State - Using sibling selector for better compatibility */
.filter-option input:checked+span {
    font-weight: 700;
    color: var(--oem-text-bright, #fff);
}

/* Modern Browser Support for :has */
@supports selector(:has(a, b)) {
    .filter-option:has(input:checked) {
        background: var(--oem-gold);
        border-color: var(--oem-gold);
        color: var(--oem-text-bright, #fff);
    }

    .filter-option input:checked+span {
        color: var(--oem-text-bright, #fff);
    }
}

/* Fallback for older browsers (needs simple JS or just use simple active class) */
.filter-option.active {
    background: var(--oem-gold);
    border-color: var(--oem-gold);
    color: #fff;
}

.filter-option.active span {
    color: #fff;
    font-weight: 700;
}

.search-results-container {
    max-height: 400px;
    overflow-y: auto;
    overscroll-behavior: contain;
    position: relative;
    background: rgba(255, 255, 255, 0.02);
}

.search-results-container::-webkit-scrollbar {
    width: 8px;
}

.search-results-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.search-results-container::-webkit-scrollbar-thumb {
    background: var(--oem-color-accent, var(--oem-gold, #d4af37));
    border-radius: 4px;
}

.search-results-container::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--oem-color-accent, #d4af37) 80%, transparent);
}

/* display:none → transition yok; animasyon istersen opacity + max-height kullan. */
.search-results {
    display: none;
}

.search-loading,
.search-empty {
    display: none;
    /* Hidden by default, shown via JS */
    padding: 40px;
    text-align: center;
    color: #888;
}

.oem-search-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--oem-gold);
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: oem-search-spin 1s linear infinite;
}

@keyframes oem-search-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================
   FULL SEARCH (Hero/Page Style)
   ============================================ */

.oem-search-full {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* z-index düşük: header menü dropdown’ı (layout --z-dropdown) arama kutusunun üstünde kalsın */
.oem-search-full .search-container {
    background: var(--oem-search-container-bg, rgba(21, 25, 43, 0.98));
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--oem-search-container-border, rgba(197, 160, 89, 0.1));
    border: 1px solid var(--oem-search-container-border, rgba(197, 160, 89, 0.1));
    position: relative;
    z-index: 1;
}

.oem-search-full .search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: color-mix(in srgb, var(--oem-search-container-bg, #15192b) 92%, rgba(255, 255, 255, 0.06));
    border-radius: 14px;
    border: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    flex-wrap: wrap;
}

/* Tek focus ring (input outline full’da kapalı → çifte efekt yok) */
.oem-search-full .search-input-wrapper:focus-within {
    background: var(--oem-search-focus-within-bg, rgba(197, 160, 89, 0.05));
    border-color: var(--oem-gold);
    box-shadow: var(--oem-search-focus-within-ring, 0 0 0 4px rgba(197, 160, 89, 0.1));
}

.search-icon-static {
    width: 24px;
    height: 24px;
    color: var(--oem-text-muted, #999);
    flex-shrink: 0;
}

.search-input-wrapper:focus-within .search-icon-static {
    color: var(--oem-gold);
}

.oem-search-full .oem-search-input-full {
    flex: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 16px;
    color: var(--oem-search-text, var(--oem-header-text, #ffffff)) !important;
    background: transparent !important;
    font-weight: 400;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.oem-search-full .oem-search-input-full:focus {
    outline: none !important;
    box-shadow: none !important;
}

.oem-search-full .oem-search-input-full:focus-visible {
    outline: none !important;
}

.oem-search-full .oem-search-input-full::placeholder {
    color: var(--oem-search-placeholder, var(--oem-text-muted, rgba(255, 255, 255, 0.4))) !important;
}

/* Elementor button stillerinin ezmemesi için yüksek özgüllük + !important */
.oem-search-full .search-input-wrapper .search-clear-btn,
.oem-search-full button.search-clear-btn {
    background: var(--oem-search-close-bg, rgba(255, 255, 255, 0.1)) !important;
    border: none !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    border-radius: 50% !important;
    font-size: 20px !important;
    color: var(--oem-search-close-text, #fff) !important;
    cursor: pointer !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s !important;
    line-height: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: Arial, sans-serif !important;
    box-shadow: none !important;
    outline: none !important;
    appearance: none !important;
}

.oem-search-full .search-input-wrapper .search-clear-btn.is-visible,
.oem-search-full button.search-clear-btn.is-visible {
    display: inline-flex !important;
}

.oem-search-full .search-input-wrapper .search-clear-btn:hover,
.oem-search-full button.search-clear-btn:hover {
    background: #ff4757 !important;
    color: #fff !important;
    transform: scale(1.1) !important;
    box-shadow: none !important;
}

.oem-search-full .search-input-wrapper .search-clear-btn:focus,
.oem-search-full button.search-clear-btn:focus,
.oem-search-full .search-input-wrapper .search-clear-btn:focus-visible,
.oem-search-full button.search-clear-btn:focus-visible {
    outline: 2px solid var(--oem-gold) !important;
    outline-offset: 2px !important;
    box-shadow: none !important;
}

.search-filters-full {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-chip {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.03);
    color: #a0a0a0;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: 1px solid var(--oem-accent-bg-15, rgba(212, 175, 55, 0.15));
    white-space: nowrap;
}

.filter-chip input {
    display: none;
}

.filter-chip:hover {
    background: rgba(0, 0, 0, 0.08);
}

.filter-chip:focus-visible {
    outline: 2px solid var(--oem-gold);
    outline-offset: 2px;
}

/* :has() ile checked state; yoksa JS .active class gerekir (progressive enhancement yarım). */
@supports selector(:has(a, b)) {
    .filter-chip:has(input:checked) {
        background: var(--oem-gold);
        color: #101419;
        box-shadow: 0 4px 12px var(--oem-accent-bg-20, rgba(212, 175, 55, 0.2));
    }
}

/* Fallback: JS .active atamalı (eski tarayıcı / :has yok) */
.filter-chip.active {
    background: var(--oem-gold);
    color: #101419;
    box-shadow: 0 4px 12px var(--oem-accent-bg-20, rgba(212, 175, 55, 0.2));
}

/* Results Area (Full) – container’ın üstünde görünsün (z-index: 20), üst parent’ta taşma kesilmesin */
.oem-search-full {
    overflow: visible;
}

.oem-search-full .search-results-full {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: var(--oem-search-results-full-bg, var(--oem-search-container-bg, rgba(11, 28, 61, 0.98)));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--oem-search-container-border, rgba(212, 175, 55, 0.15));
    box-shadow: var(--oem-search-results-full-shadow, var(--oem-search-shadow, 0 25px 60px rgba(0, 0, 0, 0.5)));
    z-index: 20;
    display: none;
    max-height: 60vh;
    overflow-y: auto;
}

.oem-search-full .results-content {
    display: none;
}

.search-loading-full,
.search-empty-full {
    display: none;
    padding: 60px 40px;
    text-align: center;
    color: var(--oem-text-muted, #a0a0a0);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.search-empty-full p {
    font-size: 18px;
    font-weight: 600;
    color: var(--oem-header-text, var(--oem-search-text, #ffffff));
    margin: 0;
}

.search-empty-full small,
.search-empty-hint {
    display: block;
    margin-top: 5px;
    opacity: 0.7;
    color: var(--oem-color-accent, #d4af37);
    font-weight: 500;
}

.search-empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.search-loading-full .oem-search-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--oem-gold);
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: oem-search-spin 1s linear infinite;
}

/* ============================================
   RESULT ITEMS (Common)
   ============================================ */

.search-result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 25px;
    text-decoration: none;
    color: var(--oem-search-text, var(--oem-text-bright, #e0e0e0));
    border-bottom: 1px solid var(--oem-search-container-border, rgba(255, 255, 255, 0.05));
    transition: all 0.3s;
}

.search-result-item:last-child {
    border-bottom: none;
}

/* Fade-in: JS adds .oem-search-fade-in after rendering (no inline transition) */
.oem-search-dropdown .search-results,
.search-results-full .results-content {
    opacity: 0;
}

.oem-search-dropdown .search-results.oem-search-fade-in,
.search-results-full .results-content.oem-search-fade-in {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.search-empty,
.search-empty-full {
    opacity: 0;
}

.search-empty.oem-search-fade-in,
.search-empty-full.oem-search-fade-in {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.search-result-item:hover {
    background: color-mix(in srgb, var(--oem-color-accent, #d4af37) 8%, transparent);
}

.search-result-item:focus-visible {
    outline: none;
    background: color-mix(in srgb, var(--oem-color-accent, #d4af37) 12%, transparent);
}

.result-badge {
    background: var(--oem-card, rgba(255, 255, 255, 0.08));
    color: var(--oem-header-text, #fff);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-oem {
    font-size: 14px;
    font-weight: 700;
    color: var(--oem-gold);
    margin-bottom: 2px;
}

.result-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--oem-header-text, var(--oem-search-text, #ffffff));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-post {
    font-size: 12px;
    color: var(--oem-text-muted, #999);
}

.result-arrow {
    width: 20px;
    height: 20px;
    color: var(--oem-text-muted, #ccc);
    transition: transform 0.2s;
}

.search-result-item:hover .result-arrow {
    color: var(--oem-gold);
    transform: translateX(3px);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .oem-search-dropdown {
        position: fixed !important;
        top: 70px !important;
        left: 15px !important;
        right: 15px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 100px) !important;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform-origin: top center !important;
    }

    .oem-search-dropdown.active {
        transform: translateY(0) scale(1) !important;
    }

    .oem-search-dropdown::before {
        display: none;
    }

    .search-filters {
        padding: 10px;
    }

    .oem-search-trigger .search-text {
        display: none !important;
    }

    .oem-search-trigger {
        padding: 0;
        width: 44px;
        min-width: 44px;
    }

    .oem-search-full {
        padding: 0;
    }

    .oem-search-full .search-container,
    .oem-search-full .search-results-full {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .oem-search-full .search-container {
        padding: 20px;
    }

    .oem-search-full .search-input-wrapper {
        padding: 10px 15px;
    }

    .oem-search-input-full {
        font-size: 16px;
        /* Prevent iOS zoom */
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .search-result-item {
        min-height: 60px;
        /* Larger touch target */
    }

    .oem-search-trigger {
        height: 44px;
        /* iOS minimum */
    }
}