#search-button,
#search-modal {
    --ds-accent: #006ad1;
    --ds-accent-dark: #00509e;
    --ds-accent-tint: #e8f1fc;
}

#search-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    /* Matches the navbar link padding a button no longer inherits */
    padding: 15px;
    background: none;
    border: 0;
    color: #e5e7eb;
    transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

#search-button:hover,
#search-button:focus-visible {
    color: #ffffff;
}

#search-button .search-button-icon {
    color: var(--ds-accent);
}

#search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 1000;
    padding-top: 10vh;
}

#search-modal.ds-hidden,
#search-modal .ds-hidden {
    display: none !important;
}

#search-modal:not(.ds-hidden) {
    animation: ds-backdrop-in 120ms ease-out;
}

#search-modal .ds-search-panel {
    background-color: #ffffff;
    width: 90%;
    max-width: 640px;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    position: relative;
    overflow: hidden;
}

#search-modal:not(.ds-hidden) .ds-search-panel {
    animation: ds-modal-in 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
    #search-modal:not(.ds-hidden),
    #search-modal:not(.ds-hidden) .ds-search-panel {
        animation: none;
    }
}

@keyframes ds-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ds-modal-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#search-modal .search-input-row {
    padding: 14px 22px;
}

#search-modal .search-input-field {
    position: relative;
    display: block;
}

#search-modal .search-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: #9ca3af;
}

#search-modal .search-input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 14px;
    pointer-events: none;
}

#search-modal .search-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    font-size: 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#search-modal .search-input:focus {
    border-color: var(--ds-accent);
    box-shadow: 0 0 0 3px rgba(0, 106, 209, 0.15);
}

#search-results {
    max-height: 55vh;
    overflow-y: auto;
    padding: 6px 14px 14px;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

#search-results::-webkit-scrollbar {
    width: 8px;
}

#search-results::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 8px;
}

#search-results .result-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 4px 0;
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid transparent;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
    transition: background-color 120ms ease-in-out, border-left-color 120ms ease-in-out;
}

#search-results .result-item:hover,
#search-results .result-item:focus,
#search-results .result-item.is-active {
    background-color: var(--ds-accent-tint);
    border-left-color: var(--ds-accent);
    text-decoration: none;
}

#search-modal .result-body {
    flex: 1;
    min-width: 0;
}

#search-modal .result-api-name {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ds-accent);
    margin-bottom: 3px;
}

#search-modal .result-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#search-modal .method-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

#search-modal .method-get { background-color: #dbeafe; color: #1d4ed8; }
#search-modal .method-post { background-color: #dcfce7; color: #15803d; }
#search-modal .method-put { background-color: #fef3c7; color: #b45309; }
#search-modal .method-patch { background-color: #ede9fe; color: #6d28d9; }
#search-modal .method-delete { background-color: #fee2e2; color: #b91c1c; }

#search-modal .result-doc-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 13px;
}

#search-modal .result-path {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 14px;
    color: #111827;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#search-modal .result-title {
    font-weight: 600;
    color: #111827;
    font-size: 15px;
}

#search-modal .result-content {
    color: #6b7280;
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 1.55;
    max-height: 3.1em;
    overflow: hidden;
}

#search-modal .result-content mark {
    background-color: transparent;
    color: #374151;
    font-weight: 600;
}

#search-modal .result-chevron {
    flex-shrink: 0;
    align-self: center;
    color: #d1d5db;
    font-size: 12px;
    opacity: 0;
    transition: opacity 120ms ease-in-out;
}

#search-results .result-item:hover .result-chevron,
#search-results .result-item:focus .result-chevron,
#search-results .result-item.is-active .result-chevron {
    opacity: 1;
    color: var(--ds-accent);
}

#search-modal .loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #6b7280;
    font-size: 14px;
    padding: 24px 0;
}

#search-modal .loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--ds-accent);
    border-radius: 50%;
    animation: ds-spin 700ms linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    #search-modal .loading-spinner {
        animation: none;
    }
}

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

#search-modal .no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 14px;
    padding: 32px 22px 24px;
}

#search-modal .no-results-icon {
    font-size: 20px;
    color: #d1d5db;
}
