/* =========================
   SEARCH COMMAND PALETTE
   ========================= */

/* Search trigger button */
.search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: #888;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.search-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #aaa;
}

.search-trigger svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.search-trigger kbd {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-family: inherit;
    color: #666;
    margin-left: 8px;
}

/* Header with search */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(26, 26, 26, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.site-header .logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
}

.site-header .logo-link img {
    height: 28px;
    width: auto;
}

/* Overlay backdrop */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal container */
.search-modal {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%) scale(0.96);
    width: 90%;
    max-width: 580px;
    max-height: 70vh;
    background: rgba(32, 32, 32, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

/* Search input area */
.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 12px;
}

.search-input-wrapper svg {
    width: 20px;
    height: 20px;
    color: #666;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.1rem;
    color: #fff;
    font-family: inherit;
    caret-color: #c44;
}

.search-input::placeholder {
    color: #555;
}

.search-input-wrapper .search-shortcut {
    display: flex;
    gap: 4px;
    color: #555;
    font-size: 0.75rem;
}

.search-input-wrapper kbd {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: inherit;
    font-size: 0.7rem;
}

/* Results area */
.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

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

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

.search-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Empty state */
.search-empty {
    padding: 40px 20px;
    text-align: center;
    color: #555;
}

.search-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.search-empty p {
    margin: 0;
    font-size: 0.95rem;
}

/* No results */
.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

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

/* Result item */
.search-result {
    display: block;
    padding: 12px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
    cursor: pointer;
}

.search-result:hover,
.search-result.selected {
    background: rgba(204, 68, 68, 0.12);
}

.search-result.selected {
    outline: none;
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.search-result-icon {
    width: 18px;
    height: 18px;
    color: #c44;
    flex-shrink: 0;
}

.search-result-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    flex: 1;
}

.search-result-category {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.search-result-description {
    font-size: 0.85rem;
    color: #888;
    margin-left: 28px;
    line-height: 1.4;
}

/* Highlight matched text */
.search-highlight {
    background: rgba(204, 68, 68, 0.3);
    color: #fff;
    border-radius: 2px;
    padding: 0 2px;
}

/* Footer hints */
.search-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
}

.search-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #555;
    font-size: 0.75rem;
}

.search-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 0 4px;
    font-family: inherit;
    font-size: 0.7rem;
}

/* Recent searches section */
.search-section-title {
    font-size: 0.7rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px 8px;
    margin: 0;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .search-modal {
        top: 5%;
        width: 95%;
        max-height: 85vh;
        border-radius: 12px;
    }

    .search-trigger {
        padding: 8px;
    }

    .search-trigger span {
        display: none;
    }

    .search-trigger kbd {
        display: none;
    }

    .search-input-wrapper {
        padding: 14px 16px;
    }

    .search-input {
        font-size: 1rem;
    }

    .search-input-wrapper .search-shortcut {
        display: none;
    }

    .search-result {
        padding: 14px 12px;
    }

    .search-footer {
        display: none;
    }

    .search-result-description {
        margin-left: 0;
        margin-top: 6px;
    }

    .site-header {
        padding: 10px 16px;
    }
}

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

.search-result {
    animation: resultFadeIn 0.15s ease forwards;
}

.search-result:nth-child(1) { animation-delay: 0ms; }
.search-result:nth-child(2) { animation-delay: 30ms; }
.search-result:nth-child(3) { animation-delay: 60ms; }
.search-result:nth-child(4) { animation-delay: 90ms; }
.search-result:nth-child(5) { animation-delay: 120ms; }
