/**
 * WooCommerce Advanced Search - Frontend Styles
 * 
 * Styles for search input, results display, highlighting,
 * keyboard navigation, and responsive design.
 * 
 * @package WC_Advanced_Search
 */

/* ==========================================================================
   Search Wrapper
   ========================================================================== */

.wc-advanced-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    direction: rtl;
    text-align: right;
}

/* ==========================================================================
   Search Input
   ========================================================================== */

.wc-advanced-search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.wc-advanced-search-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.wc-advanced-search-input::placeholder {
    color: #999;
    opacity: 1;
}

/* ==========================================================================
   Loading Indicator
   ========================================================================== */

.wc-search-loading {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
    pointer-events: none;
}

.wc-search-loading .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: wc-search-spin 0.6s linear infinite;
}

@keyframes wc-search-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Results Container
   ========================================================================== */

.wc-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 400px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.wc-search-results-list {
    padding: 8px 0;
}

/* ==========================================================================
   Result Items
   ========================================================================== */

.wc-search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f0f0f0;
}

.wc-search-result-item:last-child {
    border-bottom: none;
}

.wc-search-result-item:hover,
.wc-search-result-item.selected {
    background-color: #f5f5f5;
}

.wc-search-result-item.selected {
    background-color: #e8f4f8;
}

/* Product Name */
.wc-search-result-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.4;
}

/* Product Price */
.wc-search-result-price {
    font-size: 14px;
    font-weight: 600;
    color: #cc0000;
    margin-bottom: 4px;
}

/* Product Category */
.wc-search-result-category {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

/* View More Button */
.wc-search-view-more {
    display: block;
    padding: 12px 16px;
    text-align: center;
    background-color: #03A9F4;
    color: #fff !important;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: 0 0 8px 8px;
    transition: background-color 0.2s ease;
}

.wc-search-view-more:hover {
    background-color: #03A9F4;
    color: #fff !important;
}

/* ==========================================================================
   Highlighting
   ========================================================================== */

.wc-search-result-name mark {
    background-color: #E1F5FE;
    color: #03A9F4;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: normal;
}
/* ==========================================================================
   No Results / Error Messages
   ========================================================================== */

.wc-search-no-results,
.wc-search-error {
    padding: 20px 16px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.wc-search-error {
    color: #d63638;
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

.wc-search-results::-webkit-scrollbar {
    width: 8px;
}

.wc-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 8px 8px 0;
}

.wc-search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.wc-search-results::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ==========================================================================
   Responsive Design - Mobile
   ========================================================================== */

@media (max-width: 768px) {
    .wc-advanced-search-wrapper {
        max-width: 100%;
    }

    .wc-advanced-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 16px;
    }

    .wc-search-results {
        max-height: 60vh;
        border-radius: 8px;
    }

    .wc-search-result-item {
        padding: 16px;
        min-height: 44px; /* Touch-friendly minimum */
    }

    .wc-search-result-name {
        font-size: 16px;
    }

    .wc-search-result-price {
        font-size: 15px;
    }

    .wc-search-result-category {
        font-size: 13px;
    }
}

/* ==========================================================================
   Responsive Design - Small Mobile
   ========================================================================== */

@media (max-width: 480px) {
    .wc-advanced-search-input {
        padding: 12px 14px;
    }

    .wc-search-results {
        top: calc(100% + 4px);
        max-height: 50vh;
    }

    .wc-search-result-item {
        padding: 14px;
    }
}

/* ==========================================================================
   Touch-Friendly Buttons
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .wc-search-result-item {
        min-height: 44px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .wc-search-result-item:active {
        background-color: #e0e0e0;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.wc-advanced-search-input:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.wc-search-result-item:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wc-advanced-search-input {
        border-width: 3px;
    }

    .wc-search-result-item.selected {
        border: 2px solid #0073aa;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wc-advanced-search-input,
    .wc-search-result-item,
    .wc-search-loading .spinner {
        transition: none;
        animation: none;
    }
}

/* ==========================================================================
   Dark Mode Support (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .wc-advanced-search-input {
        background-color: #1e1e1e;
        color: #e0e0e0;
        border-color: #444;
    }

    .wc-advanced-search-input:focus {
        border-color: #4a9eff;
        box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
    }

    .wc-advanced-search-input::placeholder {
        color: #888;
    }

    .wc-search-results {
        background-color: #2a2a2a;
        border-color: #444;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }

    .wc-search-result-item {
        border-bottom-color: #3a3a3a;
    }

    .wc-search-result-item:hover,
    .wc-search-result-item.selected {
        background-color: #333;
    }

    .wc-search-result-item.selected {
        background-color: #1a3a4a;
    }

    .wc-search-result-name {
        color: #e0e0e0;
    }

    .wc-search-result-price {
        color: #4a9eff;
    }

    .wc-search-result-category {
        color: #aaa;
    }

    .wc-search-result-name mark {
        background-color: #4a4a00;
        color: #ffeb3b;
    }

    .wc-search-no-results,
    .wc-search-error {
        color: #aaa;
    }

    .wc-search-error {
        color: #ff6b6b;
    }

    .wc-search-results::-webkit-scrollbar-track {
        background: #1e1e1e;
    }

    .wc-search-results::-webkit-scrollbar-thumb {
        background: #555;
    }

    .wc-search-results::-webkit-scrollbar-thumb:hover {
        background: #777;
    }
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="ltr"] .wc-advanced-search-wrapper {
    direction: ltr;
    text-align: left;
}

[dir="ltr"] .wc-search-loading {
    left: auto;
    right: 16px;
}

[dir="ltr"] .wc-search-results::-webkit-scrollbar-track {
    border-radius: 8px 0 0 8px;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .wc-advanced-search-wrapper,
    .wc-search-results,
    .wc-search-loading {
        display: none !important;
    }
}
