/**
 * Mobile bottom sheet — generic portal + TomSelect sheet overrides
 */

:root {
    --z-aside-sheet: 1040;
    --z-select-sheet-backdrop: 1050;
    --z-select-sheet-panel: 1060;
    --z-datepicker-modal: 9999;
    --apd-bottom-sheet-vv-offset: 0px;
}

.apd-bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: var(--z-select-sheet-backdrop);
    pointer-events: none;
    visibility: hidden;
}

.apd-bottom-sheet.is-expanded {
    visibility: visible;
    pointer-events: auto;
}

.apd-bottom-sheet__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.62s cubic-bezier(0.33, 1, 0.68, 1),
        visibility 0.62s cubic-bezier(0.33, 1, 0.68, 1);
}

.apd-bottom-sheet.is-expanded .apd-bottom-sheet__backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.apd-bottom-sheet__panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--apd-bottom-sheet-vv-offset, 0px);
    z-index: var(--z-select-sheet-panel);
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - var(--apd-bottom-sheet-vv-offset, 0px));
    background: #fff;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    transform: translate3d(0, 106%, 0);
    transition: transform 0.62s cubic-bezier(0.33, 1, 0.68, 1);
    backface-visibility: hidden;
    pointer-events: none;
}

.apd-bottom-sheet.is-expanded .apd-bottom-sheet__panel {
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
}

.apd-bottom-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex: 0 0 auto;
    padding: calc(env(safe-area-inset-top, 0px) + 0.75rem) calc(1rem + env(safe-area-inset-right, 0px)) 0.75rem calc(1rem + env(safe-area-inset-left, 0px));
    border-bottom: 1px solid var(--apd-gray-mid, #e8edf2);
    background: #fff;
}

.apd-bottom-sheet__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--apd-text, #1e293b);
}

.apd-bottom-sheet__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.06);
    color: var(--apd-text, #1e293b);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.apd-bottom-sheet__close:focus-visible {
    outline: 2px solid var(--bs-primary, #0d47a1);
    outline-offset: 2px;
}

.apd-bottom-sheet__content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
}

@media (prefers-reduced-motion: reduce) {
    .apd-bottom-sheet__backdrop,
    .apd-bottom-sheet__panel {
        transition-duration: 0.01ms !important;
        transition-timing-function: linear !important;
    }
}

@media (max-width: 768px) {
    .ts-wrapper .ts-control .seguros-mobile-control-input {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        opacity: 0 !important;
        pointer-events: none !important;
        clip: rect(0, 0, 0, 0) !important;
        overflow: hidden !important;
        border: 0 !important;
        padding: 0 !important;
    }

    .apd-bottom-sheet__content .seguros-mobile-sheet,
    .apd-bottom-sheet__content > .seguros-mobile-sheet {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        transform: none !important;
        display: flex !important;
        flex-direction: column;
        flex: 1 1 auto;
        max-height: none;
        min-height: 0;
        overflow: hidden;
    }

    .apd-bottom-sheet__content .seguros-mobile-sheet .ts-dropdown-content,
    .apd-bottom-sheet__content .seguros-mobile-sheet > [role="listbox"] {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .apd-bottom-sheet__content .seguros-mobile-sheet .option,
    .apd-bottom-sheet__content .seguros-mobile-sheet .optgroup-header {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
    }

    .apd-bottom-sheet__content .seguros-mobile-sheet .dropdown-input-wrap,
    .apd-bottom-sheet__content .seguros-mobile-sheet .ts-dropdown-header {
        flex: 0 0 auto;
        position: sticky;
        top: 0;
        z-index: 3;
        background: #fff;
        border-bottom: 1px solid var(--apd-gray-mid, #e8edf2);
        padding: 0.5rem 1rem;
    }

    .apd-bottom-sheet__content .seguros-mobile-sheet .option[data-value=""],
    .apd-bottom-sheet__content .seguros-mobile-sheet .option.seguros-sheet-empty-option,
    .apd-bottom-sheet__content .seguros-mobile-sheet .option .seguros-ts-empty-option {
        display: none !important;
    }

    .ts-dropdown .option[data-value=""],
    .ts-dropdown .option .seguros-ts-empty-option {
        display: none !important;
    }

    .apd-bottom-sheet__content .seguros-mobile-sheet .dropdown-input {
        width: 100%;
        min-height: 44px;
        padding: 0.625rem 0.875rem;
        font-size: 16px;
        border: 1px solid var(--apd-gray-mid, #e8edf2);
        border-radius: 10px;
        box-sizing: border-box;
    }

    .apd-bottom-sheet__content .seguros-mobile-sheet .dropdown-input:focus {
        outline: 2px solid var(--bs-primary, #0d47a1);
        outline-offset: 0;
        border-color: var(--bs-primary, #0d47a1);
    }

    .apd-bottom-sheet__content .seguros-mobile-sheet .no-results {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        color: var(--apd-text-claro, #64748b);
    }
}
