/* Search Component - Semantic CSS without inline styles */

/* Search Trigger Button */
.search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    color: rgb(55, 65, 81);
    cursor: pointer;
    transition: all 0.15s ease;
}

.search-trigger:hover {
    background: rgba(0, 0, 0, 0.05);
}

.search-trigger-icon {
    width: 16px;
    height: 16px;
    fill: rgb(107, 114, 128);
}

.search-trigger-text {
    /* Inherits styles from parent */
}

/* Search Dialog Container */
.search-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.search-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.search-modal {
    position: relative;
    z-index: 1;
    margin: 50px auto;
    max-width: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* Search Header */
.search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #e5e7eb;
    padding: 16px;
}

.search-header-icon {
    width: 20px;
    height: 20px;
    color: #9ca3af;
}

.search-input {
    flex: 1;
    border: 0;
    background: transparent;
    font-size: 18px;
    color: #374151;
    outline: none;
    caret-color: #3b82f6;
}

.search-input::placeholder {
    color: #9ca3af;
}

.search-input:focus {
    box-shadow: 0 0 0 2px #3b82f6;
    border-radius: 4px;
}

.search-close-btn {
    padding: 4px 8px;
    background: #f3f4f6;
    color: #6b7280;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.search-close-btn:hover {
    background: #e5e7eb;
}

/* Search Results Container */
.search-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

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

.search-results::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.5);
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.7);
}

/* Search Loading State */
.search-loading {
    display: none;
    padding: 32px 8px;
    text-align: center;
    color: #6b7280;
}

.search-loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.search-spinner {
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
}

.search-spinner-track {
    opacity: 0.25;
}

.search-spinner-bar {
    opacity: 0.75;
}

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

/* Search Results List */
.search-results-list {
    display: none;
}

/* Search Result Links */
.search-result-link {
    display: block;
    padding: 12px 16px;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
    background-color: #f9fafb;
}

.search-result-link:last-child {
    margin-bottom: 0;
}

.search-result-link:hover {
    background-color: #f3f4f6;
}

.search-result-link.selected {
    background-color: #1f2937;
    color: white;
}

/* Search Result Content */
.search-result-title {
    font-weight: 500;
    color: #111827;
    margin-bottom: 4px;
    line-height: 1.4;
}

.search-result-link.selected .search-result-title {
    color: white;
}

.search-result-excerpt {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-link.selected .search-result-excerpt {
    color: #d1d5db;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #9ca3af;
}

.search-result-type {
    text-transform: capitalize;
}

.search-result-separator {
    /* Inherits color from parent */
}

.search-result-url {
    /* Inherits color from parent */
}

/* No Results State */
.search-no-results {
    display: none;
    padding: 32px 8px;
    text-align: center;
    color: #6b7280;
}

.search-no-results-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
}

.search-no-results-text {
    font-size: 14px;
}

/* Empty State */
.search-empty {
    padding: 32px 8px;
    text-align: center;
    color: #6b7280;
}

.search-empty-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
}

.search-empty-text {
    font-size: 14px;
}

/* Highlight marks in search results */
mark {
    background-color: #fef3c7;
    color: #92400e;
    padding: 0;
    border-radius: 2px;
    font-weight: 500;
}

/* Dark Mode Styles */
body.dark .search-trigger {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--color-p-200);
}

body.dark .search-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.dark .search-trigger-icon {
    fill: var(--color-p-300);
}

body.dark .search-backdrop {
    background-color: rgba(var(--p-1000), 0.8);
}

body.dark .search-modal {
    background: var(--color-p-800);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--color-p-700);
}

body.dark .search-header {
    border-color: var(--color-p-700);
}

body.dark .search-header-icon {
    color: var(--color-p-400);
}

body.dark .search-input {
    color: var(--color-p-000);
}

body.dark .search-input::placeholder {
    color: var(--color-p-400);
}

body.dark .search-close-btn {
    background: var(--color-p-700);
    color: var(--color-p-200);
}

body.dark .search-close-btn:hover {
    background: var(--color-p-600);
}

body.dark .search-loading,
body.dark .search-no-results,
body.dark .search-empty {
    color: var(--color-p-400);
}

body.dark .search-result-link {
    background-color: var(--color-p-700);
}

body.dark .search-result-link:hover {
    background-color: var(--color-p-600);
}

body.dark .search-result-link.selected {
    background-color: var(--color-p-600);
    color: var(--color-p-000);
}

body.dark .search-result-title {
    color: var(--color-p-000);
}

body.dark .search-result-excerpt {
    color: var(--color-p-300);
}

body.dark .search-result-link.selected .search-result-excerpt {
    color: var(--color-p-100);
}

body.dark .search-result-meta {
    color: var(--color-p-400);
}

body.dark mark {
    background-color: var(--color-a-800);
    color: var(--color-a-200);
}

/* Responsive Design */
@media (max-width: 640px) {
    .search-modal {
        margin: 20px auto;
        max-width: calc(100vw - 2rem);
    }

    .search-results {
        max-height: 300px;
    }
}