/**
 * Shared styles for bd-action-modal popups (assign captain/partner, booking actions).
 * Choice rows use CSS grid so meta/phone and title/id do not overlap on narrow widths.
 */

.bd-action-modal .modal-dialog {
    max-width: 460px;
    width: calc(100% - 2rem);
    margin: 1rem auto;
}

#assignCaptainModal.bd-action-modal .modal-dialog {
    max-width: min(560px, calc(100% - 2rem));
}

#assignCaptainModal .assign-captain-search-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
}

#assignCaptainModal .assign-captain-search-label {
    display: block;
    flex-shrink: 0;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-2, #4b5563);
}

#assignCaptainModal .assign-captain-suggestions {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

#assignCaptainModal .assign-captain-suggestions .bd-choice-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(50vh, 280px);
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid var(--hairline, #e5e7eb);
    border-radius: 8px;
    background: var(--surface-1, #fff);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    padding: 0.35rem;
}

/* Avoid container-query stacking inside the assign-captain modal; use viewport breakpoints instead. */
#assignCaptainModal .bd-choice-copy {
    container-type: normal;
    container-name: unset;
}

.bd-action-modal.modal.show {
    padding: 0.5rem;
}

.bd-action-modal .modal-content {
    overflow: hidden;
}

.bd-action-modal .bd-modal-header > div:first-child {
    min-width: 0;
    flex: 1;
}

.bd-action-modal .bd-modal-hint {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.bd-action-modal .bd-modal-body {
    min-width: 0;
    overflow-x: hidden;
}

.bd-action-modal .bd-search-wrap {
    position: relative;
    width: 100%;
    min-width: 0;
    flex-shrink: 0;
}

.bd-action-modal .bd-search-wrap .material-icons {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--ink-muted, #9ca3af);
    pointer-events: none;
    z-index: 0;
}

.bd-action-modal .bd-search-input {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-width: 0;
    position: relative;
    z-index: 1;
    border: 1px solid var(--hairline, #e5e7eb);
    border-radius: 10px;
    background: var(--surface-1, #fff);
    padding: 0.55rem 0.75rem 0.55rem 2.35rem;
    font-size: 0.85rem;
    line-height: 1.35;
    color: var(--ink, #1f2937);
    -webkit-text-fill-color: var(--ink, #1f2937);
    outline: none;
}

.bd-action-modal .bd-search-input::placeholder {
    color: var(--ink-muted, #9ca3af);
    opacity: 1;
}

html[dir="rtl"] .bd-action-modal .bd-search-wrap .material-icons {
    left: auto;
    right: 12px;
}

html[dir="rtl"] .bd-action-modal .bd-search-input {
    padding: 0.55rem 2.35rem 0.55rem 0.75rem;
}

.bd-action-modal .bd-choice-scroll {
    min-width: 0;
    overflow-x: hidden;
}

.bd-action-modal .bd-choice-list {
    min-width: 0;
}

.bd-action-modal .bd-choice-card {
    align-items: flex-start;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: visible;
}

.bd-action-modal .bd-choice-copy {
    flex: 1 1 auto;
    min-width: 0;
    container-type: inline-size;
    container-name: bd-choice-copy;
}

.bd-action-modal .bd-choice-check {
    flex-shrink: 0;
}

.bd-action-modal .bd-choice-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    column-gap: 0.5rem;
    row-gap: 0.12rem;
    align-items: baseline;
    width: 100%;
}

.bd-action-modal .bd-choice-title {
    grid-column: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink, #1f2937);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bd-action-modal .bd-choice-meta {
    grid-column: 1;
    font-size: 0.75rem;
    color: var(--ink-muted, #9ca3af);
    margin-top: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bd-action-modal .bd-choice-id,
.bd-action-modal .bd-choice-phone {
    grid-column: 2;
    justify-self: end;
    font-size: 0.75rem;
    color: var(--ink-muted, #9ca3af);
    max-width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stack secondary fields when the card content area is narrow (modal on mobile, tight layouts). */
@container bd-choice-copy (max-width: 360px) {
    .bd-action-modal .bd-choice-row {
        grid-template-columns: 1fr;
    }

    .bd-action-modal .bd-choice-title,
    .bd-action-modal .bd-choice-meta,
    .bd-action-modal .bd-choice-id,
    .bd-action-modal .bd-choice-phone {
        grid-column: 1;
        grid-row: auto;
        justify-self: start;
        max-width: 100%;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        word-break: break-word;
    }
}

@media (max-width: 575.98px) {
    .bd-action-modal .bd-modal-header,
    .bd-action-modal .bd-modal-body,
    .bd-action-modal .bd-modal-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .bd-action-modal .bd-search-input {
        font-size: 16px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .bd-action-modal .bd-choice-card {
        padding: 0.65rem 0.75rem;
        gap: 0.6rem;
    }

    .bd-action-modal .bd-choice-row,
    #assignCaptainModal .bd-choice-row {
        grid-template-columns: 1fr;
    }

    .bd-action-modal .bd-choice-title,
    .bd-action-modal .bd-choice-meta,
    .bd-action-modal .bd-choice-id,
    .bd-action-modal .bd-choice-phone,
    #assignCaptainModal .bd-choice-title,
    #assignCaptainModal .bd-choice-meta,
    #assignCaptainModal .bd-choice-id,
    #assignCaptainModal .bd-choice-phone {
        grid-column: 1;
        grid-row: auto;
        justify-self: start;
        max-width: 100%;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        word-break: break-word;
    }

    .bd-action-modal .bd-modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .bd-action-modal .bd-modal-btn {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .bd-action-modal .modal-dialog {
        width: calc(100% - 1rem);
        margin: 0.5rem auto;
    }

    .bd-action-modal .bd-choice-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.65rem;
    }

    .bd-action-modal .bd-choice-check {
        width: 20px;
        height: 20px;
    }
}
