/* ==========================================================================
   Search UI — Panel, Results, Bubble, Header Inputs
   ========================================================================== */

/* ===== Header Search Input ===== */
.search-header-input {
    width: 140px;
    padding: 5px 10px;
    font-size: var(--font-size-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    outline: none;
    transition: width 0.2s, border-color 0.2s;
    font-family: var(--font-family-content);
}

.search-header-input:focus {
    width: 200px;
    border-color: var(--accent-blue);
}

.search-header-input::placeholder {
    color: var(--text-muted);
}

/* ===== Search Panel ===== */
.search-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    z-index: 900;
    transition: right 0.25s ease;
    font-family: var(--font-family-content);
}

.search-panel.open {
    right: 0;
}

.search-panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.search-panel-input {
    flex: 1;
    padding: 8px 12px;
    font-size: var(--font-size-base);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.2s;
}

.search-panel-input:focus {
    border-color: var(--accent-blue);
}

.search-panel-input::placeholder {
    color: var(--text-muted);
}

.search-result-count {
    font-size: var(--font-size-sm-md);
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Results Body ===== */
.search-results-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

.search-empty {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
    font-size: var(--font-size-base);
}

/* ===== Result Group Headers ===== */
.search-source-header {
    font-size: var(--font-size-sm-md);
    font-weight: 700;
    color: var(--text-primary);
    padding: var(--space-sm) var(--space-sm) 2px;
    margin-top: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.search-source-header:first-child {
    margin-top: 0;
}

.search-group-subheader {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px var(--space-sm) 2px var(--space-md);
}

.search-level-header {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-muted);
    padding: 3px var(--space-sm) 1px calc(var(--space-md) + var(--space-sm));
}

/* ===== Result Items ===== */
.search-result-item {
    padding: var(--space-xs) var(--space-sm) var(--space-xs) calc(var(--space-md) + var(--space-md));
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
}

.search-result-item:hover {
    background: var(--bg-secondary);
}

.search-type-badge {
    display: inline-flex;
    align-items: center;
    font-size: var(--font-size-2xs);
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.search-type-content {
    color: #fff;
    background: var(--accent-green, #10b981);
}

.search-type-question {
    color: #fff;
    background: var(--accent-blue, #4361ee);
}

.search-type-transcript {
    color: #fff;
    background: #8b5cf6;
}

.search-subtype {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-match-text {
    width: 100%;
    font-size: var(--font-size-md);
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-match-text mark {
    background: rgba(245, 158, 11, 0.35);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ===== Search Bubble ===== */
.search-bubble {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-blue, #4361ee);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 901;
    transition: transform 0.15s, box-shadow 0.15s;
}

.search-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.search-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    font-size: var(--font-size-xs);
    font-weight: 700;
    background: var(--accent-red, #ef4444);
    color: #fff;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .search-panel {
        width: 100vw;
        right: -100vw;
    }

    .search-header-input {
        width: 100px;
    }

    .search-header-input:focus {
        width: 150px;
    }
}
