/**
 * SearchBarWidget Styles
 *
 * Sections:
 * 1. Base widget styles
 * 2. Input and form
 * 3. Tabs
 * 4. Dropdown panel
 * 5. Result groups and items
 * 6. Text highlighting
 * 7. Loading skeleton
 * 8. Empty state (recent + popular)
 * 9. Dropdown footer
 * 10. Clear & back buttons
 * 11. Rotating placeholder animation
 * 12. Mobile overlay
 * 13. Dark theme overrides
 */

/* =============================================================================
   1. BASE WIDGET STYLES
   ============================================================================= */

.search-bar-widget {
    position: relative;
}

.search-bar-hero {
    max-width: 800px;
    margin: 0 auto;
}

.search-bar-hero .search-bar-tabs {
    max-width: none;
    flex-wrap: nowrap;
}

.search-bar-wide {
    max-width: none;
}

@media (max-width: 767.98px) {
    .search-bar-hero .search-bar-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        justify-content: flex-start;
    }

    .search-bar-hero .search-bar-tabs::-webkit-scrollbar {
        display: none;
    }

    .search-bar-hero .search-bar-tabs .search-bar-tab {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .search-bar-tab {
        font-size: 0.75rem;
        padding: 0.25rem 0.625rem;
    }

    .search-bar-tab i {
        font-size: 0.625rem;
    }
}

.search-bar-compact .search-bar-input-wrapper {
    max-width: none;
}

.search-bar-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* =============================================================================
   2. INPUT AND FORM
   ============================================================================= */

.search-bar-input-wrapper {
    position: relative;
}

.search-bar-hero .search-bar-input {
    padding: 1rem 3.5rem 1rem 1.25rem;
    font-size: 1.125rem;
    border-radius: var(--radius-lg, 0.5rem);
    border: 2px solid var(--border-color, #dee2e6);
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #212529);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar-hero .search-bar-input:focus {
    border-color: var(--color-primary-500, #3aa8e0);
    box-shadow: 0 0 0 0.2rem rgba(58, 168, 224, 0.15);
}

.search-bar-compact .search-bar-input {
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    border-radius: var(--radius-md, 0.375rem);
    border: 1px solid var(--border-color, #dee2e6);
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #212529);
}

.search-bar-inline .search-bar-input {
    padding: 0.625rem 3rem 0.625rem 1rem;
    border-radius: var(--radius-md, 0.375rem);
    border: 1px solid var(--border-color, #dee2e6);
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #212529);
}

.search-bar-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted, #6c757d);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.125rem;
    transition: color 0.2s;
    z-index: 2;
}

.search-bar-btn:hover {
    color: var(--color-primary-500, #3aa8e0);
}

/* =============================================================================
   3. TABS
   ============================================================================= */

.search-bar-tabs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.search-bar-tab {
    padding: 0.375rem 1rem;
    border-radius: var(--radius-full, 50rem);
    border: 1px solid var(--border-color, #dee2e6);
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #6c757d);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.search-bar-tab i {
    font-size: 0.75rem;
}

.search-bar-tab:hover,
.search-bar-tab.active {
    background: var(--color-primary-500, #3aa8e0);
    border-color: var(--color-primary-500, #3aa8e0);
    color: #fff;
}

/* =============================================================================
   4. DROPDOWN PANEL
   ============================================================================= */

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: var(--radius-xl, 0.75rem);
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0,0,0,0.1));
    z-index: var(--z-dropdown, 10);
    max-height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
    text-align: left;

    /* Slide-down animation */
    opacity: 0;
    transform: translateY(-8px);
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

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

/* Scrollbar styling */
.search-dropdown::-webkit-scrollbar {
    width: 6px;
}

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

.search-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-color, #dee2e6);
    border-radius: 3px;
}

/* =============================================================================
   5. RESULT GROUPS AND ITEMS
   ============================================================================= */

.search-result-group {
    padding: 0.5rem 0;
}

.search-result-group + .search-result-group {
    border-top: 1px solid var(--border-muted, #e9ecef);
}

.search-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.375rem 1rem;
}

.search-result-header-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6c757d);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.search-result-header-label i {
    font-size: 0.625rem;
}

.search-see-all {
    font-size: 0.75rem;
    color: var(--color-primary-500, #3aa8e0);
    text-decoration: none;
    font-weight: 500;
}

.search-see-all:hover {
    color: var(--color-primary-700, #1d74a3);
    text-decoration: underline;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-primary, #212529);
    cursor: pointer;
    transition: background-color 0.15s;
    border-radius: var(--radius-md, 0.375rem);
    margin: 0 0.5rem;
}

.search-result-item:hover,
.search-result-item.is-highlighted {
    background: var(--bg-secondary, #f8f9fa);
    color: var(--text-primary, #212529);
    text-decoration: none;
}

.search-result-thumb-wrap {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.search-result-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md, 0.375rem);
    object-fit: cover;
    background: var(--bg-secondary, #f8f9fa);
}

.search-result-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md, 0.375rem);
    background: var(--bg-secondary, #f8f9fa);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #6c757d);
    font-size: 1rem;
}

.search-result-info {
    min-width: 0;
    flex: 1;
}

.search-result-title {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted, #6c757d);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =============================================================================
   6. TEXT HIGHLIGHTING
   ============================================================================= */

.search-highlight {
    background: var(--color-primary-100, #d5eefb);
    color: var(--color-primary-800, #1c5f86);
    border-radius: 2px;
    padding: 0 1px;
}

/* =============================================================================
   7. LOADING SKELETON
   ============================================================================= */

.search-loading {
    padding: 0.75rem;
}

.search-skeleton-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
}

.search-skeleton-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md, 0.375rem);
    background: var(--bg-secondary, #f8f9fa);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.search-skeleton-text {
    flex: 1;
}

.search-skeleton-line {
    border-radius: var(--radius-sm, 0.125rem);
    background: var(--bg-secondary, #f8f9fa);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.search-skeleton-title {
    width: 60%;
    height: 14px;
    margin-bottom: 6px;
}

.search-skeleton-sub {
    width: 40%;
    height: 10px;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* =============================================================================
   8. EMPTY STATE (RECENT SEARCHES + POPULAR)
   ============================================================================= */

.search-empty-state {
    padding: 0.75rem;
}

/* Recent searches */
.search-recent-section {
    margin-bottom: 0.5rem;
}

.search-recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.5rem 0.5rem;
}

.search-recent-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6c757d);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.search-recent-label i {
    font-size: 0.625rem;
}

.search-recent-clear {
    font-size: 0.75rem;
    color: var(--text-muted, #6c757d);
    text-decoration: none;
}

.search-recent-clear:hover {
    color: var(--color-danger, #dc3545);
}

.search-recent-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem;
    text-decoration: none;
    color: var(--text-primary, #212529);
    cursor: pointer;
    border-radius: var(--radius-md, 0.375rem);
    transition: background-color 0.15s;
    font-size: 0.875rem;
}

.search-recent-item > i {
    color: var(--text-muted, #6c757d);
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}

.search-recent-item span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-recent-item:hover,
.search-recent-item.is-highlighted {
    background: var(--bg-secondary, #f8f9fa);
    color: var(--text-primary, #212529);
    text-decoration: none;
}

.search-recent-remove {
    background: none;
    border: none;
    padding: 0.125rem 0.25rem;
    color: var(--text-muted, #6c757d);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    font-size: 0.625rem;
}

.search-recent-item:hover .search-recent-remove {
    opacity: 1;
}

.search-recent-remove:hover {
    color: var(--color-danger, #dc3545);
}

/* Popular categories */
.search-popular-section {
    padding: 0.25rem 0.5rem;
}

.search-popular-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6c757d);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.search-popular-label i {
    font-size: 0.625rem;
    color: var(--color-warning, #ffc107);
}

.search-popular-tags {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.search-popular-tag {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full, 50rem);
    background: var(--bg-secondary, #f8f9fa);
    color: var(--text-secondary, #6c757d);
    font-size: 0.8125rem;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.search-popular-tag:hover {
    background: var(--color-primary-50, #eef8fd);
    color: var(--color-primary-600, #2490c8);
    border-color: var(--color-primary-200, #b0dff7);
}

/* No results */
.search-no-results {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-muted, #6c757d);
}

.search-no-results i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
    opacity: 0.5;
}

.search-no-results p {
    margin: 0;
    font-size: 0.875rem;
}

/* =============================================================================
   9. DROPDOWN FOOTER
   ============================================================================= */

.search-dropdown-footer {
    border-top: 1px solid var(--border-muted, #e9ecef);
    padding: 0.75rem 1rem;
}

.search-footer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--color-primary-500, #3aa8e0);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s;
}

.search-footer-link:hover {
    color: var(--color-primary-700, #1d74a3);
}

.search-footer-link i {
    font-size: 0.75rem;
}

/* =============================================================================
   10. CLEAR & BACK BUTTONS
   ============================================================================= */

.search-bar-clear-btn {
    position: absolute;
    right: 2.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.25rem;
    color: var(--text-muted, #6c757d);
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, color 0.15s, visibility 0.15s;
    z-index: 2;
}

.search-bar-clear-btn.is-visible {
    opacity: 1;
    visibility: visible;
}

.search-bar-clear-btn:hover {
    color: var(--text-primary, #212529);
}

.search-bar-back-btn {
    display: none;
}

/* =============================================================================
   11. ROTATING PLACEHOLDER ANIMATION
   ============================================================================= */

.search-bar-input.placeholder-fade-out::placeholder {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-bar-input.placeholder-fade-in::placeholder {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.search-bar-input::placeholder {
    transition: opacity 0.3s ease;
}

/* =============================================================================
   12. MOBILE OVERLAY
   ============================================================================= */

@media (max-width: 767.98px) {
    .search-bar-widget.is-mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: var(--z-overlay, 40);
        background: var(--bg-primary, #fff);
        padding: 1rem;
        display: flex;
        flex-direction: column;
    }

    .search-bar-widget.is-mobile-overlay .search-bar-tabs {
        order: -1;
        margin-bottom: 0.75rem !important;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .search-bar-widget.is-mobile-overlay .search-bar-tabs::-webkit-scrollbar {
        display: none;
    }

    .search-bar-widget.is-mobile-overlay .search-bar-tabs .search-bar-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .search-bar-widget.is-mobile-overlay .search-bar-input-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .search-bar-widget.is-mobile-overlay .search-bar-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        left: 0.5rem;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        padding: 0.5rem;
        color: var(--text-primary, #212529);
        cursor: pointer;
        font-size: 1.125rem;
        z-index: 3;
    }

    .search-bar-widget.is-mobile-overlay .search-bar-input {
        padding-left: 2.75rem;
    }

    .search-bar-widget.is-mobile-overlay .search-dropdown {
        position: relative;
        top: auto;
        margin-top: 0.75rem;
        border: none;
        box-shadow: none;
        border-radius: 0;
        max-height: none;
        flex: 1;
        overflow-y: auto;
    }

    body.search-mobile-active {
        overflow: hidden;
    }
}

/* =============================================================================
   13. DARK THEME OVERRIDES
   ============================================================================= */

[data-theme="dark"] .search-bar-input {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .search-bar-tab {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .search-bar-tab:hover,
[data-theme="dark"] .search-bar-tab.active {
    background: var(--color-primary-500);
    border-color: var(--color-primary-500);
    color: #fff;
}

[data-theme="dark"] .search-dropdown {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .search-result-item:hover,
[data-theme="dark"] .search-result-item.is-highlighted {
    background: var(--bg-secondary);
}

[data-theme="dark"] .search-result-icon {
    background: var(--bg-tertiary, var(--bg-secondary));
    color: var(--text-muted);
}

[data-theme="dark"] .search-result-thumb {
    background: var(--bg-tertiary, var(--bg-secondary));
}

[data-theme="dark"] .search-result-group + .search-result-group {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .search-highlight {
    background: var(--color-primary-900, #1c4f6f);
    color: var(--color-primary-200, #b0dff7);
}

[data-theme="dark"] .search-skeleton-thumb,
[data-theme="dark"] .search-skeleton-line {
    background: var(--bg-secondary);
}

[data-theme="dark"] .search-recent-item:hover,
[data-theme="dark"] .search-recent-item.is-highlighted {
    background: var(--bg-secondary);
}

[data-theme="dark"] .search-popular-tag {
    background: var(--bg-tertiary, var(--bg-secondary));
    color: var(--text-secondary);
}

[data-theme="dark"] .search-popular-tag:hover {
    background: var(--color-primary-950, #0f3249);
    color: var(--color-primary-300, #80cbf1);
    border-color: var(--color-primary-800, #1c5f86);
}

[data-theme="dark"] .search-dropdown-footer {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .search-no-results {
    color: var(--text-muted);
}

[data-theme="dark"] .search-bar-widget.is-mobile-overlay {
    background: var(--bg-primary);
}
