/**
 * Klifa Global Search Styles
 * חיפוש גלובלי מקצועי לסרגל העליון
 * 
 * @package Klifa_My_Account_Customizer
 * @since 1.4.0
 */

/* === Header Search Bar === */
.klifa-header-search-bar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 999;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.klifa-header-search-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e0e0e0;
    border-radius: 50px;
    cursor: pointer;
    pointer-events: all;
    font-family: 'Heebo', sans-serif;
    font-size: 14px;
    color: #888;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    direction: rtl;
}

.klifa-header-search-trigger:hover {
    border-color: var(--klifa-primary, #8B7355);
    box-shadow: 0 4px 20px rgba(139, 115, 85, 0.15);
    color: #555;
}

.klifa-header-search-trigger svg {
    fill: var(--klifa-primary, #8B7355);
    transition: transform 0.3s ease;
}

.klifa-header-search-trigger:hover svg {
    transform: scale(1.1);
}

.klifa-search-text {
    font-size: 13px;
}

.klifa-search-shortcut {
    padding: 2px 8px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 11px;
    color: #999;
    font-family: monospace;
}

/* Admin Bar Offset */
.admin-bar .klifa-header-search-bar {
    top: 32px;
}

/* Search Menu Item */
.klifa-search-menu-item a {
    display: flex !important;
    align-items: center;
    cursor: pointer;
}

.klifa-search-menu-item svg {
    fill: currentColor;
}

/* === Search Overlay === */
.klifa-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    justify-content: center;
    padding-top: 80px;
    opacity: 0;
    transition: opacity 0.3s ease;
    direction: rtl;
}

.klifa-search-overlay.klifa-search-active {
    opacity: 1;
}

.klifa-search-overlay-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.klifa-search-container {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 680px;
    max-height: calc(100vh - 160px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: klifa-search-slide-down 0.4s ease;
}

@keyframes klifa-search-slide-down {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Search Header */
.klifa-search-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.klifa-search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f5f5f5;
    border-radius: 14px;
    padding: 12px 16px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.klifa-search-input-wrapper:focus-within {
    background: #fff;
    border-color: var(--klifa-primary, #8B7355);
    box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.1);
}

.klifa-search-icon-svg {
    fill: #999;
    flex-shrink: 0;
    transition: fill 0.3s ease;
}

.klifa-search-input-wrapper:focus-within .klifa-search-icon-svg {
    fill: var(--klifa-primary, #8B7355);
}

.klifa-global-search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 17px;
    font-family: 'Heebo', sans-serif;
    color: #333;
    outline: none;
    direction: rtl;
}

.klifa-global-search-input::placeholder {
    color: #aaa;
}

.klifa-search-spinner {
    animation: klifa-spin 1s linear infinite;
}

.klifa-search-spinner svg {
    width: 20px;
    height: 20px;
    color: var(--klifa-primary, #8B7355);
}

@keyframes klifa-spin {
    to { transform: rotate(360deg); }
}

.klifa-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: #eee;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.klifa-search-close:hover {
    background: #ddd;
}

.klifa-search-close svg {
    fill: #666;
}

/* Search Results */
.klifa-search-results {
    overflow-y: auto;
    flex: 1;
    padding: 16px 24px;
}

/* Popular Searches */
.klifa-popular-searches h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #888;
    margin: 0 0 12px;
    font-weight: 500;
}

.klifa-popular-searches h4 svg {
    fill: var(--klifa-accent, #D4AF37);
}

.klifa-popular-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.klifa-popular-tag {
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    border-radius: 50px;
    font-size: 13px;
    font-family: 'Heebo', sans-serif;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
}

.klifa-popular-tag:hover {
    background: var(--klifa-primary, #8B7355);
    border-color: var(--klifa-primary, #8B7355);
    color: #fff;
}

/* Live Results */
.klifa-search-live-results {
    padding: 0;
}

.klifa-search-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    margin: 0 0 12px;
    letter-spacing: 0.5px;
}

/* Category Results */
.klifa-search-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.klifa-search-cat-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #f8f4f0;
    border: 1px solid #e8ddd3;
    border-radius: 50px;
    font-size: 13px;
    color: var(--klifa-primary, #8B7355);
    text-decoration: none;
    transition: all 0.2s ease;
}

.klifa-search-cat-link:hover {
    background: var(--klifa-primary, #8B7355);
    color: #fff;
    border-color: var(--klifa-primary, #8B7355);
}

.klifa-search-cat-count {
    font-size: 11px;
    color: #999;
}

.klifa-search-cat-link:hover .klifa-search-cat-count {
    color: rgba(255, 255, 255, 0.7);
}

/* Product Results */
.klifa-search-product-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.klifa-search-product-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    cursor: pointer;
}

.klifa-search-product-item:hover {
    background: #f8f4f0;
}

.klifa-search-product-img {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f5f5f5;
}

.klifa-search-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.klifa-search-product-info {
    flex: 1;
    min-width: 0;
}

.klifa-search-product-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.klifa-search-product-price {
    font-size: 14px;
    color: var(--klifa-primary, #8B7355);
    font-weight: 600;
}

.klifa-search-product-price del {
    color: #bbb;
    font-weight: 400;
    font-size: 12px;
}

.klifa-search-product-price ins {
    text-decoration: none;
    color: #e74c3c;
}

.klifa-search-product-stock {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

.klifa-search-product-stock.in-stock {
    background: #e8f5e9;
    color: #2e7d32;
}

.klifa-search-product-stock.out-of-stock {
    background: #fce4ec;
    color: #c62828;
}

.klifa-search-product-arrow {
    flex-shrink: 0;
    fill: #ccc;
    transition: fill 0.2s ease;
}

.klifa-search-product-item:hover .klifa-search-product-arrow {
    fill: var(--klifa-primary, #8B7355);
}

/* Show All Results */
.klifa-search-show-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
    background: var(--klifa-primary, #8B7355);
    color: #fff;
    border-radius: 12px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.klifa-search-show-all:hover {
    background: #6d5a42;
    color: #fff;
}

.klifa-search-show-all svg {
    fill: #fff;
}

/* No Results */
.klifa-search-no-results {
    text-align: center;
    padding: 40px 20px;
}

.klifa-search-no-results svg {
    fill: #ddd;
    margin-bottom: 12px;
}

.klifa-search-no-results p {
    color: #888;
    font-size: 15px;
}

/* Inline Search Shortcode */
.klifa-inline-search {
    display: inline-block;
}

.klifa-inline-search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Heebo', sans-serif;
    font-size: 14px;
    color: #888;
    transition: all 0.3s ease;
}

.klifa-inline-search-btn:hover {
    border-color: var(--klifa-primary, #8B7355);
    box-shadow: 0 2px 10px rgba(139, 115, 85, 0.15);
}

.klifa-inline-search-btn svg {
    fill: var(--klifa-primary, #8B7355);
}

/* === Responsive === */
@media (max-width: 768px) {
    .klifa-header-search-bar {
        position: fixed;
        bottom: 0;
        top: auto;
        right: 0;
        left: 0;
        background: rgba(255, 255, 255, 0.98);
        padding: 10px 16px;
        box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.06);
        z-index: 9998;
    }
    
    .klifa-header-search-trigger {
        width: 100%;
        margin-top: 0;
        justify-content: center;
        padding: 12px 20px;
        border-radius: 12px;
    }
    
    .klifa-search-shortcut {
        display: none;
    }
    
    .klifa-search-overlay {
        padding-top: 0;
    }
    
    .klifa-search-container {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        height: 100vh;
    }
    
    .klifa-search-product-item {
        padding: 8px;
    }
    
    .klifa-search-product-img {
        width: 48px;
        height: 48px;
    }
    
    /* מניעת כפילות עם תפריט מובייל */
    .klifa-has-mobile-nav .klifa-header-search-bar {
        bottom: 70px;
    }
    
    .admin-bar .klifa-header-search-bar {
        top: auto;
    }
}

@media (max-width: 480px) {
    .klifa-search-header {
        padding: 16px;
    }
    
    .klifa-search-results {
        padding: 12px 16px;
    }
    
    .klifa-global-search-input {
        font-size: 16px;
    }
}
