/* ===================================
   Search Component Styles
   Beautiful, modern search with autocomplete
   =================================== */

/* Search Container */
.search-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 10px auto 60px auto;
    z-index: 30;
    isolation: isolate;
}

/* Search Input Wrapper */
.search-wrapper {
    position: relative;
    width: 100%;
}

/* Search Input */
.search-input {
    width: 100%;
    padding: 14px 50px 14px 50px;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--card-bg, #ffffff);
    color: var(--text-primary, #2c3e50);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.search-input::placeholder {
    color: var(--text-secondary, #7f8c8d);
    opacity: 0.7;
}

.search-input:focus {
    border-color: var(--accent-primary, #ff751f);
    box-shadow: 0 6px 30px rgba(255, 117, 31, 0.15);
    transform: translateY(-2px);
}

/* Search Icon */
.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--accent-primary, #ff751f);
    pointer-events: none;
    transition: all 0.3s ease;
}

.search-input:focus ~ .search-icon {
    transform: translateY(-50%) scale(1.1);
}

/* Clear Button */
.search-clear {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary, #7f8c8d);
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.search-clear:hover {
    background: var(--hover-bg, #f8f9fa);
    color: var(--text-primary, #2c3e50);
}

.search-clear.visible {
    opacity: 1;
}

/* Keyboard Hint */
.search-kbd {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    background: var(--code-bg, #f8f9fa);
    border: 1px solid var(--border-color, #e1e4e8);
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    color: var(--text-secondary, #7f8c8d);
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.search-input:focus ~ .search-kbd,
.search-kbd.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    max-height: 500px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 31;
    border: 1px solid var(--border-color, #e1e4e8);
}

.search-results.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Custom Scrollbar */
.search-results::-webkit-scrollbar {
    width: 8px;
}

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

.search-results::-webkit-scrollbar-thumb {
    background: var(--accent-primary, #ff751f);
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover, #ff8b49);
}

/* Results Header */
.search-results-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color, #e1e4e8);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #7f8c8d);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Result Item */
.search-result-item {
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.search-result-item:hover,
.search-result-item.active {
    background: var(--hover-bg, #f8f9fa);
    border-left-color: var(--accent-primary, #ff751f);
}

.search-result-item:active {
    transform: scale(0.98);
}

/* Result Icon */
.result-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Result Content */
.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #2c3e50);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-title mark {
    background: var(--accent-primary, #ff751f);
    color: #ffffff;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
}

.result-description {
    font-size: 13px;
    color: var(--text-secondary, #7f8c8d);
    line-height: 1.5;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.result-description mark {
    background: rgba(255, 117, 31, 0.2);
    color: var(--accent-primary, #ff751f);
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 500;
}

/* Result Category Badge */
.result-category {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.result-category.tutorial {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
}

.result-category.forms {
    background: rgba(155, 89, 182, 0.1);
    color: #9b59b6;
}

.result-category.graphics {
    background: rgba(46, 204, 113, 0.1);
    color: #2ecc71;
}

.result-category.media {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.result-category.api {
    background: rgba(241, 196, 15, 0.1);
    color: #f1c40f;
}

.result-category.reference {
    background: rgba(255, 117, 31, 0.1);
    color: #ff751f;
}

.result-category.tools {
    background: rgba(52, 73, 94, 0.1);
    color: #34495e;
}

.result-category.examples {
    background: rgba(26, 188, 156, 0.1);
    color: #1abc9c;
}

/* No Results */
.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary, #7f8c8d);
}

.search-no-results-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.search-no-results-text {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary, #2c3e50);
}

.search-no-results-hint {
    font-size: 13px;
    color: var(--text-secondary, #7f8c8d);
}

/* Loading State */
.search-loading {
    padding: 30px 20px;
    text-align: center;
}

.search-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e1e4e8);
    border-top-color: var(--accent-primary, #ff751f);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* Results Footer */
.search-results-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color, #e1e4e8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary, #7f8c8d);
    background: var(--code-bg, #f8f9fa);
    border-radius: 0 0 12px 12px;
}

.search-keyboard-hints {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-keyboard-hint {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-keyboard-hint kbd {
    padding: 2px 6px;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e1e4e8);
    border-radius: 3px;
    font-size: 11px;
    font-family: monospace;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Dark Theme Adjustments */
[data-theme="dark"],
[data-theme="dark-orange"] {
    .search-input {
        background: var(--card-bg);
        color: var(--text-primary);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .search-input:focus {
        box-shadow: 0 6px 30px rgba(255, 117, 31, 0.25);
    }

    .search-kbd {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.2);
        color: var(--text-primary);
    }

    .search-results {
        background: #1a1d24;
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
        border-color: #3d4149;
    }

    .result-title mark {
        background: var(--accent-primary);
        color: #000000;
    }

    .result-description mark {
        background: rgba(255, 117, 31, 0.3);
        color: var(--accent-primary);
    }

    .search-result-item:hover,
    .search-result-item.active {
        background: #2a2d35;
    }

    .search-results-footer {
        background: #0f1115;
        border-top-color: #3d4149;
    }

    .search-keyboard-hint kbd {
        background: #2a2d35;
        border-color: #3d4149;
        color: var(--text-primary);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-container {
        max-width: 100%;
    }

    .search-input {
        padding: 12px 40px 12px 40px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .search-results {
        max-height: 400px;
        border-radius: 8px;
    }

    .result-title {
        font-size: 14px;
    }

    .result-description {
        font-size: 12px;
    }

    .search-keyboard-hints {
        display: none; /* Hide keyboard hints on mobile */
    }
}

/* Animation for search icon pulse */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.search-icon.searching {
    animation: pulse 1.5s ease-in-out infinite;
}
