/**
 * Search Sidebar
 * ==============
 * Search controls that use the same row rhythm as the left sidebar nav.
 */

/* ============================================
   SIDEBAR COLUMN (stacks search + nav)
   ============================================ */
.tb-sidebar-column {
    width: var(--tb-sidebar-width, 280px);
    min-width: var(--tb-sidebar-width, 280px);
    flex-shrink: 0;
    position: sticky;
    top: 100px;
    height: fit-content;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.tb-sidebar-column::-webkit-scrollbar {
    width: 6px;
}

.tb-sidebar-column::-webkit-scrollbar-thumb {
    background: var(--accent-color, #8ED1B0);
    border-radius: 3px;
}

.tb-sidebar-column .tb-sidebar {
    position: relative;
    top: 0;
    max-height: none;
    overflow-y: visible;
}

/* ============================================
   SEARCH BOX (integrated sidebar control)
   ============================================ */
.tb-search-box {
    padding: 0.75rem var(--tb-sidebar-row-x, 1.5rem) 0.45rem;
    background: transparent;
    border-right: 0;
}

.tb-search-box:has(+ .tb-sidebar--sort) {
    padding-bottom: 0.45rem;
}

.sidebar-layout__aside .tb-search-box {
    border-right: 0;
}

.sidebar-layout__aside .tb-search-box + .tb-sidebar {
    padding-top: 0;
}

.tb-search-box .tb-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 44px;
    border: 1px solid var(--editor-primary, var(--primary-color, #00618F));
    border-radius: 8px;
    background: transparent;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.tb-search-leading-icon {
    position: absolute;
    left: 0.85rem;
    z-index: 2;
    width: 1.1rem;
    color: var(--primary-color, #00618F);
    font-size: 1.08rem;
    line-height: 1;
    text-align: center;
    pointer-events: none;
    transition: color 0.2s ease;
}

.tb-search-box .tb-search-input {
    width: 100%;
    min-height: 42px;
    padding: 0.68rem 4.15rem 0.68rem 2.55rem;
    border: 0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark, #1a202c);
    background: transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    outline: none !important;
}

.tb-search-box .tb-search-input:hover,
.tb-search-box .tb-search-input:focus,
.tb-search-box .tb-search-input:focus-visible,
.tb-search-box .tb-search-input.has-value {
    background: transparent;
    outline: none !important;
    box-shadow: none !important;
}

.tb-search-input-wrap:hover,
.tb-search-input-wrap:has(.tb-search-input:focus),
.tb-search-input-wrap:has(.tb-search-input.has-value) {
    border-color: var(--accent-color, #8ED1B0);
    background: #ffffff;
}

.tb-search-input-wrap:has(.tb-search-input:focus) .tb-search-leading-icon,
.tb-search-input-wrap:has(.tb-search-input.has-value) .tb-search-leading-icon {
    color: var(--accent-color, #8ED1B0);
}

.tb-search-box .tb-search-input::placeholder {
    color: var(--text-muted, #6b7280);
    font-size: 0.92rem;
    font-weight: 500;
}

.tb-search-icon-btn {
    position: absolute;
    right: 0.45rem;
    top: 50%;
    z-index: 3;
    width: 28px;
    height: 28px;
    transform: translateY(-50%);
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--primary-color, #00618F);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    outline: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.tb-search-icon-btn:hover {
    background: rgba(0, 97, 143, 0.08);
    color: var(--accent-color, #8ED1B0);
    transform: translateY(-50%) scale(1.04);
}

.tb-search-icon-btn:focus,
.tb-search-icon-btn:focus-visible,
.tb-search-icon-btn:active {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.tb-search-clear {
    position: absolute;
    right: 2.28rem;
    top: 50%;
    z-index: 3;
    width: 26px;
    height: 26px;
    transform: translateY(-50%);
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted, #6b7280);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.tb-search-clear:hover {
    background: rgba(107, 114, 128, 0.12);
    color: var(--text-dark, #1a202c);
}

.tb-search-clear:focus,
.tb-search-clear:focus-visible,
.tb-search-clear:active {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.tb-search-clear.visible {
    display: flex;
}

.tb-search-icon-btn .tb-search-icon-arrow {
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

.tb-search-input.has-value ~ .tb-search-icon-btn .tb-search-icon-arrow,
.tb-search-icon-btn:hover .tb-search-icon-arrow {
    transform: translateX(1px);
}

[data-theme="dark"] .tb-search-box,
.dark-mode .tb-search-box {
    border-right-color: transparent;
}

[data-theme="dark"] .tb-search-box .tb-search-input,
.dark-mode .tb-search-box .tb-search-input {
    color: var(--text-dark, #e8e9ea);
}

[data-theme="dark"] .tb-search-box .tb-search-input-wrap,
.dark-mode .tb-search-box .tb-search-input-wrap {
    border-color: var(--primary-color, #9fd2ff);
}

[data-theme="dark"] .tb-search-leading-icon,
[data-theme="dark"] .tb-search-icon-btn,
.dark-mode .tb-search-leading-icon,
.dark-mode .tb-search-icon-btn {
    color: var(--primary-color, #9fd2ff);
}

[data-theme="dark"] .tb-search-box .tb-search-input::placeholder,
.dark-mode .tb-search-box .tb-search-input::placeholder,
[data-theme="dark"] .tb-search-clear,
.dark-mode .tb-search-clear {
    color: var(--text-muted, #a0aec0);
}

[data-theme="dark"] .tb-search-box .tb-search-input:hover,
[data-theme="dark"] .tb-search-box .tb-search-input:focus,
[data-theme="dark"] .tb-search-box .tb-search-input:focus-visible,
[data-theme="dark"] .tb-search-box .tb-search-input.has-value,
.dark-mode .tb-search-box .tb-search-input:hover,
.dark-mode .tb-search-box .tb-search-input:focus,
.dark-mode .tb-search-box .tb-search-input:focus-visible,
.dark-mode .tb-search-box .tb-search-input.has-value {
    background: transparent;
}

[data-theme="dark"] .tb-search-input-wrap:hover,
[data-theme="dark"] .tb-search-input-wrap:has(.tb-search-input:focus),
[data-theme="dark"] .tb-search-input-wrap:has(.tb-search-input.has-value),
.dark-mode .tb-search-input-wrap:hover,
.dark-mode .tb-search-input-wrap:has(.tb-search-input:focus),
.dark-mode .tb-search-input-wrap:has(.tb-search-input.has-value) {
    border-color: var(--accent-color, #9ee1c0);
    background: #121820;
}

[data-theme="dark"] .tb-search-input-wrap:has(.tb-search-input:focus) .tb-search-leading-icon,
[data-theme="dark"] .tb-search-input-wrap:has(.tb-search-input.has-value) .tb-search-leading-icon,
[data-theme="dark"] .tb-search-icon-btn:hover,
.dark-mode .tb-search-input-wrap:has(.tb-search-input:focus) .tb-search-leading-icon,
.dark-mode .tb-search-input-wrap:has(.tb-search-input.has-value) .tb-search-leading-icon,
.dark-mode .tb-search-icon-btn:hover {
    color: var(--accent-color, #9ee1c0);
}

[data-theme="dark"] .tb-search-clear:hover,
.dark-mode .tb-search-clear:hover {
    background: rgba(160, 174, 192, 0.14);
    color: #f4f7fa;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
    .tb-sidebar-column {
        width: 100%;
        min-width: 100%;
        position: relative;
        top: 0;
        max-height: none;
        overflow-y: visible;
    }

    .tb-search-box {
        border-right: none;
    }
}
