/* --------------------------------------
   Search Input Field & Container
----------------------------------------- */
.ctc-settings-search {
    position: relative;
    min-width: 300px;
    width: 50%;
}

#ctc-search-input {
    width: 100%;
    padding: 0.625rem 2.5rem 0.625rem 0.75rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

#ctc-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

#ctc-search-input::placeholder {
    color: var(--text-secondary);
}

.ctc-settings-search::after {
    content: '\f179';
    font-family: dashicons;
    font-size: 1rem;
    position: absolute;
    inset-inline-end: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* --------------------------------------
   Dropdown Panel
----------------------------------------- */
.search-dropdown {
    position: absolute;
    top: 100%;
    inset-inline-start: 0;
    inset-inline-end: 0;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    max-height: 400px;
    overflow: hidden;
    margin-top: 4px;
    backdrop-filter: blur(12px);
}

.search-dropdown.hidden {
    display: none;
}

/* --------------------------------------
   Search Results List
----------------------------------------- */
.search-results {
    max-height: 350px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.search-result-item:hover,
.search-result-item.selected {
    background: linear-gradient(90deg, var(--primary-light) 0%, transparent 100%);
    color: var(--primary-readable);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-icon {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-secondary);
    border-radius: 0.375rem;
    margin-inline-end: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.search-result-item.selected .search-result-icon {
    background-color: var(--primary);
    color: white;
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.search-result-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.search-result-breadcrumb {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.search-result-item.selected .search-result-description,
.search-result-item.selected .search-result-breadcrumb {
    color: var(--primary-readable);
    opacity: 1;
}

/* --------------------------------------
   Footer & Hints
----------------------------------------- */
.search-footer {
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.search-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --------------------------------------
   No Results / No Items Display
----------------------------------------- */
.search-no-items {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.search-no-items i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.search-no-results {
    display: none;
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.search-no-results.show {
    display: block;
}

.search-no-results i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.search-no-results h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

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

/* --------------------------------------
   Highlighted Matches (Scroll Target)
----------------------------------------- */
.search-highlight {
    background-color: rgba(16, 185, 129, 0.1) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    border-radius: var(--radius);
    animation: searchPulse 0.3s ease-in-out;
}

@keyframes searchPulse {
    0% {
        transform: scale(1);
        background-color: rgba(16, 185, 129, 0.2);
    }

    50% {
        transform: scale(1.02);
        background-color: rgba(16, 185, 129, 0.15);
    }

    100% {
        transform: scale(1);
        background-color: rgba(16, 185, 129, 0.1);
    }
}

/* --------------------------------------
   Matched Nav Items
----------------------------------------- */
.nav-item.search-match {
    background-color: var(--primary-light) !important;
    color: var(--primary-readable) !important;
}

.nav-item.search-match::before {
    content: '\f179';
    font-family: dashicons;
    margin-inline-end: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.7;
}

/* --------------------------------------
   Responsive Styles
----------------------------------------- */
@media (max-width: 640px) {
    .search-dropdown {
        position: fixed;
        top: 4rem;
        inset-inline-start: 1rem;
        inset-inline-end: 1rem;
        max-height: 60vh;
    }
}

@media screen and (max-width: 480px) {
    .ctc-settings-search {
        min-width: 100px;
    }

    #ctc-search-input {
        font-size: 0.8rem;
        padding: 0.5rem 2rem 0.5rem 0.625rem;
    }
}

@media (min-width: 640px) {
    .ctc-settings-search {
        min-width: 250px;
    }
}