/* ── Busca Rápida — CdA Ferramentas ───────────────────────────────────────── */

.cdaf-busca-widget {
    position: relative;
    width: 100%;
}

/* Campo desktop */
.cdaf-busca-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    height: 42px;
}
.cdaf-busca-wrap:focus-within {
    border-color: #d1d5db;
}

.cdaf-busca-icon {
    color: #9ca3af;
    line-height: 0;
    flex-shrink: 0;
    order: 2;
}

.cdaf-busca-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    -webkit-appearance: none;
    background: transparent;
    font-size: 14px;
    color: #111827;
    padding: 0;
    min-width: 0;
    box-shadow: none !important;
    height: 100%;
}
.cdaf-busca-input::placeholder { color: #9ca3af; }
.cdaf-busca-input::-webkit-search-cancel-button { display: none; }

.cdaf-busca-clear {
    background-color: #9ca3af;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #ffffff;
    line-height: 0;
    border-radius: 4px;
    flex-shrink: 0;
    transition: background-color .15s;
    order: 3;
}
.cdaf-busca-clear:hover { background-color: #6b7280; }
.cdaf-busca-clear[hidden] { display: none; }

/* Dropdown de resultados */
.cdaf-busca-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    list-style: none;
    margin: 0;
    padding: 6px 0;
    z-index: 9999;
    max-height: 420px;
    overflow-y: auto;
}
.cdaf-busca-results[hidden] { display: none; }

.cdaf-busca-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s;
    border-bottom: 1px solid #f3f4f6;
}
.cdaf-busca-result-item:last-child { border-bottom: none; }
.cdaf-busca-result-item:hover { background: #f9fafb; }
.cdaf-busca-result-item.is-active { background: #f0f4ff; }

.cdaf-busca-result-thumb {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #f3f4f6;
    flex-shrink: 0;
    background: #fff;
}

.cdaf-busca-result-info {
    flex: 1;
    min-width: 0;
}

.cdaf-busca-result-name {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cdaf-busca-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.cdaf-busca-result-sku {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 4px;
    padding: 1px 5px;
    letter-spacing: 0.01em;
    flex-shrink: 0;
}

.cdaf-busca-result-price {
    font-size: 12px;
    font-weight: 700;
    color: #16a34a;
}

/* Estado: carregando */
.cdaf-busca-results-loading {
    padding: 16px 14px;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
}

/* Estado: sem resultados */
.cdaf-busca-results-empty {
    padding: 16px 14px;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
}

/* ── Mobile: só lupa ────────────────────────────────────────────────────────── */
.cdaf-busca-mobile-btn {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #374151;
    line-height: 0;
}

@media (max-width: 767px) {
    .cdaf-busca-desktop { display: none !important; }
    .cdaf-busca-mobile-btn { display: inline-flex; align-items: center; }
}
@media (min-width: 768px) {
    .cdaf-busca-mobile-btn { display: none !important; }
    .cdaf-busca-mobile-overlay { display: none !important; }
}

/* Overlay mobile com campo expandido no topo */
.cdaf-busca-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.cdaf-busca-mobile-overlay[hidden] { display: none; }

.cdaf-busca-mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.1);
}

.cdaf-busca-mobile-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #6b7280;
    line-height: 0;
    flex-shrink: 0;
}

/* Resultados mobile: lista branca abaixo da barra */
.cdaf-busca-results-mobile {
    position: static;
    border-radius: 0;
    border: none;
    border-top: 1px solid #f0f0f0;
    box-shadow: none;
    max-height: calc(100vh - 64px);
}
