/* =========================================
   SEARCH BAR COMPONENT STYLES
   Base styles for the search-bar.html component
   Hub-specific overrides are in respective hub CSS files
   (e.g., book_hub.css has .search-sticky-container overrides)
   ========================================= */

/* Search Form Container */
.search-form {
    position: relative;
    width: 100%;
    max-width: 400px;
}

/* Search Input Wrapper */
.search-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 1px 5px;
    transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

/* Search Icon */
.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Search Input Field */
.search-input {
    flex: 1;
    background: transparent;
    padding: 0.25rem;
    border: none;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9375rem;
    outline: none;
}

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

/* Search Scope Selector */
.search-scope {
    flex-shrink: 0;
}

.search-scope select {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 12px;
    padding: 4px 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
}

/* Search Submit Button */
.search-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hub-color, var(--accent-primary));
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    margin-left: 4px;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.search-submit:hover {
    opacity: 0.85;
}

/* Search Close Button */
.search-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.search-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* =========================================
   SEARCH SUGGESTIONS DROPDOWN
   ========================================= */
.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--dropdown-bg, #252538);
    border: 1px solid var(--dropdown-border, #3d3d5c);
    border-radius: 12px;
    box-shadow: var(--shadow-dropdown);
    z-index: var(--z-dropdown);
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px 8px;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.clear-history {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    font-size: 0.6875rem;
    cursor: pointer;
}

.suggestions-list {
    list-style: none;
    margin: 0;
    padding: 0 0 8px;
}

.suggestion-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s ease;
}

.suggestion-item a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.suggestion-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* =========================================
   SEARCH RESULTS (In-page results)
   ========================================= */
.search-results-container {
    padding: 1rem;
}

.search-results-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
}

.search-results-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.search-results-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.clear-search-link {
    color: var(--accent-primary);
    text-decoration: none;
}

.clear-search-link:hover {
    text-decoration: underline;
}

/* Results List */
.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-result-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card, rgba(255, 255, 255, 0.05));
    border-radius: 8px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    transition: background 0.15s ease, border-color 0.15s ease;
}

.search-result-item:hover {
    background: var(--bg-card-hover, rgba(255, 255, 255, 0.08));
    border-color: var(--hub-color, var(--accent-primary));
}

.search-result-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
}

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

.search-result-icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

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

.search-result-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 0.25rem;
}

.search-result-title:hover {
    color: var(--hub-color, var(--accent-primary));
}

.search-result-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.search-result-excerpt {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

.search-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.search-result-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.result-type {
    background: var(--hub-color, var(--accent-primary));
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* No Results State */
.search-no-results {
    text-align: center;
    padding: 3rem 1rem;
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.search-no-results p {
    margin: 0;
    color: var(--text-secondary);
}

.no-results-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem !important;
}

/* Load More Button */
.search-results-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.load-more-btn {
    background: transparent;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.2));
    color: var(--text-secondary);
    padding: 0.75rem 2rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.load-more-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--hub-color, var(--accent-primary));
    color: var(--text-primary);
}

/* =========================================
   STICKY SEARCH CONTAINER
   Shared across all hubs - sticks below header when scrolling
   ========================================= */
.search-sticky-container {
    position: sticky;
    top: var(--header-height, 64px);
    z-index: var(--z-sticky, 100);
    background: linear-gradient(to bottom, var(--bg-card) 0%, var(--bg-card) 85%, var(--hub-color) 100%);
    border-left: 1px solid var(--hub-color);
    border-right: 1px solid var(--hub-color);
    padding: 0.3rem 0.5rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    border-radius: 0 0 12px 12px;
    color: white;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Breadcrumb inline with search — remove stacking margin */
.search-sticky-container .search-breadcrumb {
    margin-bottom: 0;
    flex-shrink: 0;
}

/* Search input wrapper - override component defaults for hub context */
.search-sticky-container .search-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--hub-glow);
    border-radius: 6px;
    padding: 1px 5px;
    transition: all 0.2s ease;
}

/* Search input field - override for hub context */
.search-sticky-container .search-input {
    flex: 1;
    background: transparent;
    padding: 0.1rem;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9375rem;
    outline: none;
}

/* When stuck, add subtle shadow and adjust border-radius */
.search-sticky-container.is-stuck {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    border-radius: 0;
}

/* Ensure search form inside container is styled appropriately */
.search-sticky-container .search-form {
    flex: 1;
    min-width: 200px;
    max-width: 45%;
}

/* Mobile search toggle button - hidden on desktop */
.mobile-search-toggle {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-secondary, #a0a0a0);
    cursor: pointer;
    padding: 4px 0;
}

.mobile-search-toggle .toggle-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.mobile-search-toggle .toggle-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.mobile-search-toggle:hover .toggle-icon {
    background: rgba(255, 255, 255, 0.15);
}

/* =========================================
   RESPONSIVE - Mobile
   ========================================= */
@media (max-width: 767px) {
    .search-form {
        max-width: none;
    }

    .search-scope {
        display: none;
    }

    /* Sticky search container mobile adjustments */
    .search-sticky-container {
        padding: 0.75rem 1rem;
    }

    /* Collapse search form to icon by default */
    .search-sticky-container .search-form {
        display: none;
    }

    .search-sticky-container .search-breadcrumb {
        display: none;
    }

    /* Show search toggle button on mobile */
    .search-sticky-container .mobile-search-toggle {
        display: flex;
    }

    /* When expanded on mobile */
    .search-sticky-container.search-expanded .search-form {
        display: block;
        width: 100%;
        max-width: none;
        margin-top: 8px;
    }

    .search-sticky-container.search-expanded .search-breadcrumb {
        display: flex;
        margin-top: 8px;
    }

    .search-sticky-container.search-expanded .mobile-search-toggle .toggle-icon {
        transform: rotate(45deg);
    }
}
