/**
 * Product Search Block - Frontend Styles
 */

.product-search-block {
    --search-bg: #ffffff;
    --search-border: #e5e7eb;
    --search-border-focus: #3b82f6;
    --search-text: #1f2937;
    --search-placeholder: #9ca3af;
    --search-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --search-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --result-hover: #f9fafb;
    --accent-color: #045fa4;
    
    position: relative;
    width: 100%;
    max-width: 480px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.product-search-wrapper {
    position: relative;
    width: 100%;
}

/* Input Container */
.product-search-input-container {
    display: flex;
    align-items: center;
    background: none;
    border: solid 1px #ddd;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.product-search-input-container:focus-within {
    border-color: var(--search-border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Input Field */
.product-search-input {
    flex: 1;
    padding: 14px 16px;
    border: none !important;
    box-shadow: none !important;
    background: transparent;
    font-size: 14px !important;
    color: var(--search-text);
    outline: none;
    min-width: 0;
}

.product-search-input::placeholder {
    color: var(--search-placeholder);
}

/* Search Button */
.product-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--search-placeholder);
    cursor: pointer;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.product-search-btn:hover {
    background-color: transparent !important;
    color: var(--accent-color);
}

.product-search-btn svg {
    width: 20px;
    height: 20px;
}

/* Results Container */
.product-search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: 420px;
    min-width: 100%;
    background: #fff !important;
    border-radius: 12px;
    box-shadow: var(--search-shadow-lg);
    border: none !important;
    max-height: 400px;
    overflow-y: auto;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

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

/* Loading State */
.product-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 10px;
    color: var(--search-placeholder);
    font-size: 14px;
    background: #fff !important;
}

.product-search-loading::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid var(--search-border);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: search-spin 0.8s linear infinite;
}

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

/* No Results */
.product-search-no-results {
    padding: 24px;
    text-align: center;
    color: var(--search-placeholder);
    font-size: 14px;
    background: #fff !important;
}

/* Result Item */
.product-search-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
    border: none !important; 
    background: #fff !important;
}

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

.product-search-item:hover,
.product-search-item:focus {
    background: var(--result-hover);
    outline: none;
}

/* Result Image */
.product-search-item-image {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.product-search-item-image svg {
    width: 24px;
    height: 24px;
    color: #d1d5db;
}

/* Result Content */
.product-search-item-content {
    flex: 1;
    min-width: 0;
}

.product-search-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #23282d !important;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-search-item-excerpt {
    font-size: 13px;
    color: var(--search-placeholder);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

/* View All Link */
.product-search-view-all {
    display: block;
    padding: 14px 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-color);
    text-decoration: none;
    background: #fff !important;
    border-top: 1px solid #ddd !important;
    transition: background 0.15s ease;
}

.product-search-view-all:hover {
    background: #f3f4f6;
    text-decoration: none;
}

/* Responsive */
@media (max-width: 480px) {
    .product-search-block {
        max-width: 100%;
    }
    
    .product-search-input {
        padding: 12px 14px;
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    .product-search-btn {
        width: 44px;
        height: 44px;
    }
    
    .product-search-item {
        padding: 10px 14px;
    }
    
    .product-search-item-image {
        width: 48px;
        height: 48px;
    }
    
    .product-search-results {
        width: 100%;
        min-width: 280px;
        left: 0;
        right: 0;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .product-search-results {
        width: 350px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .product-search-block {
        --search-bg: #1f2937;
        --search-border: #374151;
        --search-border-focus: #60a5fa;
        --search-text: #f9fafb;
        --search-placeholder: #9ca3af;
        --result-hover: #374151;
    }
    
    .product-search-item-image {
        background: #374151;
    }
    
    .product-search-view-all {
        background: #111827;
    }
    
    .product-search-view-all:hover {
        background: #1f2937;
    }
}

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

.product-search-results::-webkit-scrollbar-track {
    background: transparent;
}

.product-search-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.product-search-results::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}
