/* RBM Search Widget - Container-based Expand/Collapse */

.rbm-search {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 48px;
    overflow: hidden;
}

/* ============================================
   SEARCH PANEL (Expandable, 100% width when open)
   ============================================ */

.rbm-search__panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(135deg, rgba(62, 95, 130, 0.98) 0%, rgba(48, 75, 105, 0.98) 100%);
    backdrop-filter: blur(12px);
    overflow: hidden;
    border: none;
    box-shadow: none;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
}

/* When alignment is 'right', panel comes from right */
.rbm-search[data-alignment="right"] .rbm-search__panel {
    left: auto;
    right: 0;
}

/* Open state - expand to 100% */
.rbm-search.is-open .rbm-search__panel {
    width: 100%;
}

.rbm-search__panel-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px;
    position: relative;
}

/* ============================================
   CLOSE BUTTON (X)
   ============================================ */

.rbm-search__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.2s;
    z-index: 101;
}

.rbm-search__close:hover {
    color: #fff;
}

.rbm-search__close svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ============================================
   FORM & INPUT STYLES
   ============================================ */

.rbm-search__form {
    margin: 0 0 16px 0;
    padding: 0;
    border: none;
}

.rbm-search__input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.rbm-search__input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #666;
}

.rbm-search__input-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.rbm-search__input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px 0;
    font-size: 14px;
    color: #333;
    outline: none;
    font-family: inherit;
    font-weight: 500;
}

.rbm-search__input::placeholder {
    color: #999;
    font-weight: 400;
}

.rbm-search__input::-webkit-search-cancel-button {
    display: none;
}

/* Clear Button */
.rbm-search__clear {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px 8px;
    transition: opacity 0.2s;
    flex-shrink: 0;
    color: #666;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rbm-search__clear:hover {
    opacity: 0.7;
}

/* ============================================
   RESULTS CONTAINER
   ============================================ */

.rbm-search__results {
    flex: 1;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.rbm-search__results::-webkit-scrollbar {
    width: 6px;
}

.rbm-search__results::-webkit-scrollbar-track {
    background: transparent;
}

.rbm-search__results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.rbm-search__results::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Results Header */
.rbm-search__results-header {
    padding: 12px 0 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 12px;
}

.rbm-search__results-title {
    margin: 0;
    padding: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
}

/* Results List */
.rbm-search__results-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ============================================
   RESULT ITEM
   ============================================ */

.rbm-search__results-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: background-color 0.15s;
    border-radius: 4px;
}

.rbm-search__results-item:last-child {
    border-bottom: none;
}

.rbm-search__results-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.rbm-search__results-item:active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Result Image/Flag */
.rbm-search__results-image {
    width: 40px;
    height: 40px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Result Content */
.rbm-search__results-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rbm-search__results-item-title {
    margin: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rbm-search__results-item-desc {
    margin: 0;
    padding: 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Result Price */
.rbm-search__results-item-price {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

/* ============================================
   TOGGLE BUTTON (Search Icon / Lupa)
   ============================================ */

.rbm-search__toggle {
    position: relative;
    z-index: 51;
    width: 48px;
    height: 48px;
    min-width: 48px;
    border: none;
    background: #db0a40;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.2s ease;
    color: #fff;
    opacity: 1;
    visibility: visible;
}

.rbm-search__toggle:hover {
    background: #c20836;
    box-shadow: 0 2px 8px rgba(219, 10, 64, 0.3);
}

.rbm-search__toggle:active {
    background: #a90730;
}

/* Hide button when panel is open */
.rbm-search.is-open .rbm-search__toggle {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.rbm-search__toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
}

/* ============================================
   STATUS MESSAGES
   ============================================ */

.rbm-search__loading,
.rbm-search__no-results,
.rbm-search__error {
    padding: 20px 12px;
    text-align: center;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.rbm-search__error {
    color: #ff6b6b;
}

/* ============================================
   RESPONSIVE - TABLET (768px and below)
   ============================================ */

@media (max-width: 768px) {
    .rbm-search {
        min-height: 44px;
    }

    .rbm-search__toggle {
        width: 44px;
        height: 44px;
    }

    .rbm-search__toggle svg {
        width: 18px;
        height: 18px;
    }

    .rbm-search__close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }

    .rbm-search__close svg {
        width: 20px;
        height: 20px;
    }

    .rbm-search__panel-inner {
        padding: 12px;
    }
}

/* ============================================
   RESPONSIVE - MOBILE (480px and below)
   ============================================ */

@media (max-width: 480px) {
    .rbm-search {
        min-height: 40px;
    }

    .rbm-search__toggle {
        width: 40px;
        height: 40px;
    }

    .rbm-search__toggle svg {
        width: 16px;
        height: 16px;
    }

    .rbm-search__close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
    }

    .rbm-search__close svg {
        width: 18px;
        height: 18px;
    }

    .rbm-search__panel-inner {
        padding: 10px;
    }

    .rbm-search__form {
        margin: 0 0 12px 0;
    }

    .rbm-search__input-wrapper {
        padding: 8px 10px;
        gap: 10px;
    }

    .rbm-search__input {
        font-size: 16px;
    }

    .rbm-search__clear {
        font-size: 11px;
        padding: 3px 6px;
    }

    .rbm-search__results-item {
        padding: 10px 6px;
        gap: 10px;
    }

    .rbm-search__results-image {
        width: 36px;
        height: 36px;
    }

    .rbm-search__results-item-title {
        font-size: 13px;
    }

    .rbm-search__results-item-price {
        font-size: 12px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.rbm-search__toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.rbm-search__close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: -2px;
}

.rbm-search__input:focus-visible {
    outline: none;
}
