/**
 * Search Shortcode Styles
 * Inline search bar with dropdown results
 *
 * @package Betformatics
 */

/* ==========================================================================
   ACCESSIBILITY - SCREEN READER ONLY
   ========================================================================== */

.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
    white-space: nowrap;
}

/* ==========================================================================
   SEARCH CONTAINER
   ========================================================================== */

.bf-search-shortcode {
    position: relative;
    width: 100%;
    max-width: 500px;
    font-family: var(--bf-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif);
}

.bf-search-wrapper {
    position: relative;
}

/* ==========================================================================
   INPUT WRAPPER
   ========================================================================== */

.bf-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--bf-primary, #7ed957);
    border-radius: var(--bf-border-radius-lg, 10px);
    transition: border-color var(--bf-transition-fast, 0.15s ease),
                box-shadow var(--bf-transition-fast, 0.15s ease);
}

.bf-search-input-wrapper:focus-within {
    border-color: var(--bf-accent, #ffff00);
    box-shadow: 0 0 0 3px rgba(var(--bf-primary-rgb, 126, 217, 87), 0.2),
                0 0 20px rgba(var(--bf-primary-rgb, 126, 217, 87), 0.3);
}

/* Search Icon */
.bf-search-shortcode .bf-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bf-text-secondary, #aaaaaa);
    pointer-events: none;
    transition: color var(--bf-transition-fast, 0.15s ease);
    z-index: 1;
}

.bf-search-input-wrapper:focus-within .bf-search-icon {
    color: var(--bf-primary, #7ed957);
}

/* Input Field */
.bf-search-shortcode .bf-search-field {
    flex: 1;
    width: 100%;
    padding: 12px 40px 12px 44px !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    font-size: 16px;
    font-weight: 400;
    color: var(--bf-text-primary, #ffffff);
    caret-color: var(--bf-primary, #7ed957);
}

.bf-search-field::placeholder {
    color: var(--bf-text-muted, #888888);
}

/* Hide browser default search cancel button */
.bf-search-field::-webkit-search-cancel-button,
.bf-search-field::-webkit-search-decoration {
    display: none;
    -webkit-appearance: none;
}

/* Clear Button */
.bf-search-shortcode .bf-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    border-radius: 50% !important;
    color: var(--bf-text-secondary, #aaaaaa) !important;
    cursor: pointer;
    transition: background var(--bf-transition-fast, 0.15s ease),
                color var(--bf-transition-fast, 0.15s ease);
    box-shadow: none !important;
    outline: none !important;
}

/* Hidden state for clear button */
.bf-search-clear--hidden {
    display: none !important;
}

.bf-search-shortcode .bf-search-clear:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: var(--bf-text-primary, #ffffff) !important;
}

.bf-search-shortcode .bf-search-clear svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ==========================================================================
   DROPDOWN
   ========================================================================== */

.bf-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--bf-border-radius-lg, 10px);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05),
                0 0 30px rgba(var(--bf-primary-rgb, 126, 217, 87), 0.2),
                0 15px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease,
                visibility 0s 0.2s,
                transform 0.2s ease;
    z-index: 1000;
}

.bf-search-shortcode.is-open .bf-search-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.2s ease,
                visibility 0s,
                transform 0.2s ease;
}

/* ==========================================================================
   RESULTS
   ========================================================================== */

.bf-search-results {
    max-height: 400px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Loading & Messages */
.bf-search-loading,
.bf-search-no-results,
.bf-search-min-chars {
    padding: 20px;
    text-align: center;
    color: var(--bf-text-muted, #888888);
    font-size: 14px;
}

.bf-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.bf-search-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(var(--bf-primary-rgb, 126, 217, 87), 0.3);
    border-top-color: var(--bf-primary, #7ed957);
    border-radius: 50%;
    animation: bf-search-spin 0.8s linear infinite;
}

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

/* Results List */
.bf-search-results-list {
    padding: 8px;
}

/* Result Item */
.bf-search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--bf-text-primary, #ffffff);
    transition: background var(--bf-transition-fast, 0.15s ease);
}

.bf-search-result-item:hover,
.bf-search-result-item:focus {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.bf-search-result-item:focus-visible {
    outline: 2px solid var(--bf-primary, #7ed957);
    outline-offset: -2px;
}

/* Result Thumbnail */
.bf-search-result-thumb {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.bf-search-result-thumb svg {
    width: 20px;
    height: 20px;
    color: var(--bf-text-muted, #888888);
}

/* Result Info */
.bf-search-result-info {
    flex: 1;
    min-width: 0;
}

.bf-search-result-type {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bf-primary, #7ed957);
    margin-bottom: 2px;
}

.bf-search-result-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--bf-accent, #ffff00);
}

/* Highlight matching text */
.bf-search-result-title mark {
    background: transparent;
    color: inherit;
    font-weight: 700;
}

/* ==========================================================================
   MOBILE RESPONSIVE
   ========================================================================== */

@media (max-width: 640px) {
    .bf-search-shortcode {
        max-width: 100%;
    }

    .bf-search-field {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 10px 36px 10px 40px;
    }

    .bf-search-shortcode .bf-search-icon {
        left: 12px;
        width: 18px;
        height: 18px;
    }

    .bf-search-clear {
        right: 8px;
        width: 24px;
        height: 24px;
    }

    .bf-search-dropdown {
        top: calc(100% + 6px);
    }

    .bf-search-results {
        max-height: 50vh;
    }

    .bf-search-result-item {
        padding: 8px 10px;
        gap: 10px;
    }

    .bf-search-result-thumb {
        width: 38px;
        height: 38px;
    }

    .bf-search-result-title {
        font-size: 13px;
    }
}

/* ==========================================================================
   DARK/LIGHT MODE SUPPORT (if needed)
   ========================================================================== */

@media (prefers-color-scheme: light) {
    /* Keep dark theme for consistency with site design */
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .bf-search-dropdown {
        transition: opacity 0.01ms, visibility 0s;
        transform: none;
    }

    .bf-search-loading::before {
        animation: none;
    }
}