/**
 * Enhanced Content Discovery - Search Interface Styles
 * Desert theme integration with WCAG 2.1 AA compliance
 */

/* Search Container */
#search-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* Search Form */
.search-form {
    position: relative;
    margin-bottom: 1rem;
}

#search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    border: 2px solid var(--color-border, #d4af37);
    border-radius: 8px;
    background: var(--color-background, #faf8f3);
    color: var(--color-text, #2c1810);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--color-accent, #cd853f);
    box-shadow: 0 0 0 3px rgba(205, 133, 63, 0.2);
}

#search-input::placeholder {
    color: var(--color-text-muted, #8b7355);
    opacity: 1;
}

.search-clear {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted, #8b7355);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.search-clear:hover,
.search-clear:focus {
    background-color: var(--color-accent-light, rgba(205, 133, 63, 0.1));
    color: var(--color-accent, #cd853f);
    outline: 2px solid var(--color-accent, #cd853f);
    outline-offset: 2px;
}

/* Search Help */
.search-help {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--color-text-muted, #8b7355);
}

/* Search Filters */
.search-filters {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--color-background-light, #f9f7f2);
    border: 1px solid var(--color-border-light, #e8e0d0);
    border-radius: 8px;
}

.search-filters fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.search-filters legend {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-options label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    cursor: pointer;
    min-height: 44px;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.filter-options label:hover {
    background-color: var(--color-accent-light, rgba(205, 133, 63, 0.1));
}

.filter-options input[type="checkbox"] {
    margin-right: 0.5rem;
    accent-color: var(--color-accent, #cd853f);
}

/* Search Stats */
.search-stats {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--color-text-muted, #8b7355);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border-light, #e8e0d0);
}

/* Search Results */
.search-results {
    min-height: 200px;
}

.search-loading,
.search-error,
.search-no-results {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted, #8b7355);
}

.search-error {
    background: var(--color-error-light, #fdf2f2);
    border: 1px solid var(--color-error, #e74c3c);
    border-radius: 8px;
    color: var(--color-error, #e74c3c);
}

.search-no-results h2 {
    margin-bottom: 1rem;
    color: var(--color-text, #2c1810);
}

.search-no-results ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.search-no-results li a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--color-accent-light, rgba(205, 133, 63, 0.1));
    color: var(--color-accent, #cd853f);
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid var(--color-accent, #cd853f);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.search-no-results li a:hover,
.search-no-results li a:focus {
    background: var(--color-accent, #cd853f);
    color: var(--color-background, #faf8f3);
}

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

/* Individual Search Result */
.search-result {
    padding: 1.5rem;
    background: var(--color-background, #faf8f3);
    border: 1px solid var(--color-border-light, #e8e0d0);
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-result:hover {
    border-color: var(--color-accent, #cd853f);
    box-shadow: 0 2px 8px rgba(205, 133, 63, 0.1);
}

/* Search Result Header */
.search-result-header {
    margin-bottom: 1rem;
}

.search-result-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    line-height: 1.3;
}

.search-result-title a {
    color: var(--color-accent, #cd853f);
    text-decoration: none;
    transition: color 0.2s ease;
}

.search-result-title a:hover,
.search-result-title a:focus {
    color: var(--color-accent-dark, #b8860b);
    text-decoration: underline;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--color-text-muted, #8b7355);
}

/* Content Type Badges */
.content-type-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    background: var(--color-text-muted, #8b7355);
    color: var(--color-background, #faf8f3);
}

.badge-post { background: #2ecc71; }
.badge-note { background: #3498db; }
.badge-response { background: #9b59b6; }
.badge-bookmark { background: #e67e22; }
.badge-wiki { background: #1abc9c; }
.badge-review { background: #e74c3c; }
.badge-snippet { background: #34495e; }
.badge-presentation { background: #f39c12; }
.badge-album { background: #8e44ad; }
.badge-media { background: #27ae60; }

/* Search Score (for debugging) */
.search-score {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Search Result Summary */
.search-result-summary {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.search-result-summary p {
    margin: 0;
    color: var(--color-text, #2c1810);
}

/* Highlighted Search Terms */
.search-result mark {
    background: var(--color-highlight, #fff3cd);
    color: var(--color-text, #2c1810);
    padding: 0.1em 0.2em;
    border-radius: 2px;
    font-weight: 600;
}

/* Tags */
.search-result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-result-tags .tag {
    font-size: 0.8rem;
    color: var(--color-accent, #cd853f);
    background: var(--color-accent-light, rgba(205, 133, 63, 0.1));
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-decoration: none;
    border: 1px solid var(--color-accent-light, rgba(205, 133, 63, 0.3));
    transition: background-color 0.2s ease;
}

.search-result-tags .tag:hover {
    background: var(--color-accent, #cd853f);
    color: var(--color-background, #faf8f3);
}

/* Accessibility Helpers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    #search-container {
        padding: 0.5rem;
    }
    
    #search-input {
        font-size: 1rem;
        padding: 0.875rem 1rem;
    }
    
    .search-clear {
        right: 0.5rem;
        min-width: 40px;
        min-height: 40px;
    }
    
    .filter-options {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .search-result {
        padding: 1rem;
    }
    
    .search-result-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .search-result-title {
        font-size: 1.1rem;
    }
    
    .content-type-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    #search-input {
        border-width: 3px;
    }
    
    .search-result {
        border-width: 2px;
    }
    
    .content-type-badge {
        border: 1px solid;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    #search-input,
    .search-clear,
    .filter-options label,
    .search-result,
    .search-result-title a,
    .search-result-tags .tag {
        transition: none;
    }
}
