/* ==========================================================================
   AppBar Search — Command Palette (chỉ giao diện)
   - Desktop (>= 768px): nút icon cạnh nhóm actions; bấm mở palette giữa màn hình
   - Mobile  (<  768px): nút icon cuối dòng 1; bấm mở rộng thành ô nhập toàn dòng
   ========================================================================== */

.appbar-search {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

/* Ô nhập mở rộng — mặc định ẩn trên desktop */
.appbar-search__inline {
    display: none;
}

/* Dropdown kết quả + backdrop — chỉ dùng trên mobile */
.appbar-search__drop,
.appbar-search__backdrop {
    display: none;
}

.appbar-search__inline-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 34px;
    padding: 0 12px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    outline: none;
    font-size: 0.9rem;
}

.appbar-search__inline-input::placeholder {
    color: rgba(255, 255, 255, 0.75);
}

/* ===== Command Palette overlay ===== */
.asp-overlay {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
}

.asp-palette {
    width: min(600px, 92vw);
    background: var(--mud-palette-surface, #ffffff);
    color: var(--mud-palette-text-primary, #111111);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

.asp-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
}

.asp-input {
    flex: 1 1 auto;
    border: none;
    outline: none;
    background: transparent;
    color: inherit;
    font-size: 0.92rem;
}

.asp-input::placeholder {
    color: rgba(128, 128, 128, 0.8);
}

.asp-esc {
    flex: 0 0 auto;
    padding: 1px 5px;
    border: 1px solid rgba(128, 128, 128, 0.4);
    border-radius: 5px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #888888;
    white-space: nowrap;
}

.asp-body {
    max-height: 56vh;
    overflow-y: auto;
    padding: 4px 6px 8px;
}

/* ===== Nhóm kết quả (Chức năng / Khách hàng / Chứng từ …) ===== */
.asp-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 8px 3px;
}

.asp-group__icon {
    font-size: 14px !important;
    color: #aaaaaa;
}

.asp-group__title {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999999;
}

.asp-group__count {
    margin-left: 2px;
    padding: 0 5px;
    border-radius: 8px;
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 14px;
    background: rgba(128, 128, 128, 0.16);
    color: #888888;
}

.asp-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1.25;
}

.asp-item:hover,
.asp-item--selected {
    background: rgba(128, 128, 128, 0.12);
}

.asp-item__icon {
    flex: 0 0 auto;
    font-size: 17px !important;
    color: #888888;
}

.asp-item__title {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asp-item__breadcrumb {
    flex: 0 1 auto;
    max-width: 42%;
    font-size: 0.68rem;
    color: #999999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asp-item__enter {
    flex: 0 0 auto;
    font-size: 15px !important;
    opacity: 0;
    color: #888888;
}

.asp-item--selected .asp-item__enter {
    opacity: 0.7;
}

.asp-badge {
    display: inline-block;
    margin-left: 3px;
    padding: 0 3px;
    border-radius: 3px;
    font-size: 0.56rem;
    font-weight: 700;
    vertical-align: middle;
    background: rgba(128, 128, 128, 0.2);
    color: #777777;
}

.asp-badge--lock {
    background: rgba(211, 47, 47, 0.15);
    color: #d32f2f;
}

.asp-empty {
    padding: 14px;
    text-align: center;
    font-size: 0.8rem;
    color: #999999;
}

/* ==========================================================================
   Mobile (< 768px)
   ========================================================================== */
@media (max-width: 767px) {

    /* Không dùng palette overlay trên mobile */
    .asp-overlay {
        display: none;
    }

    /* Ô nhập mở rộng full-width cố định trên đỉnh (thay cho dòng 1) */
    .appbar-search--open {
        flex: 1 1 auto;
    }

    .appbar-search__inline {
        display: flex;
        align-items: center;
        gap: 6px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1300;
        height: 56px;
        padding: 0 12px;
        box-sizing: border-box;
        background: var(--mud-palette-primary, #1976d2);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    }

    /* Backdrop mờ phía sau dropdown */
    .appbar-search__backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1298;
        background: rgba(0, 0, 0, 0.25);
    }

    /* Dropdown kết quả ngay dưới ô nhập */
    .appbar-search__drop {
        display: block;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        z-index: 1299;
        max-height: 60vh;
        overflow-y: auto;
        box-sizing: border-box;
        padding: 8px;
        background: var(--mud-palette-surface, #ffffff);
        color: var(--mud-palette-text-primary, #111111);
        border-radius: 0 0 12px 12px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    }
}
