/* WooCommerce Smart Search Styles */

:root {
    --wc-smart-search-primary: #4CAF50;
    --wc-smart-search-primary-dark: #388E3C;
    --wc-smart-search-primary-light: #E8F5E8;
    --wc-smart-search-white: #ffffff;
    --wc-smart-search-black: #333333;
    --wc-smart-search-gray-100: #f8f9fa;
    --wc-smart-search-gray-200: #e9ecef;
    --wc-smart-search-gray-300: #dee2e6;
    --wc-smart-search-gray-400: #ced4da;
    --wc-smart-search-gray-500: #adb5bd;
    --wc-smart-search-gray-600: #6c757d;
    --wc-smart-search-gray-700: #495057;
    --wc-smart-search-gray-800: #343a40;
    --wc-smart-search-gray-900: #212529;
    --wc-smart-search-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --wc-smart-search-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
    --wc-smart-search-border-radius: 12px;
    --wc-smart-search-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --wc-smart-search-font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Search Field Styles */
.wc-smart-search-field-wrapper {
    position: relative;
    display: inline-block;
    font-family: var(--wc-smart-search-font-family);
}

.wc-smart-search-form {
    margin: 0;
    padding: 0;
}

.wc-smart-search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--wc-smart-search-white);
    border: 2px solid var(--wc-smart-search-gray-300);
    border-radius: var(--wc-smart-search-border-radius);
    transition: var(--wc-smart-search-transition);
    overflow: hidden;
}

.wc-smart-search-input-group:focus-within {
    border-color: var(--wc-smart-search-primary);
    box-shadow: 0 0 0 3px var(--wc-smart-search-primary-light);
}

.wc-smart-search-trigger-field {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 16px;
    font-family: var(--wc-smart-search-font-family);
    font-size: 16px;
    font-weight: 400;
    background: transparent;
    color: var(--wc-smart-search-gray-700);
    cursor: pointer;
}

.wc-smart-search-trigger-field::placeholder {
    color: var(--wc-smart-search-gray-500);
}

.wc-smart-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    color: var(--wc-smart-search-gray-500);
}

.wc-smart-search-trigger-button {
    background: var(--wc-smart-search-primary);
    color: white;
    border: none;
    padding: 12px 20px;
    font-family: var(--wc-smart-search-font-family);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wc-smart-search-transition);
    outline: none;
}

.wc-smart-search-trigger-button:hover {
    background: var(--wc-smart-search-primary-dark);
}

/* Style Variations */
.wc-smart-search-style-minimal .wc-smart-search-input-group {
    border: 1px solid var(--wc-smart-search-gray-300);
    border-radius: 4px;
}

.wc-smart-search-style-rounded .wc-smart-search-input-group {
    border-radius: 25px;
}

.wc-smart-search-style-custom .wc-smart-search-input-group {
    /* Can be customized via theme CSS */
}

/* Size Variations */
.wc-smart-search-size-small .wc-smart-search-trigger-field {
    padding: 8px 12px;
    font-size: 14px;
}

.wc-smart-search-size-small .wc-smart-search-trigger-button {
    padding: 8px 16px;
    font-size: 13px;
}

.wc-smart-search-size-medium .wc-smart-search-trigger-field {
    padding: 12px 16px;
    font-size: 16px;
}

.wc-smart-search-size-large .wc-smart-search-trigger-field {
    padding: 16px 20px;
    font-size: 18px;
}

.wc-smart-search-size-large .wc-smart-search-trigger-button {
    padding: 16px 24px;
    font-size: 16px;
}

/* Widget Styles */
.wc-smart-search-widget .wc-smart-search-field-wrapper {
    width: 100%;
}

/* Focus styles */
.wc-smart-search-trigger-field:focus {
    /* Focus handled by parent container */
}

/* Hover effects */
.wc-smart-search-input-group:hover {
    border-color: var(--wc-smart-search-gray-400);
}

/* Main Megamenu Container */
.wc-smart-search-megamenu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 999999;
    font-family: var(--wc-smart-search-font-family);
    font-size: 14px;
    line-height: 1.5;
    color: var(--wc-smart-search-gray-700);
    width: 100%;
}

.wc-smart-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: -1;
    pointer-events: all;
}

.wc-smart-search-container {
    position: relative;
    background: var(--wc-smart-search-white);
    box-shadow: var(--wc-smart-search-shadow-lg);
    border-radius: 0 0 var(--wc-smart-search-border-radius) var(--wc-smart-search-border-radius);
    width: 100%;
    max-width: none;
    margin: 0;
    transform: translateY(-20px);
    opacity: 0;
    transition: var(--wc-smart-search-transition);
    overflow: hidden;
    display: flex;
    min-height: 400px;
}

.wc-smart-search-megamenu.active .wc-smart-search-container {
    transform: translateY(0);
    opacity: 1;
}

/* Left Sidebar - Categories */
.wc-smart-search-sidebar {
    width: 280px;
    background: var(--wc-smart-search-gray-100);
    border-right: 1px solid var(--wc-smart-search-gray-200);
    padding: 24px;
    overflow-y: auto;
    max-height: 500px;
}

.wc-smart-search-sidebar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--wc-smart-search-gray-800);
    margin: 0 0 20px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--wc-smart-search-primary);
}

.wc-smart-search-categories-tree {
    /* Categories tree styling */
}

.wc-smart-search-category-tree-item {
    margin-bottom: 8px;
}

.wc-smart-search-category-tree-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--wc-smart-search-gray-700);
    text-decoration: none;
    border-radius: 6px;
    transition: var(--wc-smart-search-transition);
    font-weight: 500;
}

.wc-smart-search-category-tree-link:hover {
    background: var(--wc-smart-search-primary-light);
    color: var(--wc-smart-search-primary);
}

.wc-smart-search-category-tree-link.has-children::after {
    content: '▶';
    margin-left: auto;
    font-size: 12px;
    transition: var(--wc-smart-search-transition);
}

.wc-smart-search-category-tree-link.expanded::after {
    transform: rotate(90deg);
}

.wc-smart-search-category-children {
    margin-left: 16px;
    margin-top: 4px;
    border-left: 2px solid var(--wc-smart-search-gray-300);
    padding-left: 12px;
}

.wc-smart-search-category-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--wc-smart-search-gray-500);
    background: var(--wc-smart-search-gray-200);
    padding: 2px 6px;
    border-radius: 10px;
}

/* Right Main Content */
.wc-smart-search-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header with Search Input */
.wc-smart-search-header {
    padding: 24px 32px 16px 32px;
    background: var(--wc-smart-search-white);
    border-bottom: 1px solid var(--wc-smart-search-gray-200);
}

.wc-smart-search-input-wrapper {
    position: relative;
    max-width: 100%;
    margin: 0;
}

.wc-smart-search-input {
    width: 100%;
    padding: 16px 20px 16px 50px;
    border: 2px solid var(--wc-smart-search-gray-300);
    border-radius: var(--wc-smart-search-border-radius);
    font-family: var(--wc-smart-search-font-family);
    font-size: 16px;
    font-weight: 500;
    background: var(--wc-smart-search-white);
    transition: var(--wc-smart-search-transition);
    outline: none;
}

.wc-smart-search-input:focus {
    border-color: var(--wc-smart-search-primary);
    box-shadow: 0 0 0 3px var(--wc-smart-search-primary-light);
}

.wc-smart-search-input::placeholder {
    color: var(--wc-smart-search-gray-500);
    font-weight: 400;
}

.wc-smart-search-input-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 18px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236c757d'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.7;
}

.wc-smart-search-close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    background: var(--wc-smart-search-gray-100);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--wc-smart-search-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wc-smart-search-gray-600);
}

.wc-smart-search-close:hover {
    background: var(--wc-smart-search-gray-200);
    color: var(--wc-smart-search-gray-800);
    transform: translateY(-50%) scale(1.05);
}

/* Content Area */
.wc-smart-search-content {
    padding: 24px 32px 32px 32px;
    max-height: 400px;
    overflow-y: auto;
    flex: 1;
}

/* Loading State */
.wc-smart-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--wc-smart-search-gray-600);
}

.wc-smart-search-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--wc-smart-search-gray-300);
    border-top: 3px solid var(--wc-smart-search-primary);
    border-radius: 50%;
    animation: wc-smart-search-spin 1s linear infinite;
    margin-right: 12px;
}

@keyframes wc-smart-search-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Section Titles */
.wc-smart-search-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--wc-smart-search-gray-800);
    margin: 0 0 20px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--wc-smart-search-primary);
    display: inline-block;
}

/* Products Grid */
.wc-smart-search-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.wc-smart-search-product-item {
    background: var(--wc-smart-search-white);
    border: 1px solid var(--wc-smart-search-gray-200);
    border-radius: var(--wc-smart-search-border-radius);
    overflow: hidden;
    transition: var(--wc-smart-search-transition);
    position: relative;
}

.wc-smart-search-product-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--wc-smart-search-shadow);
    border-color: var(--wc-smart-search-primary);
}

.wc-smart-search-product-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.wc-smart-search-product-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--wc-smart-search-gray-100);
}

.wc-smart-search-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--wc-smart-search-transition);
}

.wc-smart-search-product-item:hover .wc-smart-search-product-image img {
    transform: scale(1.05);
}

.wc-smart-search-product-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wc-smart-search-badge {
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wc-smart-search-badge-sale {
    background: #ff4444;
    color: white;
}

.wc-smart-search-badge-new {
    background: var(--wc-smart-search-primary);
    color: white;
}

.wc-smart-search-product-info {
    padding: 16px;
}

.wc-smart-search-product-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--wc-smart-search-gray-800);
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wc-smart-search-product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--wc-smart-search-primary);
}

.wc-smart-search-product-price del {
    color: var(--wc-smart-search-gray-500);
    font-weight: 400;
    margin-right: 8px;
}

/* Categories */
.wc-smart-search-categories {
    margin-bottom: 32px;
}

.wc-smart-search-categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.wc-smart-search-category-item {
    background: var(--wc-smart-search-gray-100);
    border-radius: 20px;
    transition: var(--wc-smart-search-transition);
}

.wc-smart-search-category-item:hover {
    background: var(--wc-smart-search-primary-light);
    transform: translateY(-2px);
}

.wc-smart-search-category-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--wc-smart-search-gray-700);
    font-weight: 500;
}

.wc-smart-search-category-name {
    margin-right: 6px;
}

.wc-smart-search-category-count {
    color: var(--wc-smart-search-gray-500);
    font-size: 13px;
}

/* No Results */
.wc-smart-search-no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--wc-smart-search-gray-600);
}

.wc-smart-search-no-results-icon {
    margin-bottom: 16px;
    opacity: 0.5;
}

.wc-smart-search-no-results h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--wc-smart-search-gray-800);
    margin: 0 0 8px 0;
}

.wc-smart-search-no-results p {
    margin: 0;
    font-size: 16px;
}

/* View All Link */
.wc-smart-search-view-all {
    text-align: center;
    margin-top: 24px;
}

.wc-smart-search-view-all-link {
    display: inline-flex;
    align-items: center;
    padding: 12px 24px;
    background: var(--wc-smart-search-primary);
    color: white;
    text-decoration: none;
    border-radius: var(--wc-smart-search-border-radius);
    font-weight: 600;
    transition: var(--wc-smart-search-transition);
}

.wc-smart-search-view-all-link:hover {
    background: var(--wc-smart-search-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--wc-smart-search-shadow);
}

/* Responsive Design */
@media (max-width: 768px) {
    .wc-smart-search-container {
        flex-direction: column;
        min-height: 300px;
    }
    
    .wc-smart-search-sidebar {
        width: 100%;
        max-height: 150px;
        padding: 16px;
    }
    
    .wc-smart-search-header {
        padding: 16px 20px 12px 20px;
    }
    
    .wc-smart-search-content {
        padding: 16px 20px 20px 20px;
        max-height: 300px;
    }
    
    .wc-smart-search-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 16px;
    }
    
    .wc-smart-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 18px 14px 45px;
    }
    
    .wc-smart-search-section-title {
        font-size: 16px;
    }
    
    .wc-smart-search-categories-list {
        gap: 8px;
    }
    
    .wc-smart-search-category-link {
        padding: 8px 12px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .wc-smart-search-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
    }
    
    .wc-smart-search-product-info {
        padding: 12px;
    }
    
    .wc-smart-search-product-title {
        font-size: 14px;
    }
    
    .wc-smart-search-product-price {
        font-size: 15px;
    }
}

/* Animation for entrance */
@keyframes wc-smart-search-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wc-smart-search-product-item,
.wc-smart-search-category-item {
    animation: wc-smart-search-fadeInUp 0.3s ease-out;
}

/* Stagger animation for multiple items */
.wc-smart-search-product-item:nth-child(1) { animation-delay: 0.05s; }
.wc-smart-search-product-item:nth-child(2) { animation-delay: 0.1s; }
.wc-smart-search-product-item:nth-child(3) { animation-delay: 0.15s; }
.wc-smart-search-product-item:nth-child(4) { animation-delay: 0.2s; }
.wc-smart-search-product-item:nth-child(5) { animation-delay: 0.25s; }
.wc-smart-search-product-item:nth-child(6) { animation-delay: 0.3s; }
.wc-smart-search-product-item:nth-child(7) { animation-delay: 0.35s; }
.wc-smart-search-product-item:nth-child(8) { animation-delay: 0.4s; }

/* Focus styles for accessibility */
.wc-smart-search-product-link:focus,
.wc-smart-search-category-link:focus,
.wc-smart-search-view-all-link:focus {
    outline: 2px solid var(--wc-smart-search-primary);
    outline-offset: 2px;
}

.wc-smart-search-input:focus {
    outline: none; /* Already handled with border and box-shadow */
}

.wc-smart-search-close:focus {
    outline: 2px solid var(--wc-smart-search-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wc-smart-search-container {
        border: 2px solid var(--wc-smart-search-black);
    }
    
    .wc-smart-search-product-item {
        border: 2px solid var(--wc-smart-search-gray-600);
    }
    
    .wc-smart-search-input {
        border: 2px solid var(--wc-smart-search-black);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wc-smart-search-container,
    .wc-smart-search-overlay,
    .wc-smart-search-product-item,
    .wc-smart-search-category-item,
    .wc-smart-search-close,
    .wc-smart-search-input,
    .wc-smart-search-product-image img {
        transition: none;
    }
    
    .wc-smart-search-spinner {
        animation: none;
    }
    
    .wc-smart-search-product-item,
    .wc-smart-search-category-item {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --wc-smart-search-white: #1a1a1a;
        --wc-smart-search-black: #ffffff;
        --wc-smart-search-gray-100: #2d2d2d;
        --wc-smart-search-gray-200: #404040;
        --wc-smart-search-gray-300: #525252;
        --wc-smart-search-gray-400: #6b6b6b;
        --wc-smart-search-gray-500: #8b8b8b;
        --wc-smart-search-gray-600: #a3a3a3;
        --wc-smart-search-gray-700: #d4d4d4;
        --wc-smart-search-gray-800: #e5e5e5;
        --wc-smart-search-gray-900: #f5f5f5;
    }
    
    .wc-smart-search-overlay {
        background: rgba(0, 0, 0, 0.7);
    }
}

/* Print styles */
@media print {
    .wc-smart-search-megamenu {
        display: none !important;
    }
}

/* RTL support */
[dir="rtl"] .wc-smart-search-input {
    padding: 16px 50px 16px 20px;
}

[dir="rtl"] .wc-smart-search-input-wrapper::before {
    left: auto;
    right: 18px;
}

[dir="rtl"] .wc-smart-search-close {
    left: 12px;
    right: auto;
}

[dir="rtl"] .wc-smart-search-product-badges {
    left: auto;
    right: 12px;
}

[dir="rtl"] .wc-smart-search-category-name {
    margin-left: 6px;
    margin-right: 0;
}

/* Custom scrollbar for webkit browsers */
.wc-smart-search-content::-webkit-scrollbar {
    width: 8px;
}

.wc-smart-search-content::-webkit-scrollbar-track {
    background: var(--wc-smart-search-gray-100);
    border-radius: 4px;
}

.wc-smart-search-content::-webkit-scrollbar-thumb {
    background: var(--wc-smart-search-gray-400);
    border-radius: 4px;
}

.wc-smart-search-content::-webkit-scrollbar-thumb:hover {
    background: var(--wc-smart-search-gray-500);
}

/* Special styles for empty states */
.wc-smart-search-no-products {
    text-align: center;
    padding: 40px 20px;
    color: var(--wc-smart-search-gray-600);
    font-style: italic;
}

/* Enhanced hover effects for better UX */
.wc-smart-search-product-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--wc-smart-search-primary), transparent);
    opacity: 0;
    transition: var(--wc-smart-search-transition);
    pointer-events: none;
}

.wc-smart-search-product-item:hover::before {
    opacity: 0.05;
}

/* Loading skeleton animation */
.wc-smart-search-skeleton {
    background: linear-gradient(90deg, var(--wc-smart-search-gray-200) 25%, var(--wc-smart-search-gray-100) 50%, var(--wc-smart-search-gray-200) 75%);
    background-size: 200% 100%;
    animation: wc-smart-search-skeleton 1.5s infinite;
}

@keyframes wc-smart-search-skeleton {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Accessibility improvements */
.wc-smart-search-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Advanced grid layouts for different screen sizes */
@media (min-width: 1400px) {
    .wc-smart-search-products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    .wc-smart-search-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .wc-smart-search-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Enhanced focus management */
.wc-smart-search-megamenu.active .wc-smart-search-input {
    /* Auto-focus handled by JavaScript */
}

/* Performance optimizations */
.wc-smart-search-product-image {
    contain: layout style paint;
}

.wc-smart-search-products-grid {
    contain: layout;
}

/* Enhanced mobile experience */
@media (max-width: 600px) {
    .wc-smart-search-container {
        margin: 0;
        border-radius: 0 0 var(--wc-smart-search-border-radius) var(--wc-smart-search-border-radius);
        max-height: 80vh;
    }
    
    .wc-smart-search-content {
        max-height: calc(80vh - 120px);
    }
    
    .wc-smart-search-products-grid {
        grid-template-columns: 1fr 1fr;
    }
}
