/**
 * WOA Search - Styles
 * 
 * Custom AJAX product search styling.
 * 
 * @package WebtronAuctionSite
 * @since 1.1.0
 */

/* ==========================================================================
   Search Wrapper
   ========================================================================== */

.woa-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 480px;
    min-width: 280px;
}

/* ==========================================================================
   Search Form
   ========================================================================== */

.woa-search-form {
    position: relative;
}

.woa-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: stretch;
}

.woa-search-input {
    flex: 1;
    padding: 12px 16px;
    padding-right: 100px;
    font-size: 15px;
    line-height: 1.4;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    color: #1a1a1a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    outline: none;
    width: 100%;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.woa-search-input:focus {
    border-color: #8b0000;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.woa-search-input::placeholder {
    color: #999999;
}

/* Keyboard shortcut hint */
.woa-search-shortcut {
    position: absolute;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 3px;
    pointer-events: none;
}

.woa-search-shortcut kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #666666;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.woa-search-input:focus ~ .woa-search-shortcut {
    opacity: 0;
}

.woa-search-submit {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: #666666;
    cursor: pointer;
    transition: color 0.2s ease;
}

.woa-search-submit:hover {
    color: #8b0000;
}

.woa-search-submit svg {
    display: block;
}

/* ==========================================================================
   Include Sold Toggle
   ========================================================================== */

/* Hide the toggle from shortcode version - only modal should control this */
.woa-search-wrapper .woa-search-toggle {
    display: none;
}

.woa-search-toggle {
    margin-top: 10px;
}

.woa-search-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #666666;
    user-select: none;
}

.woa-search-include-sold {
    position: relative;
    width: 38px;
    height: 20px;
    appearance: none;
    -webkit-appearance: none;
    background: #cccccc;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.woa-search-include-sold:checked {
    background: #8b0000;
}

.woa-search-include-sold::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.woa-search-include-sold:checked::before {
    transform: translateX(18px);
}

.woa-search-toggle-text {
    transition: color 0.2s ease;
}

.woa-search-include-sold:checked + .woa-search-toggle-text {
    color: #333333;
}

/* ==========================================================================
   Results Dropdown
   ========================================================================== */

.woa-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    margin-top: 8px;
    max-height: 450px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.woa-search-results.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Results list */
.woa-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Result Item
   ========================================================================== */

.woa-search-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s ease;
}

.woa-search-result-item:last-child {
    border-bottom: none;
}

.woa-search-result-item:hover,
.woa-search-result-item.is-selected {
    background: #f8f8f8;
}

/* Result image */
.woa-search-result-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 4px;
    background: #f5f5f5;
}

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

/* Result content */
.woa-search-result-content {
    flex: 1;
    min-width: 0;
}

.woa-search-result-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.woa-search-result-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666666;
}

/* Categories */
.woa-search-categories {
    color: #888888;
}

.woa-search-category-link {
    color: #8b0000;
    text-decoration: none;
    transition: color 0.15s ease;
}

.woa-search-category-link:hover {
    color: #5c0000;
    text-decoration: underline;
}

/* Price */
.woa-search-result-price {
    font-weight: 600;
    color: #333333;
}

.woa-search-result-price del {
    color: #999999;
    font-weight: 400;
}

.woa-search-result-price ins {
    text-decoration: none;
    color: #8b0000;
}

/* Stock badge */
.woa-search-result-stock {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 3px;
}

.woa-search-result-stock.in-stock {
    background: #d4edda;
    color: #155724;
}

.woa-search-result-stock.sold {
    background: #f8d7da;
    color: #721c24;
}

/* ==========================================================================
   View All Link
   ========================================================================== */

.woa-search-view-all {
    padding: 14px 16px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

.woa-search-view-all a {
    color: #8b0000;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s ease;
}

.woa-search-view-all a:hover {
    color: #5c0000;
    text-decoration: underline;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.woa-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 16px;
    color: #666666;
    font-size: 14px;
}

.woa-search-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e0e0e0;
    border-top-color: #8b0000;
    border-radius: 50%;
    animation: woa-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   No Results
   ========================================================================== */

.woa-search-no-results {
    padding: 24px 16px;
    text-align: center;
    color: #666666;
    font-size: 14px;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .woa-search-wrapper {
        max-width: 100%;
    }
    
    .woa-search-input {
        padding: 14px 16px;
        padding-right: 50px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .woa-search-results {
        position: fixed;
        top: auto;
        left: 10px;
        right: 10px;
        bottom: 10px;
        max-height: 60vh;
        border-radius: 12px;
        margin-top: 0;
    }
    
    .woa-search-result-item {
        padding: 14px;
    }
    
    .woa-search-result-image {
        width: 50px;
        height: 50px;
    }
    
    .woa-search-result-title {
        font-size: 13px;
    }
    
    .woa-search-result-stock {
        position: absolute;
        top: 10px;
        right: 10px;
        font-size: 10px;
        padding: 3px 8px;
    }
    
    .woa-search-result-item {
        position: relative;
        padding-right: 80px;
    }
}

/* ==========================================================================
   Dark Mode Support (User Toggle Only)
   ========================================================================== */

/* Dark mode is controlled by the .woa-dark-mode class on <html>
   See dark-mode.css for dark mode styles */

/* ==========================================================================
   Header Search Integration
   ========================================================================== */

/* Style for when search is in header/navigation */
.site-header .woa-search-wrapper,
.main-navigation .woa-search-wrapper,
#et-top-navigation .woa-search-wrapper {
    max-width: 300px;
}

.site-header .woa-search-input,
.main-navigation .woa-search-input {
    padding: .5rem;
    padding-right: 44px;
    font-size: 14px;
}

.site-header .woa-search-toggle,
.main-navigation .woa-search-toggle {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #ffffff;
    padding: 8px 12px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.site-header .woa-search-input:focus ~ .woa-search-toggle,
.main-navigation .woa-search-input:focus ~ .woa-search-toggle,
.site-header .woa-search-toggle:hover,
.main-navigation .woa-search-toggle:hover {
    opacity: 1;
    visibility: visible;
}
