/* =================================================================
   SEARCH FUNCTIONALITY STYLES
   ================================================================= */

/* Floating Search Button */
.floating-search-btn {
    position: fixed;
    bottom: 20px;
    right: 100px;
    /* Positioned next to cart button (cart is at right: 20px) */
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3),
        0 2px 6px rgba(0, 0, 0, 0.1);
    z-index: 9998;
    /* Below cart */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: pulse 2s infinite;
}

.floating-search-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(26, 84, 144, 0.4);
    animation: none;
}

.floating-search-btn:active {
    transform: scale(0.95);
}

/* Pulse Animation */
@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 4px 12px rgba(26, 84, 144, 0.3);
    }

    50% {
        box-shadow: 0 4px 20px rgba(26, 84, 144, 0.5);
    }
}

/* Tooltip */
.floating-search-btn::before {
    content: 'Search';
    position: absolute;
    right: 70px;
    background: var(--bg-dark);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.floating-search-btn:hover::before {
    opacity: 1;
}

/* Search Modal Overlay */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    padding: var(--space-xl);
    overflow-y: auto;
}

.search-modal.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 10vh;
}

/* Search Container */
.search-container {
    width: 100%;
    max-width: 700px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2xl);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search Header */
.search-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.search-input-wrapper {
    flex: 1;
    position: relative;
}

.search-input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-lg);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    border-color: var(--primary);
}

.search-close-btn {
    background: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, color 0.3s ease;
}

.search-close-btn:hover {
    background: var(--error);
    color: white;
}

/* Search Results Container */
.search-results {
    padding: var(--space-lg);
    max-height: 60vh;
    overflow-y: auto;
}

/* Search Hint */
.search-hint {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-2xl);
    font-size: var(--font-size-md);
}

/* No Results */
.no-results {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
}

.no-results p {
    margin-bottom: var(--space-md);
}

.no-results p:first-child {
    font-size: var(--font-size-lg);
    color: var(--text-primary);
}

.no-results .text-muted {
    color: var(--text-muted);
    font-size: var(--font-size-md);
}

/* Search Category */
.search-category {
    margin-bottom: var(--space-xl);
}

.search-category:last-child {
    margin-bottom: 0;
}

.search-category-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-light);
}

.search-category-results {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

/* Search Result Item */
.search-result-item {
    display: block;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease, transform 0.2s ease;
}

.search-result-item:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
}

.search-result-title {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    font-size: var(--font-size-md);
}

.search-result-description {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

/* Highlight matched text */
.search-result-item mark,
.search-results mark {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 0 0.2em;
    border-radius: 2px;
    font-weight: var(--font-weight-semibold);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {

    /* Mobile Responsive */
    .floating-search-btn {
        width: 56px;
        height: 56px;
        font-size: 1.3rem;
        bottom: 80px;
        /* Above potential mobile nav */
        right: 16px;
        /* Back to right edge on mobile, cart appears below */
    }

    .floating-search-btn::before {
        right: 60px;
        font-size: 12px;
        padding: 6px 10px;
    }

    .search-modal {
        padding: 0;
    }

    .search-modal.active {
        padding-top: 0;
    }

    .search-container {
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
    }

    .search-results {
        max-height: calc(100vh - 120px);
    }

    .search-btn-text {
        display: none;
    }
}

/* Desktop Search Button with Text */
@media (min-width: 768px) {
    .search-btn {
        padding: var(--space-sm) var(--space-md);
        background: var(--bg-secondary);
        border-radius: var(--radius-md);
    }

    .search-btn:hover {
        background: var(--primary-light);
    }
}

/* Keyboard Navigation Highlight */
.search-result-item:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}