/* ============================================
   CUSTOM DROPDOWN COMPONENT
   Reusable responsive dropdown with drawer on mobile

   The dropdown menu/overlay styling is consistent.
   Trigger button styling can be customized per page.
   ============================================ */

.custom-dropdown {
    position: relative;
}

.custom-dropdown-overlay {
    display: none;
}

/* Trigger Button - Base Structure Only */
.custom-dropdown-trigger {
    align-items: center;
    display: flex;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.custom-dropdown-trigger-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-dropdown-trigger-chevron {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    background-repeat: no-repeat;
    background-size: 14px 8px;
    background-position: center;
    transition: transform 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8' fill='none'%3E%3Cpath d='M1 1L7 7L13 1' stroke='%23788396' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.custom-dropdown.open .custom-dropdown-trigger-chevron {
    transform: rotate(180deg);
}

/* Default Trigger Styling (Optional - can be overridden per page) */
.custom-dropdown-trigger-default {
    background-color: #fff;
    border: 1px solid #c3c6d6;
    border-radius: 8px;
    color: #1a1c1e;
    font-size: 14px;
    line-height: 20px;
    min-height: 44px;
    padding: 10px 14px;
    gap: 12px;
}

    .custom-dropdown-trigger-default:hover {
        color: #1A1C1E;
    }

    .custom-dropdown-trigger-default:focus {
        border-color: #c5ccda;
        outline: none;
    }

/* Dropdown Menu - Desktop */
.custom-dropdown-menu {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 10px);
    z-index: 20;
    background: #fff;
    border: 1px solid #E5E5E5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 0;
    overflow: hidden;
}

.custom-dropdown.open .custom-dropdown-menu {
    display: flex;
    flex-direction: column;
}

.custom-dropdown-drawer-head {
    display: none;
}

.custom-dropdown-drawer-handle {
    display: none;
}

/* Search Functionality */
.custom-dropdown-search-wrap {
    position: relative;
    padding: 16px;
}

.custom-dropdown-search-icon {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Ccircle cx='6.2' cy='6.2' r='4.7' stroke='%23788396' stroke-width='1.2'/%3E%3Cpath d='M9.6 9.6L12.2 12.2' stroke='%23788396' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
}

.custom-dropdown-search-input {
    width: 100%;
    border: 1px solid #D4DAE6;
    min-height: 44px;
    padding: 8px 16px 8px 34px;
    color: #000;
}

    .custom-dropdown-search-input:focus {
        outline: none;
        border-color: #c5ccda;
    }

.custom-dropdown-search-clear-btn {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 0;
    padding: 0;
    background: transparent;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: #788396;
}

    .custom-dropdown-search-clear-btn.is-visible {
        display: inline-flex;
    }

/* Options List */
.custom-dropdown-options {
    max-height: 160px;
    overflow-y: auto;
    padding: 0 8px;
    min-width: 80px;
}

.custom-dropdown-option {
    width: 100%;
    border: 0;
    background: transparent;
    color: #788396;
    display: flex;
    align-items: center;
    padding: 10px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
}

    .custom-dropdown-option:hover,
    .custom-dropdown-option:focus-visible {
        background: #F5F5F5;
        outline: none;
    }

    .custom-dropdown-option.is-selected {
        color: #000;
    }

.custom-dropdown-option-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-dropdown-option.is-hidden {
    display: none;
}

/* ============================================
   MOBILE RESPONSIVE (DRAWER MODE)
   ============================================ */

@media (max-width: 768px) {
    .custom-dropdown-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 98;
    }

    .custom-dropdown.open .custom-dropdown-overlay {
        display: block;
    }

    .custom-dropdown-menu {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 99;
        max-height: 50vh;
        height: 50vh;
        padding: 0;
        transform: translateY(100%);
        transition: transform 0.22s ease;
        pointer-events: none;
        overflow: hidden;
        border-radius: 16px 16px 0 0;
    }

    .custom-dropdown.open .custom-dropdown-menu {
        transform: translateY(0);
        pointer-events: auto;
    }

    .custom-dropdown-drawer-handle {
        display: block;
        width: 44px;
        height: 4px;
        border-radius: 4px;
        background: #1A1C1E;
        margin: 8px auto;
    }

    .custom-dropdown-drawer-head {
        display: block;
        position: sticky;
        top: 0;
        background: #fff;
        padding: 19px 16px 3px;
        z-index: 1;
    }

    .custom-dropdown-drawer-title {
        margin: 0;
        color: #000;
        font-size: 22px;
        line-height: 23px;
    }

    .custom-dropdown-option {
        border-radius: 0;
        padding: 12px 16px;
    }

    .custom-dropdown-options {
        max-height: none;
        flex: 1 1 auto;
        padding: 0;
        overflow-y: auto;
    }
}
