.custom-dropdown {
    position: relative;
    min-height: 50px;
}

    .custom-dropdown > div[value] {
        display: none;
    }

.custom-dropdown-input,
.custom-dropdown-tags,
.custom-dropdown-textarea {
    width: 100%;
    padding-right: 32px !important;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    resize: none;
    box-sizing: border-box;
}

[dir="rtl"] .custom-dropdown-input,
.custom-dropdown-tags,
.custom-dropdown-textarea {
    padding-left: 32px !important;
}

.custom-dropdown-right input, .custom-dropdown-right .custom-dropdown-item {
    text-align: right;
}

.custom-dropdown-center input, .custom-dropdown-center .custom-dropdown-item {
    text-align: center;
}

.custom-dropdown-left input, .custom-dropdown-left .custom-dropdown-item {
    text-align: left;
}

.custom-dropdown-justify input, .custom-dropdown-justify .custom-dropdown-item {
    text-align: justify;
}

.custom-dropdown-right .custom-dropdown-tags {
    display: flex;
    justify-content: right;
}

.custom-dropdown-center .custom-dropdown-tags {
    display: flex;
    justify-content: center;
}

.custom-dropdown-left .custom-dropdown-tags {
    display: flex;
    justify-content: left;
}

.custom-dropdown-popup {
    position: absolute;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    margin-top: 4px;
    display: none;
    z-index: 99999;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
}


.custom-dropdown.open .custom-dropdown-popup {
    display: block;
}

.custom-dropdown-item {
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.2s;
}

    .custom-dropdown-item:hover {
        background: #f0f0f0;
    }

    .custom-dropdown-item.custom-dropdown-selected {
        background: #007bff !important;
        color: white;
    }

    .custom-dropdown-item.custom-dropdown-hover {
        background-color: #ccc;
        color: #333;
    }

    .custom-dropdown-item.custom-dropdown-selected.custom-dropdown-hover {
        background: #007bff;
        color: white;
    }

.custom-dropdown-search {
    padding: 5px;
    border-bottom: 1px solid #ddd;
}

    .custom-dropdown-search input {
        width: 100%;
        padding: 6px 8px;
        border: 1px solid #ccc;
        border-radius: 4px;
        box-sizing: border-box;
    }

.custom-dropdown-remove-btn {
    position: absolute;
    gap: 4px;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    color: #888;
    display: none;
    padding: 5px;
}

    .custom-dropdown-remove-btn:hover {
        color: red;
    }

[dir="rtl"] .custom-dropdown-remove-btn {
    right: unset;
    left: 0;
}

.custom-dropdown-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 30px 5px 4px;
    border: 2px solid #afbdcf;
    border-radius: 10px;
    background: transparent;
    min-height: 50px;
    cursor: pointer;
    align-items: center;
}

[dir="rtl"] .custom-dropdown-tags {
    padding: 8px 4px 5px 30px
}

.custom-dropdown-tag {
    display: inline-flex;
    align-items: center;
    background: #007bff;
    color: white;
    border-radius: 12px;
    margin: 4px 0px;
    padding: 3px 10px;
    font-size: 13px;
    z-index: 9999;
}

    .custom-dropdown-tag button {
        border: none;
        background: none;
        color: white;
        margin-left: 4px;
        cursor: pointer;
        font-weight: bold;
        line-height: 1;
        padding: 0;
        width: 16px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

[dir="rtl"] .custom-dropdown-tag button {
    margin-left: unset;
    margin-right: 4px;
}
/* ================= DARK MODE ================= */

[data-theme="dark"] .custom-dropdown-input,
[data-theme="dark"] .custom-dropdown-tags,
[data-theme="dark"] .custom-dropdown-textarea {
    border: 1px solid #444;
    color: #eee;
}

[data-theme="dark"] .custom-dropdown-popup {
    background: #1e1e1e;
    border: 1px solid #444;
}

[data-theme="dark"] .custom-dropdown-item {
    color: #ddd;
}

    [data-theme="dark"] .custom-dropdown-item:hover {
        background: #2c2c2c;
    }

    [data-theme="dark"] .custom-dropdown-item.custom-dropdown-hover {
        background-color: #3a3a3a;
        color: #fff;
    }

[data-theme="dark"] .custom-dropdown-search {
    border-bottom: 1px solid #444;
}

    [data-theme="dark"] .custom-dropdown-search input {
        background: #2a2a2a;
        border: 1px solid #444;
        color: #eee;
    }

[data-theme="dark"] .custom-dropdown-remove-btn {
    color: #aaa;
}

    [data-theme="dark"] .custom-dropdown-remove-btn:hover {
        color: #ff6b6b;
    }

[data-theme="dark"] .custom-dropdown-tags {
    border: 2px solid #afbdcf;
}
/* ================= DISABLED & READONLY STATES ================= */
.custom-dropdown.disabled {
    opacity: 0.6;
    pointer-events: none;
}

    .custom-dropdown.disabled .custom-dropdown-input,
    .custom-dropdown.disabled .custom-dropdown-tags {
        background-color: #f5f5f5;
        cursor: not-allowed;
    }

.custom-dropdown.readonly {
    opacity: 1;
}

    .custom-dropdown.readonly .custom-dropdown-input,
    .custom-dropdown.readonly .custom-dropdown-tags {
        background-color: #f9f9f9;
        cursor: default;
    }

    .custom-dropdown.readonly .custom-dropdown-remove-btn,
    .custom-dropdown.readonly .custom-dropdown-tag button {
        pointer-events: none;
        opacity: 0.5;
    }

    .custom-dropdown.readonly .custom-dropdown-popup {
        display: none !important;
    }

[data-theme="dark"] .custom-dropdown.disabled .custom-dropdown-input,
[data-theme="dark"] .custom-dropdown.disabled .custom-dropdown-tags {
    background-color: #2a2a2a;
}

[data-theme="dark"] .custom-dropdown.readonly .custom-dropdown-input,
[data-theme="dark"] .custom-dropdown.readonly .custom-dropdown-tags {
    background-color: #252525;
}

.custom-dropdown-input.custom-dropdown-selected-value {
    background-color: #d7dfef !important;
    border-color: #007bff;
    color: #0056b3;
    font-weight: 500;
    cursor: default;
    padding-left: 30px;
}

[data-theme="dark"] .custom-dropdown-input.custom-dropdown-selected-value {
    background-color: #1e3a5f !important;
    border-color: #4a9eff;
    color: #bbd9ff;
}
