/**
 * Semantic search results styling.
 *
 * Designed to work with Material theme for MkDocs.
 * Fully responsive with mobile-first design.
 */

/* Results container */
.semantic-search-results {
    margin-top: 1rem;
    padding: 0.5rem 0;
    max-width: 100%;
}

/* Loading indicator */
.search-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--md-default-fg-color--light);
}

.search-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--md-default-fg-color--lighter);
    border-top-color: var(--md-primary-fg-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.search-loading-text {
    font-size: 0.875rem;
}

/* Individual result item */
.search-result-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--md-default-bg-color);
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.search-result-item:hover {
    background: var(--md-default-bg-color--light);
    border-color: var(--md-primary-fg-color--light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Result title */
.search-result-title {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: var(--md-primary-fg-color);
    text-decoration: none;
    margin-bottom: 0.5rem;
}

.search-result-title:hover {
    text-decoration: underline;
}

/* Result badges */
.search-result-badges {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.search-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    line-height: 1.4;
}

/* Badge colors by type */
.search-badge-adr {
    background: linear-gradient(135deg, #ef5350 0%, #e53935 100%);
    color: white;
}

.search-badge-prd {
    background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
    color: white;
}

.search-badge-add {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: white;
}

.search-badge-api {
    background: linear-gradient(135deg, #ab47bc 0%, #8e24aa 100%);
    color: white;
}

.search-badge-arch {
    background: linear-gradient(135deg, #ffa726 0%, #fb8c00 100%);
    color: white;
}

/* Result snippet */
.search-result-snippet {
    color: var(--md-default-fg-color--light);
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0.5rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Highlighted terms */
.search-result-snippet mark {
    background: linear-gradient(135deg, #fff59d 0%, #ffeb3b 100%);
    color: var(--md-default-fg-color);
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
    font-weight: 500;
}

/* Relevance score */
.search-result-score {
    display: inline-block;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--md-default-fg-color--lighter);
    margin-top: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: var(--md-default-fg-color--lightest);
    border-radius: 0.25rem;
}

/* No results message */
.search-no-results {
    padding: 2rem;
    text-align: center;
    color: var(--md-default-fg-color--light);
}

.search-no-results p {
    margin: 0.5rem 0;
}

.search-no-results strong {
    color: var(--md-default-fg-color);
}

/* Error message */
.search-error {
    padding: 1rem;
    background: #ffebee;
    border: 1px solid #ef5350;
    border-radius: 0.375rem;
    color: #c62828;
}

.search-error p {
    margin: 0.5rem 0;
}

/* Hint text */
.search-hint {
    color: var(--md-default-fg-color--lighter);
    font-size: 0.875rem;
}

.search-hints {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
    text-align: left;
    display: inline-block;
}

.search-hints li {
    padding: 0.25rem 0;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-error {
        background: #3e2723;
        border-color: #ef5350;
        color: #ffcdd2;
    }

    .search-result-snippet mark {
        background: linear-gradient(135deg, #f9a825 0%, #f57f17 100%);
        color: var(--md-default-fg-color--dark);
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .semantic-search-results {
        margin-top: 0.75rem;
    }

    .search-result-item {
        padding: 0.75rem;
        margin-bottom: 0.375rem;
    }

    .search-result-title {
        font-size: 0.9375rem;
    }

    .search-result-snippet {
        font-size: 0.8125rem;
        -webkit-line-clamp: 2;
    }

    .search-result-badges {
        flex-wrap: wrap;
    }

    .search-badge {
        font-size: 0.65rem;
        padding: 0.1rem 0.375rem;
    }

    .search-no-results {
        padding: 1.5rem 1rem;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .semantic-search-results {
        max-width: 90%;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .semantic-search-results {
        max-width: 800px;
    }

    .search-result-item {
        padding: 1.25rem;
    }
}

/* Animation for results */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-result-item {
    animation: fadeIn 0.3s ease-out;
}

/* Stagger animations for multiple results */
.search-result-item:nth-child(1) { animation-delay: 0ms; }
.search-result-item:nth-child(2) { animation-delay: 50ms; }
.search-result-item:nth-child(3) { animation-delay: 100ms; }
.search-result-item:nth-child(4) { animation-delay: 150ms; }
.search-result-item:nth-child(5) { animation-delay: 200ms; }

/* Accessibility - focus states */
.search-result-title:focus {
    outline: 2px solid var(--md-primary-fg-color);
    outline-offset: 2px;
    border-radius: 0.125rem;
}

/* Print styles */
@media print {
    .semantic-search-results {
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .search-result-item {
        border-width: 2px;
    }

    .search-badge {
        border: 1px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .search-result-item {
        animation: none;
        transition: none;
    }

    .search-spinner {
        animation: none;
        border-top-color: transparent;
        border-right-color: transparent;
    }
}
