/**
 * Webtron Docs Search Styles
 * Instant search widget and results dropdown
 */

/* Search Wrapper */
.webtron-docs-search-wrapper {
    position: relative;
    max-width: 500px;
    width: 100%;
}

/* Search Form */
.webtron-docs-search-form {
    margin: 0;
}

.webtron-docs-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.webtron-docs-search-icon {
    position: absolute;
    left: 14px;
    color: var(--docs-search-icon, #6b7280);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.webtron-docs-search-input {
    width: 100%;
    padding: 12px 80px 12px 44px;
    font-size: 15px;
    border: 1px solid var(--docs-search-border, #e5e7eb);
    border-radius: 8px;
    background: var(--docs-search-bg, #fff);
    color: var(--docs-search-text, #111827);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.webtron-docs-search-input:focus {
    outline: none;
    border-color: var(--docs-search-focus-border, #3b82f6);
    box-shadow: 0 0 0 3px var(--docs-search-focus-shadow, rgba(59, 130, 246, 0.15));
}

.webtron-docs-search-input::placeholder {
    color: var(--docs-search-placeholder, #9ca3af);
}

.webtron-docs-search-loading {
    position: absolute;
    right: 50px;
    color: var(--docs-search-loading, #6b7280);
    display: flex;
    align-items: center;
}

.webtron-docs-spinner {
    animation: webtron-spin 1s linear infinite;
}

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

.webtron-docs-search-kbd {
    position: absolute;
    right: 14px;
    padding: 4px 8px;
    font-size: 12px;
    font-family: inherit;
    background: var(--docs-search-kbd-bg, #f3f4f6);
    border: 1px solid var(--docs-search-kbd-border, #e5e7eb);
    border-radius: 4px;
    color: var(--docs-search-kbd-text, #6b7280);
}

.webtron-docs-search-input:focus ~ .webtron-docs-search-kbd {
    display: none;
}

/* Search Results Dropdown */
.webtron-docs-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--docs-search-results-bg, #fff);
    border: 1px solid var(--docs-search-results-border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

/* Results List */
.webtron-docs-search-results-list {
    list-style: none;
    margin: 0;
    padding: 8px;
}

.webtron-docs-search-result {
    margin: 0;
}

.webtron-docs-search-result a {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.15s ease;
}

.webtron-docs-search-result a:hover,
.webtron-docs-search-result.is-selected a {
    background: var(--docs-search-result-hover-bg, #f3f4f6);
}

.webtron-docs-search-result-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--docs-search-result-icon-bg, #eff6ff);
    border-radius: 6px;
    color: var(--docs-search-result-icon-color, #3b82f6);
    font-size: 14px;
}

.webtron-docs-search-result-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.webtron-docs-search-result-path {
    font-size: 11px;
    color: var(--docs-search-result-path, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.webtron-docs-search-result-title {
    font-weight: 500;
    color: var(--docs-search-result-title, #111827);
    font-size: 14px;
}

.webtron-docs-search-result-excerpt {
    font-size: 13px;
    color: var(--docs-search-result-excerpt, #6b7280);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.webtron-docs-search-result-excerpt mark {
    background: var(--docs-search-highlight-bg, #fef3c7);
    color: var(--docs-search-highlight-text, #92400e);
    padding: 0 2px;
    border-radius: 2px;
}

.webtron-docs-search-result-arrow {
    flex-shrink: 0;
    color: var(--docs-search-result-arrow, #9ca3af);
    opacity: 0;
    transition: opacity 0.15s ease;
    align-self: center;
}

.webtron-docs-search-result a:hover .webtron-docs-search-result-arrow,
.webtron-docs-search-result.is-selected a .webtron-docs-search-result-arrow {
    opacity: 1;
}

/* Empty State */
.webtron-docs-search-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--docs-search-empty-color, #6b7280);
}

.webtron-docs-search-empty svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.webtron-docs-search-empty p {
    margin: 0;
}

.webtron-docs-search-empty-hint {
    font-size: 13px;
    margin-top: 4px !important;
    opacity: 0.7;
}

/* Error State */
.webtron-docs-search-error {
    text-align: center;
    padding: 24px 16px;
    color: var(--docs-search-error-color, #dc2626);
}

/* Footer with keyboard hints */
.webtron-docs-search-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 10px 16px;
    border-top: 1px solid var(--docs-search-footer-border, #e5e7eb);
    font-size: 12px;
    color: var(--docs-search-footer-text, #9ca3af);
}

.webtron-docs-search-footer kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: inherit;
    background: var(--docs-search-kbd-bg, #f3f4f6);
    border: 1px solid var(--docs-search-kbd-border, #e5e7eb);
    border-radius: 3px;
    margin-right: 2px;
}

/* Responsive */
@media screen and (max-width: 640px) {
    .webtron-docs-search-results {
        position: fixed;
        top: auto;
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-height: 60vh;
        border-radius: 16px;
    }

    .webtron-docs-search-footer {
        display: none;
    }
}
