/* Search Megamenu - مانند تکنوسان */

/* کانتینر اصلی جستجو */
.search-megamenu-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* باکس جستجوی اصلی */
.search-input-wrapper {
    position: relative;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-input-wrapper.active {
    border-color: #3b82f6;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
    border-radius: 12px 12px 0 0;
}

/* فیلد جستجو */
.search-megamenu-input {
    width: 100%;
    border: none;
    outline: none;
    padding: 16px 60px 16px 20px;
    font-size: 16px;
    font-family: inherit;
    background: transparent;
    color: #1f2937;
}

.search-megamenu-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* دکمه جستجو */
.search-megamenu-btn {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #3b82f6;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-megamenu-btn:hover {
    background: #2563eb;
    transform: translateY(-50%) scale(1.05);
}

.search-megamenu-btn i {
    font-size: 18px;
}

/* مگامنوی جستجو - مانند تکنوسان */
.search-megamenu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 2px solid #3b82f6;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    max-height: 500px;
    overflow-y: auto;
}

.search-megamenu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* بخش برچسب‌های جستجو */
.search-tags-section {
    padding: 20px;
    border-bottom: 1px solid #f3f4f6;
}

.search-tags-title {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-tags-title i {
    font-size: 16px;
    color: #f59e0b;
}

.search-tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.search-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    justify-content: center;
}

.search-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.search-tag i {
    font-size: 14px;
}

/* بخش نتایج جستجو */
.search-results-section {
    padding: 20px;
    display: none;
}

.search-results-section.show {
    display: block;
}

.search-results-title {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-results-title i {
    font-size: 16px;
    color: #3b82f6;
}

.search-results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: #1f2937;
    border-radius: 8px;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f8fafc;
    color: #3b82f6;
    text-decoration: none;
    transform: translateX(5px);
}

.search-result-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #64748b;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.search-result-item:hover .search-result-icon {
    background: #dbeafe;
    color: #3b82f6;
}

.search-result-image {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    padding: 2px;
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-result-type {
    background: #e5e7eb;
    color: #374151;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
}

.search-result-price {
    font-weight: 600;
    color: #059669;
    font-size: 12px;
}

/* Loading و Empty States */
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    color: #6b7280;
    font-weight: 500;
}

.search-loading i {
    animation: spin 1s linear infinite;
    margin-left: 10px;
    font-size: 18px;
    color: #3b82f6;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.search-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.search-empty i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
    color: #9ca3af;
}

.search-empty div {
    font-weight: 500;
    font-size: 15px;
}

/* حالت موبایل */
@media (max-width: 768px) {
    .search-megamenu-container {
        max-width: 100%;
        margin: 0;
    }
    
    .search-input-wrapper {
        border-radius: 10px;
    }
    
    .search-input-wrapper.active {
        border-radius: 10px 10px 0 0;
    }
    
    .search-megamenu-input {
        padding: 14px 50px 14px 16px;
        font-size: 16px; /* جلوگیری از zoom در iOS */
    }
    
    .search-megamenu-btn {
        width: 40px;
        height: 40px;
        left: 6px;
    }
    
    .search-megamenu {
        border-radius: 0 0 10px 10px;
        max-height: 400px;
    }
    
    .search-tags-section {
        padding: 15px;
    }
    
    .search-tags-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .search-tag {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .search-results-section {
        padding: 15px;
    }
    
    .search-result-item {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .search-result-icon,
    .search-result-image {
        width: 35px;
        height: 35px;
    }
    
    .search-result-title {
        font-size: 13px;
    }
    
    .search-result-meta {
        font-size: 11px;
    }
}

/* انیمیشن‌های اضافی */
@keyframes searchPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.advanced-search-btn.searching {
    animation: searchPulse 1s infinite;
}

/* اسکرول بار سفارشی برای پیشنهادات */
.advanced-search-suggestions::-webkit-scrollbar {
    width: 6px;
}

.advanced-search-suggestions::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.advanced-search-suggestions::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.advanced-search-suggestions::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* حالت فوکوس برای accessibility */
.search-tag:focus,
.suggestion-item:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Loading state - Bootstrap Compatible */
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 25px 20px;
    color: #6b7280;
    font-weight: 500;
}

.search-loading i {
    animation: spin 1s linear infinite;
    margin-left: 10px;
    font-size: 18px;
    color: #3b82f6;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Empty state - Bootstrap Compatible */
.search-empty {
    text-align: center;
    padding: 30px 20px;
    color: #6b7280;
}

.search-empty i {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.4;
    color: #9ca3af;
}

.search-empty div {
    font-weight: 500;
    font-size: 15px;
}

/* Header integration - Bootstrap Compatible */
.header-center .advanced-search-container {
    width: 100%;
    max-width: 650px;
}

/* Mobile header integration */
.mobile-header {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 15px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.mobile-header .advanced-search-container {
    padding: 0 20px;
}

.mobile-header .search-tags-container {
    margin-top: 15px;
}

/* RTL Support */
[dir="rtl"] .advanced-search-input {
    padding: 16px 20px 16px 60px;
}

[dir="rtl"] .advanced-search-btn {
    left: auto;
    right: 8px;
}

[dir="rtl"] .suggestion-item {
    text-align: right;
}

/* Dark mode support (اختیاری) */
@media (prefers-color-scheme: dark) {
    .advanced-search-box {
        background: #1f2937;
        border-color: #374151;
    }
    
    .advanced-search-input {
        color: #f9fafb;
    }
    
    .advanced-search-input::placeholder {
        color: #6b7280;
    }
    
    .advanced-search-suggestions {
        background: #1f2937;
        border-color: #374151;
    }
    
    .suggestion-item {
        color: #f9fafb;
        border-color: #374151;
    }
    
    .suggestion-item:hover {
        background: #374151;
    }
}