/* ============================================================
   Bunny Smart Search Bar — Frontend Styles
   ============================================================ */

/* CSS custom properties are set inline per widget instance.
   Fallbacks here cover any edge cases. */

.bsb-wrap {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

/* ---- Form & input row ---- */
.bsb-form {
    position: relative;
    width: 100%;
}

.bsb-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bsb-input-bg, #fff);
    border: 1px solid var(--bsb-border, #ddd);
    border-radius: var(--bsb-radius, 4px);
    box-shadow: var(--bsb-shadow, none);
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.bsb-input-wrap:focus-within {
    border-color: var(--bsb-highlight, #c9a84c);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bsb-highlight, #c9a84c) 20%, transparent);
}

.bsb-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 10px 14px;
    font-size: var(--bsb-font-size, 14px);
    color: var(--bsb-input-text, #333);
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
}

.bsb-input::placeholder {
    color: color-mix(in srgb, var(--bsb-input-text, #333) 50%, transparent);
}

/* Hide browser default clear/search decorations */
.bsb-input::-webkit-search-decoration,
.bsb-input::-webkit-search-cancel-button {
    display: none;
}

/* ---- Button ---- */
.bsb-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    background: var(--bsb-btn-bg, #c9a84c);
    border: none;
    outline: none;
    cursor: pointer;
    color: var(--bsb-btn-icon, #fff);
    transition: opacity 0.15s ease;
}

.bsb-btn:hover {
    opacity: 0.85;
}

.bsb-btn svg {
    display: block;
    stroke: var(--bsb-btn-icon, #fff);
    fill: var(--bsb-btn-icon, #fff);
}

/* ---- Dropdown ---- */
.bsb-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bsb-dropdown-bg, #fff);
    border: 1px solid var(--bsb-dropdown-border, #eee);
    border-radius: var(--bsb-radius, 4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    overflow: hidden;
    animation: bsb-fade-in 0.15s ease;
}

.bsb-dropdown[hidden] {
    display: none;
}

@keyframes bsb-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Result items ---- */
.bsb-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--bsb-dropdown-text, #333);
    border-bottom: 1px solid var(--bsb-dropdown-border, #eee);
    transition: background 0.12s ease;
}

.bsb-result-item:last-of-type {
    border-bottom: none;
}

.bsb-result-item:hover,
.bsb-result-item:focus {
    background: color-mix(in srgb, var(--bsb-highlight, #c9a84c) 10%, transparent);
    outline: none;
}

.bsb-result-img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: calc(var(--bsb-radius, 4px) / 2);
    flex-shrink: 0;
    background: #f5f5f5;
}

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

.bsb-result-title {
    font-size: var(--bsb-font-size, 14px);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--bsb-dropdown-text, #333);
}

.bsb-result-price {
    font-size: calc(var(--bsb-font-size, 14px) - 1px);
    color: var(--bsb-highlight, #c9a84c);
    margin-top: 2px;
}

.bsb-result-price .amount {
    font-weight: 600;
}

/* ---- View all / no results / loading ---- */
.bsb-view-all {
    display: block;
    padding: 10px 14px;
    text-align: center;
    font-size: calc(var(--bsb-font-size, 14px) - 1px);
    font-weight: 600;
    color: var(--bsb-highlight, #c9a84c);
    text-decoration: none;
    border-top: 1px solid var(--bsb-dropdown-border, #eee);
    background: color-mix(in srgb, var(--bsb-highlight, #c9a84c) 5%, transparent);
    transition: background 0.12s ease;
}

.bsb-view-all:hover {
    background: color-mix(in srgb, var(--bsb-highlight, #c9a84c) 15%, transparent);
}

.bsb-no-results,
.bsb-loading {
    padding: 14px;
    text-align: center;
    font-size: var(--bsb-font-size, 14px);
    color: color-mix(in srgb, var(--bsb-dropdown-text, #333) 60%, transparent);
}

.bsb-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid color-mix(in srgb, var(--bsb-highlight, #c9a84c) 30%, transparent);
    border-top-color: var(--bsb-highlight, #c9a84c);
    border-radius: 50%;
    animation: bsb-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-left: 6px;
}

@keyframes bsb-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Left icon variant (.bsb-icon-left)
   ============================================================ */

.bsb-icon-left .bsb-icon-left-icon,
.bsb-icon-left .bsb-icon-left {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px 0 14px;
    color: var(--bsb-input-text, #333);
    flex-shrink: 0;
    pointer-events: none;
}

.bsb-icon-left .bsb-icon-left svg {
    display: block;
    stroke: var(--bsb-input-text, #333);
    fill: var(--bsb-input-text, #333);
    opacity: 0.5;
}

.bsb-icon-left .bsb-input {
    padding-left: 6px;
}

/* ============================================================
   Text button variant (.bsb-btn-text)
   ============================================================ */

.bsb-btn.bsb-btn-text {
    padding: 7px 20px;
    margin: 5px;
    border-radius: calc(var(--bsb-radius, 4px) - 2px);
    font-size: calc(var(--bsb-font-size, 14px) - 1px);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bsb-btn-icon, #fff);
    line-height: 1;
    white-space: nowrap;
}

.bsb-btn.bsb-btn-text .bsb-btn-label {
    display: block;
}

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet portrait and below */
@media (max-width: 768px) {
    .bsb-input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 9px 12px;
    }

    .bsb-btn {
        padding: 9px 12px;
    }

    .bsb-result-img {
        width: 38px;
        height: 38px;
    }

    .bsb-dropdown {
        left: -1px;
        right: -1px;
        border-radius: 0 0 var(--bsb-radius, 4px) var(--bsb-radius, 4px);
    }
}

/* Mobile */
@media (max-width: 480px) {
    .bsb-result-item {
        padding: 8px 10px;
        gap: 10px;
    }

    .bsb-result-img {
        width: 34px;
        height: 34px;
    }
}
