/* Elemerce Product Search Widget Styles */

/* Base Search Container */
.elemerce-product-search {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 600px;
}

/* Search Form */
.elemerce-search-form {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #e8ecef;
    border-radius: 50px;
    overflow: hidden;
    transition: all 0.3s ease;
    height: 56px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Search Wrapper */
.elemerce-search-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
    gap: 4px;
    padding: 0 4px;
}

/* Category Filter Dropdown */
.elemerce-category-filter {
    background: #f8f9fa;
    border: 1px solid #e8ecef;
    border-radius: 25px;
    padding: 8px 15px;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 35px;
}

.elemerce-category-filter:focus {
    /* Removed focus border and box-shadow */
    background: #ffffff;
}

/* Search Input */
.elemerce-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: #495057;
    padding: 15px 20px;
    height: 100%;
    font-weight: 400;
}

.elemerce-search-input::placeholder {
    color: #adb5bd;
    font-style: normal;
    font-weight: 400;
}

.elemerce-search-input:focus {
    outline: none;
    color: #212529;
}

/* Search Icon */
.elemerce-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 18px;
    pointer-events: none;
    transition: color 0.3s ease;
}

.elemerce-search-icon.icon-left {
    margin-left: 10px;
    margin-right: 5px;
}

.elemerce-search-icon.icon-right {
    margin-left: 5px;
    margin-right: 10px;
}

/* Removed focus color change for search icon */

/* Search Button */
.elemerce-search-button {
    background: linear-gradient(135deg, #ff4757 0%, #e03e4a 100%);
    color: #fff;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    white-space: nowrap;
    height: calc(100% - 4px);
    margin: 2px;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
}

/* Remove margin completely when padding controls are set to 0 */
.elemerce-search-button[style*="padding: 0"] {
    margin: 0;
    height: 100%;
}

/* Additional button styles for different padding scenarios */
.elemerce-search-button.no-margin {
    margin: 0;
    height: 100%;
}

.elemerce-search-button:active {
    transform: translateY(0);
}

/* Button Position Styles */
.elemerce-search-form.button-outside {
    border-radius: 25px 0 0 25px;
}

.elemerce-search-form.button-outside .elemerce-search-button {
    border-radius: 0 25px 25px 0;
    margin: 0;
    height: 100%;
}

/* Fix for zero padding scenarios */
.elemerce-search-form .elemerce-search-button[style*="padding:0"],
.elemerce-search-form .elemerce-search-button[style*="padding: 0"] {
    margin: 0 !important;
    height: 100% !important;
    border-radius: 0 25px 25px 0;
}

/* Fix for very small padding scenarios */
.elemerce-search-form .elemerce-search-button[style*="padding:1px"],
.elemerce-search-form .elemerce-search-button[style*="padding: 1px"],
.elemerce-search-form .elemerce-search-button[style*="padding:2px"],
.elemerce-search-form .elemerce-search-button[style*="padding: 2px"] {
    margin: 1px !important;
    height: calc(100% - 2px) !important;
}

/* Search Results */
.elemerce-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 5px;
}

.elemerce-search-results:empty {
    display: none !important;
}

/* Search Result Item */
.elemerce-search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.elemerce-search-result-item:hover {
    background-color: #f8f9fa;
}

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

/* Product Image in Results */
.elemerce-search-result-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
}

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

/* Product Info in Results */
.elemerce-search-result-info {
    flex: 1;
    min-width: 0;
}

.elemerce-search-result-title {
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
    font-size: 14px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.elemerce-search-result-price {
    font-size: 13px;
    color: #ff4757;
    font-weight: 500;
}

.elemerce-search-result-sku {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

/* Loading State */
.elemerce-search-loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* No Results */
.elemerce-search-no-results {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Search Style Variations */

/* Classic Style */
.search-style-classic .elemerce-search-form {
    border-radius: 4px;
    border: 2px solid #ddd;
}

.search-style-classic .elemerce-search-button {
    border-radius: 2px;
}

/* Modern Style */
.search-style-modern .elemerce-search-form {
    border-radius: 30px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.search-style-modern .elemerce-search-button {
    border-radius: 25px;
}

/* Minimal Style */
.search-style-minimal .elemerce-search-form {
    border: none;
    border-bottom: 2px solid #e0e0e0;
    border-radius: 0;
    background: transparent;
}

.search-style-minimal .elemerce-search-form:focus-within {
    /* Removed red border for minimal style */
    box-shadow: none;
}

.search-style-minimal .elemerce-search-button {
    border-radius: 0;
    background: transparent;
    color: #ff4757;
    border-bottom: 2px solid #ff4757;
}

.search-style-minimal .elemerce-search-button:hover {
    background: #ff4757;
    color: #fff;
}

/* Outlined Style */
.search-style-outlined .elemerce-search-form {
    border: 2px solid #ff4757;
    border-radius: 25px;
    background: transparent;
}

.search-style-outlined .elemerce-search-button {
    background: transparent;
    color: #ff4757;
    border: 1px solid #ff4757;
}

.search-style-outlined .elemerce-search-button:hover {
    background: #ff4757;
    color: #fff;
}

/* Responsive Design */

/* Tablet */
@media (max-width: 768px) {
    .elemerce-search-form {
        height: 48px;
    }
    
    .elemerce-search-input {
        font-size: 16px;
        padding: 10px 12px;
    }
    
    .elemerce-search-button {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .elemerce-search-icon {
        font-size: 14px;
    }
    
    .elemerce-search-result-item {
        padding: 10px 12px;
    }
    
    .elemerce-search-result-image {
        width: 45px;
        height: 45px;
        margin-right: 10px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .elemerce-search-form {
        height: 46px;
    }
    
    .elemerce-search-input {
        font-size: 16px;
        padding: 8px 10px;
    }
    
    .elemerce-search-button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .elemerce-search-icon.icon-left {
        margin-left: 10px;
        margin-right: 8px;
    }
    
    .elemerce-search-icon.icon-right {
        margin-left: 8px;
        margin-right: 10px;
    }
    
    .elemerce-search-result-item {
        padding: 8px 10px;
    }
    
    .elemerce-search-result-image {
        width: 40px;
        height: 40px;
        margin-right: 8px;
    }
    
    .elemerce-search-result-title {
        font-size: 13px;
    }
    
    .elemerce-search-result-price {
        font-size: 12px;
    }
}

/* RTL Support */
.rtl .elemerce-search-icon.icon-left {
    margin-left: 10px;
    margin-right: 15px;
}

.rtl .elemerce-search-icon.icon-right {
    margin-left: 15px;
    margin-right: 10px;
}

.rtl .elemerce-search-result-image {
    margin-right: 0;
    margin-left: 12px;
}

/* High DPI Displays */
@media (min-resolution: 192dpi) {
    .elemerce-search-form {
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
    }
    
    .elemerce-search-results {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    }
}

/* Focus States for Accessibility */
.elemerce-search-button:focus {
    /* Removed red outline */
    outline: none;
}

.elemerce-search-result-item:focus {
    /* Removed red outline */
    outline: none;
}

/* Enhanced Mobile Responsive Styles */
@media (max-width: 480px) {
    .elemerce-search-form {
        flex-direction: column;
        height: auto;
        padding: 8px;
        gap: 8px;
    }
    
    .elemerce-search-wrapper {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .elemerce-category-filter {
        width: 100% !important;
        order: 1;
    }
    
    .elemerce-search-input {
        order: 2;
        width: 100%;
        padding: 12px 15px;
    }
    
    .elemerce-search-button {
        order: 3;
        width: 100%;
        margin: 0;
        height: 44px;
        border-radius: 25px;
    }
    
    .elemerce-search-icon {
        order: 2;
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
    }
}

/* Tablet Responsive Styles */
@media (max-width: 768px) and (min-width: 481px) {
    .elemerce-search-wrapper {
        gap: 6px;
    }
    
    .elemerce-category-filter {
        min-width: 120px;
    }
    
    .elemerce-search-input {
        padding: 12px 15px;
    }
}

/* Enhanced Category Filter Styles */
.elemerce-category-filter:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
    transform: translateY(-1px);
}

.elemerce-category-filter:focus {
    background: #ffffff;
    transform: translateY(-1px);
}

/* Modern Gradient Button Variations */
.elemerce-search-button.gradient-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.elemerce-search-button.gradient-green {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.elemerce-search-button.gradient-purple {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Loading Animation Enhancement */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.elemerce-search-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Enhanced Search Results */
.elemerce-search-results {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.elemerce-search-result-item:hover {
    transform: translateX(5px);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .elemerce-search-form {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .elemerce-search-input {
        color: #e2e8f0;
    }
    
    .elemerce-search-input::placeholder {
        color: #a0aec0;
    }
    
    .elemerce-category-filter {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .elemerce-search-results {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .elemerce-search-result-item {
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .elemerce-search-result-item:hover {
        background: #4a5568;
    }
}

/* Advanced Search Bar Styles */
.elemerce-product-search.bar-style-classic .elemerce-search-form {
    border-radius: 4px;
    border-width: 1px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
}

.elemerce-product-search.bar-style-modern .elemerce-search-form {
    border-radius: 50px;
    border-width: 2px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    background: linear-gradient(145deg, #ffffff 0%, #fafbfc 100%);
}

.elemerce-product-search.bar-style-minimal .elemerce-search-form {
    border-radius: 0;
    border-width: 0;
    border-bottom: 3px solid #e8ecef;
    box-shadow: none;
    background: transparent;
}

.elemerce-product-search.bar-style-minimal .elemerce-search-form:focus-within {
    /* Removed red border for bar-style-minimal */
    background: linear-gradient(180deg, transparent 0%, rgba(255, 71, 87, 0.02) 100%);
}

.elemerce-product-search.bar-style-rounded .elemerce-search-form {
    border-radius: 30px;
    border-width: 2px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    background: linear-gradient(145deg, #ffffff 0%, #f1f3f4 100%);
}

/* Enhanced Animation Effects */
.elemerce-product-search.animations-enabled * {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.elemerce-product-search.animations-enabled .elemerce-search-form {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.elemerce-product-search.animations-enabled .elemerce-search-results {
    animation: slideDownFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.elemerce-product-search.animations-enabled .elemerce-search-result-item {
    animation: slideInRight 0.3s ease-out;
    animation-fill-mode: both;
}

.elemerce-product-search.animations-enabled .elemerce-search-result-item:nth-child(1) { animation-delay: 0.05s; }
.elemerce-product-search.animations-enabled .elemerce-search-result-item:nth-child(2) { animation-delay: 0.1s; }
.elemerce-product-search.animations-enabled .elemerce-search-result-item:nth-child(3) { animation-delay: 0.15s; }
.elemerce-product-search.animations-enabled .elemerce-search-result-item:nth-child(4) { animation-delay: 0.2s; }

@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Enhanced Button Gradient Styles */
.elemerce-search-button.gradient-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.elemerce-search-button.gradient-green {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
}

.elemerce-search-button.gradient-purple {
    background: linear-gradient(135deg, #a855f7 0%, #e879f9 100%);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

/* Enhanced Category Filter Styling */
.elemerce-category-filter {
    background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid transparent;
    background-clip: padding-box;
    position: relative;
}

.elemerce-category-filter::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, #e8ecef, #dee2e6);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
}

.elemerce-category-filter:focus {
    /* Removed red border and box-shadow */
    background: linear-gradient(145deg, #ffffff 0%, #fafbfc 100%);
    outline: none;
}

/* Enhanced Search Results */
.elemerce-search-results {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.elemerce-search-result-item {
    position: relative;
    overflow: hidden;
}

.elemerce-search-result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 71, 87, 0.1), transparent);
    transition: left 0.5s;
}

.elemerce-search-result-item:hover::before {
    left: 100%;
}

.elemerce-search-result-title mark {
    background: linear-gradient(135deg, #ff4757 0%, #ff6b7d 100%);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* Enhanced Loading States */
.elemerce-search-loading {
    position: relative;
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

.elemerce-search-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ff4757;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Advanced Image Hover Effects */
.elemerce-search-result-image {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.image-hover-zoom .elemerce-search-result-image:hover {
    transform: scale(1.1);
}

.image-hover-rotate .elemerce-search-result-image:hover {
    transform: rotate(5deg) scale(1.05);
}

.image-hover-fade .elemerce-search-result-image:hover {
    opacity: 0.7;
}

/* Custom Scrollbar Styling */
.elemerce-search-results::-webkit-scrollbar {
    width: 6px;
}

.elemerce-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.elemerce-search-results::-webkit-scrollbar-thumb {
    background: #ff4757;
    border-radius: 10px;
    background-clip: padding-box;
}

.elemerce-search-results::-webkit-scrollbar-thumb:hover {
    background: #e63946;
}

/* Advanced Results Layout */
.elemerce-search-results {
    display: flex;
    flex-direction: column;
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
    .elemerce-product-search .elemerce-search-form {
        min-height: 45px;
    }
    
    .elemerce-search-input {
        font-size: 14px;
        padding: 8px 12px;
    }
    
    .elemerce-search-button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .elemerce-category-filter {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .elemerce-search-result-item {
        padding: 8px;
    }
    
    .elemerce-search-result-image {
        width: 45px !important;
        height: 45px !important;
    }
    
    .elemerce-search-result-title {
        font-size: 13px;
    }
    
    .elemerce-search-result-price {
        font-size: 12px;
    }
}

/* Elementor Button Padding Override System */
/* This system ensures that when padding is set to 0 via Elementor controls, 
   the button properly aligns with the border */

/* Target button with zero padding */
.elemerce-search-button[style*="padding: 0px"],
.elemerce-search-button[style*="padding:0px"],
.elemerce-search-button[style*="padding: 0"],
.elemerce-search-button[style*="padding:0"] {
    margin: 0 !important;
    height: 100% !important;
    border-radius: 0 25px 25px 0 !important;
}

/* Target button with very small padding (1-3px) */
.elemerce-search-button[style*="padding: 1px"],
.elemerce-search-button[style*="padding: 2px"],
.elemerce-search-button[style*="padding: 3px"] {
    margin: 1px !important;
    height: calc(100% - 2px) !important;
}

/* Target wrapper with zero gap/padding */
.elemerce-search-wrapper[style*="gap: 0"],
.elemerce-search-wrapper[style*="padding: 0"] {
    gap: 0 !important;
    padding: 0 !important;
}

/* Special class for no-margin button (can be added via JS if needed) */
.elemerce-search-form .elemerce-search-button.elemerce-no-margin {
    margin: 0 !important;
    height: 100% !important;
    border-radius: 0 25px 25px 0 !important;
}

/* Form level overrides for tight layouts */
.elemerce-search-form.elemerce-tight-layout {
    padding: 0;
}

.elemerce-search-form.elemerce-tight-layout .elemerce-search-wrapper {
    gap: 0;
    padding: 0;
}

.elemerce-search-form.elemerce-tight-layout .elemerce-search-button {
    margin: 0;
    height: 100%;
    border-radius: 0 25px 25px 0;
}

@media (max-width: 480px) {
    .elemerce-product-search .elemerce-search-form {
        flex-direction: column;
        gap: 8px;
    }
    
    .elemerce-search-input {
        border-radius: 20px !important;
    }
    
    .elemerce-search-button {
        border-radius: 20px !important;
        width: 100%;
    }
    
    .elemerce-category-filter {
        border-radius: 20px !important;
        width: 100%;
    }
    
    .elemerce-search-results {
        margin-top: 5px;
    }
}

/* Performance Optimizations */
.elemerce-product-search * {
    will-change: auto;
}

.elemerce-product-search.animations-enabled * {
    will-change: transform, opacity;
}

/* Accessibility Enhancements */
.elemerce-search-input:focus,
.elemerce-category-filter:focus,
.elemerce-search-button:focus {
    /* Removed red outline for accessibility - replace with subtle outline if needed */
    outline: none;
}

.elemerce-search-result-item:focus {
    outline: 2px solid #ff4757;
    outline-offset: 1px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .elemerce-search-form {
        border-width: 2px !important;
        border-color: #000 !important;
    }
    
    .elemerce-search-button {
        background: #000 !important;
        color: #fff !important;
        border: 2px solid #000 !important;
    }
    
    .elemerce-search-results {
        border: 2px solid #000 !important;
        background: #fff !important;
    }
}
