/**
 * Custom Multi-Select Dropdown
 *
 * CSS custom properties for configurable colors:
 * --pc-ms-icon-color: Icon color (default #d24dc6)
 * --pc-ms-check-color: Check icon color (default #3498db)
 * --pc-ms-text-color: Option text color (default #000)
 * --pc-ms-option-bg: Dropdown/option background (default #fff)
 * --pc-ms-hover-bg: Hover background (default rgba(0,0,0,0.04))
 * --pc-ms-selected-bg: Selected option background (default rgba(0,0,0,0.06))
 */

.custom-select-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 10px;
    user-select: none;
    z-index: 100;
}

/* Hidden checkbox toggle */
.custom-select-toggle {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100%;
    height: 38px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 3;
    pointer-events: auto;
}

/* Select button — matches form input style */
.custom-select-btn {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: none;
    border-radius: 0px;
    font-size: 16px;
    color: #5e5e5e;
    background: #ffffff;
    font-family: "Open Sans", Helvetica, Arial, sans-serif;
    cursor: pointer;
    transition: box-shadow 0.2s ease;
}

.custom-select-btn:hover {
    box-shadow: 0 0 5px rgb(98 139 189 / 50%);
}

.custom-select-btn .selected-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
    line-height: 1.5;
}

.custom-select-btn.has-selection {
    background-color: #E8F0FE;
}

.custom-select-btn .selected-text.has-selection {
    color: #000000;
}

.custom-select-btn .chevrons {
    display: flex;
    flex-direction: column;
    font-size: 10px;
    line-height: 1;
    color: #d1dede;
    gap: 2px;
}

.custom-select-toggle:checked + .custom-select-btn .chevrons {
    color: #333333;
}

/* Dropdown options — opens upward */
.custom-select-options {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    background-color: var(--pc-ms-option-bg, #ffffff);
    border-radius: 0px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    z-index: 10000;
    box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
}

.custom-select-toggle:checked ~ .custom-select-options {
    max-height: 300px;
    opacity: 1;
}

/* Single option row */
.custom-option {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    overflow: hidden;
}

/* Hidden native checkbox */
.custom-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Option label — full row clickable */
.custom-option label {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 0 10px 14px;
    cursor: pointer;
    font-family: "Open Sans", Helvetica, Arial, sans-serif;
    font-size: 12px;
    color: var(--pc-ms-text-color, #000000);
    line-height: 1;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.custom-option label i {
    width: 20px;
    margin-right: 10px;
    font-size: 16px;
    text-align: center;
    transition: transform 0.3s ease, color 0.2s ease;
}

/* Icon color via CSS custom property */
.custom-option label i:first-child {
    color: var(--pc-ms-icon-color, #d24dc6);
}

/* Checkmark indicator */
.custom-option label .check-icon {
    margin-left: auto;
    font-size: 13px;
    color: transparent;
    transition: color 0.2s ease;
}

.custom-option input[type="checkbox"]:checked + label .check-icon {
    color: var(--pc-ms-check-color, #3498db);
}

/* Hover background */
.custom-option-bg {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 100%;
    background-color: var(--pc-ms-hover-bg, rgba(0, 0, 0, 0.04));
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1;
    border-radius: 0;
}

.custom-option:hover .custom-option-bg {
    opacity: 1;
}

/* Checked state — bold text, background */
.custom-option input[type="checkbox"]:checked + label span {
    font-weight: 600;
}

.custom-option input[type="checkbox"]:checked ~ .custom-option-bg {
    opacity: 1;
    background-color: var(--pc-ms-selected-bg, rgba(0, 0, 0, 0.06));
}

/* Icon hover animation */
.custom-option:hover label i:first-child {
    animation: iconBounceDown 0.3s ease forwards;
}

.custom-option:nth-child(even):hover label i:first-child {
    animation: iconBounceUp 0.3s ease forwards;
}

@keyframes iconBounceDown {
    0% { transform: translateY(-8px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes iconBounceUp {
    0% { transform: translateY(8px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Border radius for first/last options */
.custom-option:first-child {
    border-radius: 4px 4px 0 0;
}

.custom-option:last-child {
    border-radius: 0 0 4px 4px;
}
