/* Search Page Styles
   Extends the base design system
   ============================== */

/* Page Header */
.search-page-header {
    margin-bottom: var(--space-6);
}

.search-page-header h1 {
    margin-bottom: var(--space-2);
}

.search-page-header .text-muted {
    font-size: var(--text-lg);
}

/* Search Form */
.search-form {
    margin-bottom: var(--space-8);
}

.search-input-wrapper {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.search-input-wrapper input[type="search"] {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.search-input-wrapper input[type="search"]:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgb(6 182 212 / 0.1);
}

.search-input-wrapper input[type="search"]::placeholder {
    color: var(--color-text-muted);
}

.search-input-wrapper button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-inverse);
    background: linear-gradient(135deg, var(--color-cyan-500) 0%, var(--color-cyan-600) 100%);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 48px;
}

.search-input-wrapper button:hover {
    background: linear-gradient(135deg, var(--color-cyan-400) 0%, var(--color-cyan-500) 100%);
    box-shadow: var(--shadow), 0 0 20px rgb(6 182 212 / 0.3);
    transform: translateY(-1px);
}

.search-input-wrapper button:active {
    transform: translateY(0);
}

.search-input-wrapper button svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Search Filters - styled like subnav pills */
.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

.filter-label {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-right: var(--space-2);
}

.filter-option {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.filter-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.filter-option span {
    display: block;
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    background: transparent;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.filter-option:hover span {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

.filter-option input[type="radio"]:checked + span {
    background: var(--color-slate-900);
    color: var(--color-text-inverse);
}

.filter-option input[type="radio"]:focus-visible + span {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Results Header */
.search-results-header {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.results-count {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin: 0;
}

.results-count strong {
    color: var(--color-text);
    font-weight: 600;
}

.version-note {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* Search Results - using card system */
.search-results {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0; /* Allow shrinking in flex context */
}

.search-result {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: var(--space-5);
    border: 1px solid var(--color-border-subtle);
    border-left: 4px solid var(--color-accent);
    transition: all var(--transition);
    animation: fadeIn 0.3s ease forwards;
    min-width: 0; /* Prevent growing beyond container */
    overflow: hidden; /* Contain overflow */
}

.search-result:nth-child(1) { animation-delay: 0.05s; }
.search-result:nth-child(2) { animation-delay: 0.1s; }
.search-result:nth-child(3) { animation-delay: 0.15s; }
.search-result:nth-child(4) { animation-delay: 0.2s; }
.search-result:nth-child(5) { animation-delay: 0.25s; }

.search-result:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Result type-specific borders */
.search-result[data-type="document"] {
    border-left-color: var(--color-info);
}

.search-result[data-type="faq"] {
    border-left-color: var(--color-success);
}

.search-result[data-type="blog"] {
    border-left-color: var(--color-warning);
}

/* Result Header - matches card.update structure */
.search-result header {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-2);
}

.result-source {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.result-identifier {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.result-date {
    margin-left: auto;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* Result Title */
.search-result h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    margin: var(--space-2) 0;
    line-height: var(--leading-tight);
    overflow-wrap: break-word;
    word-break: break-word;
}

.search-result h3 a {
    color: var(--color-slate-900);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.search-result h3 a:hover {
    color: var(--color-accent);
}

/* Version Badge - matches base badge styling */
.version-badge {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: 600;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    background: var(--color-bg-alt);
    color: var(--color-text-secondary);
    vertical-align: middle;
    margin-left: var(--space-2);
}

.search-result h3 .version-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
}

/* Result Snippet */
.result-snippet {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Highlight matched terms */
.result-snippet mark {
    background: linear-gradient(120deg, var(--color-amber-100) 0%, var(--color-amber-100) 100%);
    background-repeat: no-repeat;
    background-size: 100% 40%;
    background-position: 0 90%;
    padding: 0 2px;
    border-radius: 2px;
    color: inherit;
}

/* Older Versions Collapsible */
.older-versions {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-sm);
}

.older-versions summary {
    cursor: pointer;
    color: var(--color-accent);
    font-family: var(--font-display);
    font-weight: 500;
    padding: var(--space-1) 0;
    user-select: none;
    transition: color var(--transition-fast);
}

.older-versions summary:hover {
    color: var(--color-cyan-600);
}

.older-versions summary::-webkit-details-marker {
    color: var(--color-accent);
}

.older-versions[open] summary {
    margin-bottom: var(--space-2);
}

.older-versions ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.older-versions li {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border-subtle);
}

.older-versions li:last-child {
    border-bottom: none;
}

.older-versions li .version-badge {
    margin-left: 0;
}

.older-versions time {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

/* Empty State - extends base */
.search-results .empty-state {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: var(--space-12) var(--space-4);
    text-align: center;
    color: var(--color-text-muted);
}

/* Search Help */
.search-help {
    max-width: 600px;
    margin: var(--space-8) auto;
    padding: var(--space-6);
    background: linear-gradient(135deg, var(--color-info-bg) 0%, #f0f9ff 100%);
    border-left: 4px solid var(--color-info);
    border-radius: var(--radius-lg);
}

.search-help h2 {
    margin: 0 0 var(--space-4) 0;
    font-size: var(--text-lg);
    color: var(--color-slate-900);
}

.search-help ul {
    margin: 0;
    padding-left: var(--space-5);
}

.search-help li {
    margin-bottom: var(--space-2);
    color: var(--color-info-text);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

.search-help li:last-child {
    margin-bottom: 0;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .search-input-wrapper {
        flex-direction: column;
    }

    .search-input-wrapper button {
        width: 100%;
    }

    .search-filters {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .filter-label {
        margin-right: 0;
        margin-bottom: var(--space-1);
    }

    .filter-options {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .result-date {
        margin-left: 0;
        width: 100%;
        margin-top: var(--space-1);
    }

    .search-result h3 {
        font-size: var(--text-base);
    }

    .search-result h3 .version-badge {
        display: block;
        margin-left: 0;
        margin-top: var(--space-1);
        width: fit-content;
    }
}

/* Focus styles for accessibility */
.search-input-wrapper input[type="search"]:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.search-input-wrapper button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Animation keyframe (inherited from base, but defined here for clarity) */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
