/**
 * Custom Employee Dropdown Styles
 * Matches the Figma design (rounded card + avatar list + search box).
 */

.ced-wrapper {
    position: relative;
    width: 100%;
    font-family: "Prompt", "Inter", "Sarabun", sans-serif;
    font-size: 14px;
    color: #1f2933;
}

.ced-wrapper * {
    box-sizing: border-box;
}

.ced-display {
    width: 100%;
    border: 1px solid #c2c2c2;
    border-radius: 12px;
    background: #ffffff;
    padding: 8px 16px;
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    /* transition: box-shadow 0.2s ease, border-color 0.2s ease; */
}

.ced-display:focus {
    outline: none;
}

.ced-display:focus-visible,
.ced-display:focus,
.ced-display:hover {
    border: 1px solid #0072bc;
    /* box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.12); */
}

/* Error state (used by formErrors in custom-toast.js) */
.ced-wrapper.error .ced-display,
.ced-wrapper.error .ced-display:hover,
.ced-wrapper.error .ced-display:focus,
.ced-wrapper.error .ced-display:focus-visible {
    border: 1px solid #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.08);
}

.ced-display-info {
    flex: 1;
    text-align: left;
    min-width: 0; /* จำเป็นสำหรับ ellipsis ใน flex container */
    overflow: hidden;
}

.ced-display-line1 {
    font-weight: 600;
    color: var(--gray-700);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* สี placeholder เมื่อยังไม่เลือก */
.ced-display-line1.ced-is-placeholder {
    color: var(--gray-400);
}

.ced-display-line2 {
    font-size: 12px;
    color: var(--gray-400);
    line-height: 1.2;
}

.ced-caret {
    width: 8px;
    height: 8px;
    border-right: 1px solid #858585;
    border-bottom: 1px solid #858585;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.ced-dropdown.is-open ~ .ced-display .ced-caret,
.ced-wrapper:has(.ced-dropdown.is-open) .ced-caret,
.ced-display[aria-expanded="true"] .ced-caret {
    transform: rotate(-135deg);
}

.ced-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 12px;
    display: none;
    z-index: 20;
    border: 1px solid #c2c2c2;
}

.ced-dropdown.is-open {
    display: block;
}

.ced-dropdown.is-open ~ .ced-display,
.ced-wrapper:has(.ced-dropdown.is-open) .ced-display {
    border: 1px solid #0072bc;
    /* box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.12); */
}

.ced-dropdown::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 36px;
    width: 0;
    height: 0;
    
}

.ced-search-wrapper {
    margin-bottom: 12px;
}

.ced-search {
    width: 100%;
    border: 1px solid #e4e7ec;
    background: #f9fafb;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--gray-700);
}

.ced-search:focus {
    outline: none;
    border: 1px solid #0072bc;
}

.ced-list {
    max-height: 260px;
    overflow-y: auto;
}

.ced-list::-webkit-scrollbar {
    width: 4px;
}

.ced-list::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.2);
    border-radius: 999px;
}

.ced-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    margin-bottom: 11px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
    justify-content: space-between;
}

.ced-option:last-child {
    margin-bottom: 0;
}

.ced-option:hover {
    background-color: #FAFAFA;
    color: #0072bc;
}

.ced-option.is-active {
    background-color: #FAFAFA;
    color: #0072bc;
    font-weight: 600;
}

.ced-option .check-icon {
    display: none;
    margin-left: 8px;
    flex-shrink: 0;
    color: #0072bc;
}

.ced-option.is-active .check-icon {
    display: inline-block;
}

.ced-avatar {
    width: 33px;
    height: 33px;
    border-radius: 24.115px;
    overflow: hidden;
    flex-shrink: 0;
}

.ced-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ced-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.ced-line1 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
}

.ced-line2 {
    font-size: 12px;
    color: var(--gray-400);
}

.ced-empty {
    text-align: center;
    padding: 20px 0;
    font-size: 13px;
    color: var(--gray-400);
}

@media (max-width: 480px) {
    .ced-dropdown {
        width: calc(100vw - 40px);
        left: 50%;
        transform: translateX(-50%);
    }

    .ced-dropdown::before {
        display: none;
    }
}
/* ==========================================================================
   Refactored Dropdown Styles (Custom + Fitter)
   – สอดคล้องกับ JS Module (Full)
   – รองรับ: open/show/drop-up, คีย์บอร์ด, single-tag UI, multi-select
   ========================================================================== */

/* ---------- Theme tokens (แก้สีได้ที่นี่) ---------- */
:root {
    /* สีชุดที่คุณอยากใช้จริง ให้เหลือชุดเดียวนี้ */
    --clr-border: #c2c2c2; /* <- เอาค่าจากก้อนล่าง */
    --clr-border-strong: #0072bc;
    --clr-bg: #fff;
    --clr-text: #233043;
    --clr-muted: #98a6b5;
    --clr-hover: #f3f4f6;
    --clr-active: #e5e7eb;
    --clr-focus-ring: rgba(30, 136, 229, 0.12);
    --radius: 12px;
    /* hrsolution_layout stacks modals at 1050 + (count * 20) — keep above all */
    --z-dropdown: 10000;
}

/* ========================================================================== */
/*                               CUSTOM DROPDOWN                              */
/* ========================================================================== */

.custom-dropdown-container {
    position: relative;
    width: 100%;
}
.custom-dropdown-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    min-height: 38px;
    cursor: pointer;
    border: 1px solid #c2c2c2;
    border-radius: 12px;
    background: #ffffff;
    color: var(--clr-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.custom-dropdown-input:hover {
    border: 1px solid #0072bc;
}
.custom-dropdown-input:focus,
.custom-dropdown-input:focus-within {
    outline: none;
    border: 1px solid #0072bc;
}
.custom-dropdown-container.open .custom-dropdown-input {
    border: 1px solid #0072bc;
}

.selected-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    padding-left: 12px;
    padding-right: 24px; /* reserve area for arrow */
}
.dropdown-unit {
    font-size: 14px;
    color: var(--clr-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}

/* Unit alignment */
.custom-dropdown-container[data-unit-align="left"] .dropdown-unit {
    order: 2;
    margin-left: 0 !important;
    margin-right: auto;
    flex-shrink: 0;
}
.custom-dropdown-container[data-unit-align="center"] .dropdown-unit {
    order: 2;
    margin-left: auto;
    margin-right: auto;
}
.custom-dropdown-container[data-unit-align="right"] .dropdown-unit {
    order: 1;
    margin-left: auto;
    margin-right: 4px;
}

/* When unit is on the right, adjust selected-value */
.custom-dropdown-container[data-unit-align="right"] .selected-value {
    order: 2;
}

/* Arrow (ใช้รูปเดิมได้) */
.dropdown-arrow {
    width: 32px;
    height: 100%;
    position: absolute;
    right: 8px;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.dropdown-arrow::after {
    content: "";
}
.dropdown-arrow i {
    font-size: 18px;
    color: var(--gray-600, #858585);
    transition: transform 0.3s ease;
}
.custom-dropdown-container.open .dropdown-arrow i {
    transform: rotate(180deg);
}

.custom-dropdown-container[data-text-align="left"] .selected-value {
    text-align: left !important;
    padding-left: 0 !important;
    padding-right: 8px !important;
    margin-left: 0 !important;
    justify-self: flex-start;
}

.custom-dropdown-container[data-text-align="center"] .selected-value {
    text-align: center;
    /* padding-left: 24px; */
    padding-right: 24px;
}

.custom-dropdown-container[data-text-align="right"] .selected-value {
    text-align: right;
    padding-right: 12px;
}

.custom-dropdown-container[data-text-align="left"] .custom-dropdown-input {
    padding: 8px 32px 8px 12px !important;
    justify-content: flex-start !important;
    text-align: left !important;
}

.custom-dropdown-container[data-text-align="left"] .custom-dropdown-input .selected-value {
    padding-left: 0 !important;
    padding-right: 8px !important;
}

/* Unit alignment left - ชิดซ้าย */
.custom-dropdown-container[data-unit-align="left"] .dropdown-unit {
    order: 2;
    margin-left: 0 !important;
    margin-right: auto;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* เมื่อ textAlign และ unitAlign เป็น left ทั้งคู่ ให้ลด gap และทำให้ชิดซ้าย */
.custom-dropdown-container[data-text-align="left"][data-unit-align="left"] .custom-dropdown-input {
    gap: 4px !important;
}

/* เมื่อ unitAlign เป็น left ให้ selected-value และ unit ชิดซ้าย */
.custom-dropdown-container[data-unit-align="left"] .custom-dropdown-input .selected-value {
    flex: 0 0 auto !important;
    margin-right: 0 !important;
}

.custom-dropdown-container[data-unit-align="left"] .custom-dropdown-input .dropdown-unit {
    flex: 0 0 auto !important;
    margin-left: 0 !important;
}

.custom-dropdown-input .selected-value.custom-placeholder {
    color: var(--gray-400);
}

.custom-dropdown-input .dropdown-unit.dropdown-unit-hidden {
    visibility: hidden;
}

.custom-dropdown-container[data-text-align="center"] .custom-dropdown-input {
    justify-content: center;
}

.custom-dropdown-container[data-text-align="right"] .custom-dropdown-input {
    justify-content: flex-end;
    padding-right: 12px;
}

.custom-dropdown-list {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: #ffffff;
    border: 1px solid #c2c2c2;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: var(--z-dropdown);
    max-height: 300px;
    overflow: hidden;
    display: none;
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease;
    padding: 12px;
    gap: 11px;
}
.custom-dropdown-list.show {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.custom-dropdown-container.drop-up .custom-dropdown-list {
    top: auto;
    bottom: calc(100% + 6px);
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid #e4e7ec;
    background: #f9fafb;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: var(--gray-700);
}
.search-input:focus {
    outline: none;
    border: 1px solid #0072bc;
}
.custom-dropdown-search {
    margin-bottom: 12px;
    padding: 0;
}
.custom-dropdown-search .search-input {
    background: #f9fafb;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
}
.custom-dropdown-search .search-input::placeholder {
    color: var(--gray-400);
}

.custom-dropdown-options {
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    /* extra bottom padding so last item doesn't touch edge */
    padding: 8px 8px 16px;
    scrollbar-width: thin;
    scrollbar-color: #F0F0F0 transparent;
}
.custom-dropdown-options::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-dropdown-options::-webkit-scrollbar-track {
    border-radius: 10px;
}
.custom-dropdown-options::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background-color: #F0F0F0;
}
.custom-dropdown-options::-webkit-scrollbar-thumb:hover {
    background-color: #F0F0F0;
}

.dropdown-option {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--gray-700);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    margin: 0;
    margin-bottom: 11px;
    position: relative;
    display: flex !important;
    align-items: center;
    justify-content: flex-start; /* ให้จัดเริ่มจากซ้าย แล้วใช้ margin-left:auto ดัน icon ไปขวา */
    width: 100%; /* ให้ option กว้างเต็มแถว เพื่อให้ check icon ไปชิดขวาสุด */
}

/* ใช้สำหรับซ่อน option ตอนกรองด้วย search */
.dropdown-option.hidden {
    display: none !important;
}
.dropdown-option:last-child {
    margin-bottom: 0;
}
.dropdown-option:hover {
    border-radius: 8px;
    background-color: var(--gray-100, #FAFAFA);
    color: var(--blue-700, #0072bc);
}
.dropdown-option:active {
    border-radius: 8px;
    background-color: var(--gray-100, #FAFAFA);
    color: var(--blue-700, #0072bc);
}
.dropdown-option.selected {
    border-radius: 8px;
    background-color: var(--gray-100, #FAFAFA);
    color: var(--blue-700, #0072bc);
    font-weight: 600;
}
/* .dropdown-option.selected:hover {
    background-color: #e0e8ff;
} */
/* Icon check สำหรับ option ที่ถูกเลือก (ดันไปชิดขวาสุดในแถว) */
.dropdown-option .check-icon {
    display: none;
    margin-left: auto; /* ดันไปชิดขวาสุดของ flex row */
}
.dropdown-option.selected .check-icon {
    display: inline-block;
}

/* Text alignment for dropdown options */
.custom-dropdown-container[data-text-align="left"] .dropdown-option {
    justify-content: flex-start !important;
    text-align: left !important;
}
.custom-dropdown-container[data-text-align="left"] .dropdown-option .option-text {
    text-align: left !important;
    flex: 1;
}
.custom-dropdown-container[data-text-align="center"] .dropdown-option {
    justify-content: flex-start !important;
    text-align: center !important;
}
.custom-dropdown-container[data-text-align="center"] .dropdown-option .option-text {
    flex: 1;
    text-align: center;
}
.custom-dropdown-container[data-text-align="right"] .dropdown-option {
    justify-content: flex-start !important;
    text-align: right !important;
}
.custom-dropdown-container[data-text-align="right"] .dropdown-option .option-text {
    flex: 1;
    text-align: right;
}

/* Keyboard highlight */
._kbd {
    outline: 2px dashed #90caf9;
    outline-offset: 2px;
}

/* Scrollbars - Legacy styles (backup) */
.custom-dropdown-options::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-dropdown-options::-webkit-scrollbar-track {
    border-radius: 10px;
}
.custom-dropdown-options::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background-color: #F0F0F0;
}
.custom-dropdown-options::-webkit-scrollbar-thumb:hover {
    background-color: #F0F0F0;
}
.custom-dropdown-options {
    scrollbar-width: thin;
    scrollbar-color: #F0F0F0 transparent;
}

/* Empty state message - matches ced-empty styling */
.custom-dropdown-empty {
    text-align: center;
    padding: 20px 0;
    font-size: 13px;
    color: var(--gray-400);
}

/* Disabled */
.custom-dropdown-container.disabled .custom-dropdown-input {
    opacity: 0.7;
    pointer-events: none;
    background-color: #e9ecef !important;
    color: #6c757d;
    cursor: not-allowed;
    
}

/* Removed legacy .fitter-dropdown-* rules (not referenced by JS module) */

/* ========================================================================== */
/*                                RESPONSIVE                                  */
/* ========================================================================== */

@media (max-width: 768px) {
    .custom-dropdown-input {
        min-height: 44px;
        font-size: 16px;
    }
    .search-input {
        font-size: 16px;
    }
    .dropdown-option {
        padding: 10px 12px;
        font-size: 16px;
    }
}

@media (max-width: 576px) {
    .custom-dropdown-list {
        max-height: 260px;
    }
}

/* Removed legacy multi-summary UI for .fitter-dropdown-* (not used by JS) */

/* Removed legacy fitter-dropdown list/option tweaks and portal class */

/* Removed legacy single-tag-ui for fitter-dropdown */

/* ========= Base container ========= */
.ftr-ctn {
    position: relative;
    display: inline-block;
    width: 100%;
}
.ftr-ctn[style*="width"] {
    max-width: 100%;
}
/* autosize mode: let the content define width */
.ftr-ctn[data-auto-size="1"] {
    width: auto;
    min-width: 0;
}

/* ========= Head (idle pill) ========= */
.ftr-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 35px 10px 15px;
    /* min-height: 40px; */
    cursor: pointer;
    border: 1px solid var(--gray-300, #D6D6D6);
    border-radius: var(--radius);
    background: var(--clr-bg);
    color: var(--gray-600, #858585);
    -webkit-user-select: none;
    user-select: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    width: 100%;

}
/* autosize mode: head shrinks to content */
.ftr-ctn[data-auto-size="1"] .ftr-head {
    width: auto;
    min-width: 0;
}

.ftr-ctn.open .ftr-head {
    border-color: var(--clr-border-strong);
    /* box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.12); */
}
.ftr-placeholder {
    color: var(--gray-400);
    max-width: calc(100% - 28px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* autosize mode: placeholder shows full text */
.ftr-ctn[data-auto-size="1"] .ftr-placeholder {
    max-width: none;
    white-space: nowrap;
    overflow: visible;
    text-overflow: unset;
}

/* arrow */
.ftr-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
}
.ftr-arrow::after {
    content: "";
    display: inline-block;
    width: 24px;
    height: 24px;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cpath d='M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z'/%3E%3Cpath fill='%23858585' d='M12.707 15.707a1 1 0 0 1-1.414 0L5.636 10.05A1 1 0 1 1 7.05 8.636l4.95 4.95l4.95-4.95a1 1 0 0 1 1.414 1.414z'/%3E%3C/g%3E%3C/svg%3E");
    transition: transform 0.3s ease;
}

.ftr-ctn.open .ftr-arrow::after {
    transform: rotate(180deg);
}

/* ========= Selected Tag (single-mode) ========= */
.ftr-tag {
    display: none; /* ซ่อนจนกว่าจะมีค่า */
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    /* min-height: 40px; */
    border: 1px solid var(--clr-border-strong);
    background: #e8f3ff;
    color: #0f5fb8;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    width: auto; /* shrink to content */
    position: relative; /* ใช้เป็นจุดอ้างอิงสำหรับปุ่ม X */
    padding-right: 30px; /* เผื่อพื้นที่ให้ปุ่ม X */
}

.ftr-tag .ftr-tag-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    /* background: #1e88e5; */
    color: #fff;
    font-weight: 700;
}
.ftr-tag.empty {
    border: 1px solid var(--clr-border);
    background: #fff;
    color: var(--gray-400);
    font-weight: 500;
}

.ftr-tag-clear {
    position: absolute;
    top: 50%;
    right: 6px; /* ระยะห่างจากขอบขวา */
    transform: translateY(-50%);
    margin-left: 0 !important; /* กัน spacing เดิม */
}

/* ========= List (portal to body) ========= */
.ftr-list {
    position: fixed; /* พอร์ตขึ้น body */
    min-width: 240px;
    max-height: 300px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--clr-border);
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.ftr-list.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* search */
.ftr-search {
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f6;
}
.ftr-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d5dde6;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
}
.ftr-search input:focus {
    border-color: #1e88e5;
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.12);
}

.ftr-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.ftr-opt.selected {
    background: #fafafa;
    color: #0072bc;
}

.ftr-opt.selected span {
    font-weight: 500;
}

.ftr-opt .opt-main {
    flex: 1;
    min-width: 0;
}
.ftr-opt .opt-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}
.ftr-opt .opt-desc {
    display: block;
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}
.ftr-opt .opt-check {
    margin-left: 12px;
    width: 18px;
    height: 18px;
    accent-color: #1e88e5;
}

/* keyboard */
.ftr-opt._kbd {
    outline: 2px solid #1e88e5;
    outline-offset: -2px;
}

/* mobile tweaks */
@media (max-width: 768px) {
    .ftr-head,
    .ftr-tag {
        min-height: 44px;
    }
    .ftr-opt {
        padding: 14px;
    }
}

/* === Custom list when portaled to <body> === */
.custom-list-portal {
    position: fixed;
    /* Above hrsolution_layout dynamic modal z-index (1050 + n*20) and backdrop */
    z-index: 10000;
    /* ค่าเริ่มต้น เดี๋ยว JS จะคำนวณ left/top ให้ */
    left: 0;
    top: 0;

    /* ยกเลิก right:0 ที่มากับ .custom-dropdown-list */
    right: auto !important;

    /* คุมความกว้างด้วยตัวเอง ไม่ยืดเต็มจอ */
    width: auto;
    min-width: 200px; /* ขั้นต่ำ */
    max-width: min(480px, 100vw - 24px);
    box-sizing: border-box;

    /* ไม่ใช้ transform เดิมของคลาสหลัก เพื่อกันการทับซ้อน */
    transform: none !important;
    opacity: 1; /* โชว์-ซ่อนใช้ class .show อยู่แล้ว */
    visibility: visible;
}

/* ให้เงา/ขอบเหมือนตัวหลัก */
.custom-list-portal {
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* เมื่อโชว์ */
.custom-list-portal.show {
    display: block !important;
}

/* ป้องกันสไตล์จาก .custom-dropdown-list หลักมาทับ */
.custom-list-portal .custom-dropdown-options {
    max-height: 240px;
    overflow-y: auto;
    /* keep same bottom breathing room when in portal */
    padding-bottom: 16px;
}

/* ตัวอย่าง: เฉพาะหน้า X ให้ dropdown แคบลง */
.page-x .ftr-ctn {
    width: auto;
    max-width: 260px;
}
.page-x .ftr-tag,
.page-x .ftr-head {
    width: 100%;
}

/* สี placeholder เมื่อยังไม่เลือก */
.custom-dropdown-container .selected-placeholder {
    color: var(--gray-400);
}

/* ใส่ในไฟล์ CSS ของหน้า */
#ctforms_id_custom_list .dropdown-option[data-value=""] {
    display: none !important;
}

.custom-dropdown-container.error .custom-dropdown-input {
    border: 1px solid #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.08);
}
.ftr-ctn.error .ftr-head,
.ftr-ctn.error .ftr-tag {
    border: 1px solid #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.08);
}
.select2 .select2-selection.border-red {
    border: 1px solid #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.08);
}

.custom-dropdown-options .dropdown-option[data-value=""]{ display:none; }

