/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Select Dropdown Widget (SDW)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.fdw {
    position: relative;
    width: 100%;
    font-family: inherit;
    user-select: none;
}

/* Trigger box */
.fdw-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding: 0 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    transition: border-color .18s, box-shadow .18s;
    gap: 8px;
}
.fdw.fdw--open:not(.fdw--drop-up) .fdw-trigger,
.fdw-trigger:hover {
    border-color: #4a5568;
}
/* Mở xuống: bo góc dưới trigger nối panel */
.fdw.fdw--open:not(.fdw--drop-up) .fdw-trigger {
    box-shadow: 0 0 0 3px rgba(74,85,104,.1);
    border-radius: 7px 7px 0 0;
}
/* Mở lên (gần đáy viewport): bo góc trên trigger */
.fdw.fdw--open.fdw--drop-up .fdw-trigger {
    border-color: #4a5568;
    box-shadow: 0 0 0 3px rgba(74,85,104,.1);
    border-radius: 0 0 7px 7px;
}

.fdw-trigger-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.fdw-trigger-icon {
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}
.fdw-trigger-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.fdw-trigger-label {
    font-size: 13.5px;
    color: #2d3748;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fdw-trigger-label.fdw--placeholder { color: #a0aec0; }

/* Nút bỏ chọn (X) — ẩn mặc định; class fdw-clear--visible xử lý hiển thị */
.fdw-clear {
    display: none;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 0 2px 0 0;
    padding: 0;
    border: none;
    background: transparent;
    color: #a0aec0;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
    transition: color .15s, background .15s;
}
.fdw-clear:hover {
    color: #e53e3e;
    background: #fff5f5;
}
.fdw-clear:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.4);
}
.fdw-clear i { font-size: 14px; }

/* Ưu tiên hiển thị nút X khi đã chọn (tránh bị CSS khác đè display) */
.fdw-clear.fdw-clear--visible {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.fdw-arrow {
    color: #a0aec0;
    font-size: 14px;
    flex-shrink: 0;
    transition: transform .18s;
}
.fdw.fdw--open .fdw-arrow { transform: rotate(180deg); }

/* Panel */
/* z-index phải cao hơn modal fullscreen (vd. #modal-product-select 9999999) vì panel append vào body */
.fdw-panel {
    position: fixed;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 9px 9px;
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    z-index: 10000050;
    display: none;
    overflow: hidden;
    animation: fdwFadeIn .12s ease;
}
.fdw-panel.fdw-panel--rounded {
    border-top: 1.5px solid #e2e8f0;
    border-radius: 9px;
}
/* Panel mở phía trên trigger (tránh bị cắt ở cuối trang) */
.fdw-panel.fdw-panel--drop-up.fdw-panel--rounded {
    border-radius: 9px 9px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,.12);
}
@keyframes fdwFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

/* Search box (optional) */
.fdw-search-wrap {
    padding: 8px 10px 4px;
    border-bottom: 1px solid #f0f4f8;
}
.fdw-search {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    color: #2d3748;
    outline: none;
    background: #f8fafc;
    transition: border-color .15s;
}
.fdw-search:focus { border-color: #4a5568; background: #fff; }

/* List */
.fdw-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 5px 0;
}
.fdw-list::-webkit-scrollbar { width: 4px; }
.fdw-list::-webkit-scrollbar-track { background: transparent; }
.fdw-list::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }

/* Option item */
.fdw-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    transition: background .1s;
    border-radius: 0;
}
.fdw-option:hover { background: #f7fafc; }
.fdw-option.fdw-option--active {
    background: #ebf4ff;
}
.fdw-option.fdw-option--active:hover { background: #dbeafe; }

.fdw-option-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}
.fdw-option-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.fdw-option-body { flex: 1; min-width: 0; }
.fdw-option-label {
    font-size: 13.5px;
    color: #2d3748;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fdw-option--active .fdw-option-label { color: #1a56db; }
.fdw-option-desc {
    font-size: 11.5px;
    color: #9ca3af;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fdw-option-check {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .12s;
}
.fdw-option--active .fdw-option-check {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}
.fdw-option--active .fdw-option-check::after {
    content: '✓';
    font-size: 9px;
    font-weight: 700;
}

/* Phân cấp thư mục (data-level 0/1/2) */
.fdw-option.fdw-option--tree {
    border-left: 2px solid transparent;
}
.fdw-option.fdw-option--tree[data-level="1"] { border-left-color: #e2e8f0; }
.fdw-option.fdw-option--tree[data-level="2"] { border-left-color: #cbd5e1; }
.fdw-option.fdw-option--tree .fdw-option-icon { min-width: 1.1em; }

/* Empty state */
.fdw-empty {
    padding: 12px 14px;
    font-size: 13px;
    color: #a0aec0;
    text-align: center;
}

/* Group header */
.fdw-group-label {
    padding: 7px 14px 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #94a3b8;
    cursor: default;
    user-select: none;
}
.fdw-group-label:not(:first-child) {
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
    padding-top: 9px;
}

/* Theme Hội doanh nghiệp — đồng bộ màu navy/gold */
.fdw-trigger {
    min-height: 48px;
    border-radius: var(--hdn-radius-sm, 8px);
    border-color: var(--hdn-border, #e7eaf0);
}
.fdw-trigger:hover,
.fdw.fdw--open:not(.fdw--drop-up) .fdw-trigger,
.fdw.fdw--open.fdw--drop-up .fdw-trigger {
    border-color: var(--hdn-navy-light, #14345f);
    box-shadow: 0 0 0 3px rgba(11, 36, 71, 0.08);
}
.fdw-trigger-label { font-size: 14px; color: var(--hdn-ink, #1c2733); }
.fdw-option--active { background: rgba(11, 36, 71, 0.06); }
.fdw-option--active .fdw-option-label { color: var(--hdn-navy, #0b2447); font-weight: 600; }
.fdw-option-check { border-color: var(--hdn-navy-light, #14345f); }
.fdw-option--active .fdw-option-check { background: var(--hdn-navy, #0b2447); border-color: var(--hdn-navy, #0b2447); }
.fdw-panel { border-color: var(--hdn-border, #e7eaf0); z-index: 10050; }
