/*
 * Module 6.6 — Mobile VRM enquiry popup refinement
 * Loaded after the global and website-specific styles so these rules remain isolated.
 */

/* Better use of available desktop height without changing the existing design language. */
.vrm-modal-dialog {
    width: min(920px, calc(100% - 32px));
    max-height: min(760px, calc(100dvh - 32px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.vrm-popup-form {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
}

.vrm-popup-step.is-active {
    min-height: 0;
    flex: 1 1 auto;
}

.vrm-problem-field textarea {
    width: 100%;
    resize: vertical;
    min-height: 132px;
    max-height: 190px;
}

/* Phone and small-tablet layout. */
@media (max-width: 790px) {
    body.vrm-modal-open {
        overflow: hidden;
    }

    .vrm-modal {
        align-items: center;
        padding: 8px;
    }

    .vrm-modal-dialog {
        width: 100%;
        max-height: calc(100dvh - 16px);
        border-radius: 17px;
    }

    .vrm-modal-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 1.55rem;
    }

    .vrm-modal-header {
        flex: 0 0 auto;
        gap: 10px;
        padding: 12px 52px 11px 14px;
    }

    .vehicle-found-badge {
        flex: 0 0 auto;
        padding: 5px 8px;
        font-size: .66rem;
        white-space: nowrap;
    }

    .vrm-modal-header > div {
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 9px;
        flex-wrap: wrap;
    }

    .vrm-modal-vrm {
        flex: 0 0 auto;
        padding: 4px 9px;
        font-size: .86rem;
        line-height: 1.25;
    }

    .vrm-modal-header h2 {
        flex: 1 1 180px;
        min-width: 0;
        margin: 0;
        font-size: .88rem;
        line-height: 1.2;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .vrm-popup-form {
        padding: 0 14px 13px;
    }

    .vrm-popup-step.is-active {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .vrm-step-heading {
        max-width: 100%;
        margin: 10px auto 9px;
    }

    .vrm-step-heading h3,
    .vrm-step-heading h3:first-child {
        margin-bottom: 4px;
        font-size: clamp(1.22rem, 6vw, 1.55rem);
        line-height: 1.12;
    }

    .vrm-step-heading > p:not(.eyebrow) {
        font-size: .78rem;
        line-height: 1.35;
    }

    .vrm-problem-field label > span,
    .vrm-contact-grid label {
        font-size: .74rem;
    }

    .vrm-problem-field textarea {
        min-height: 104px;
        max-height: 118px;
        padding: 10px 11px;
        border-radius: 11px;
        font-size: .82rem;
        line-height: 1.4;
        resize: none;
    }

    .vrm-problem-field small,
    .vrm-contact-grid label small {
        min-height: 13px;
        margin-top: 2px;
        font-size: .68rem;
    }

    .vrm-choice-grid {
        gap: 8px;
        margin: 9px 0 5px;
    }

    .condition-grid,
    .service-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .vrm-choice-card {
        min-height: 89px;
        padding: 9px 6px;
        border-radius: 11px;
    }

    .choice-check {
        top: 6px;
        right: 6px;
        width: 19px;
        height: 19px;
        font-size: .64rem;
    }

    .choice-icon {
        width: 34px;
        height: 34px;
        margin-bottom: 4px;
        border-radius: 9px;
        font-size: 1.05rem;
    }

    .vrm-choice-card strong {
        font-size: .78rem;
        line-height: 1.15;
    }

    .vrm-choice-card small {
        margin-top: 2px;
        font-size: .65rem;
        line-height: 1.18;
    }

    .vrm-step-error {
        min-height: 14px;
        margin: 0 0 2px;
        font-size: .7rem;
    }

    .vrm-contact-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
        margin: 9px auto 4px;
    }

    .vrm-contact-grid input {
        min-height: 39px;
        margin-top: 3px;
        padding: 7px 9px;
        border-radius: 7px;
        font-size: .8rem;
    }

    .vrm-step-actions {
        flex: 0 0 auto;
        margin-top: 8px;
    }

    .vrm-step-actions-end .btn,
    .vrm-step-actions .btn {
        width: 100%;
        min-width: 0;
        min-height: 43px;
        padding: 9px 14px;
        font-size: .82rem;
    }

    .vrm-privacy-note {
        margin-top: 6px;
        font-size: .65rem;
    }

    .vrm-popup-success {
        padding: 35px 18px 30px;
    }
}

/* Narrow phones: retain two-column choices but simplify card detail. */
@media (max-width: 420px) {
    .vrm-modal {
        padding: 5px;
    }

    .vrm-modal-dialog {
        max-height: calc(100dvh - 10px);
        border-radius: 14px;
    }

    .vrm-modal-header {
        padding-left: 10px;
        padding-right: 48px;
    }

    .vehicle-found-badge {
        font-size: .61rem;
    }

    .vrm-modal-header h2 {
        font-size: .79rem;
    }

    .vrm-popup-form {
        padding-left: 10px;
        padding-right: 10px;
        padding-bottom: 10px;
    }

    .vrm-choice-card small {
        display: none;
    }

    .vrm-choice-card {
        min-height: 72px;
    }

    .vrm-contact-grid {
        gap: 5px;
    }
}

/* Very short screens: prioritize all controls staying above the fold. */
@media (max-width: 790px) and (max-height: 680px) {
    .vrm-modal-header {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .vrm-step-heading {
        margin-top: 6px;
        margin-bottom: 6px;
    }

    .vrm-step-heading h3,
    .vrm-step-heading h3:first-child {
        font-size: 1.15rem;
    }

    .vrm-step-heading > p:not(.eyebrow) {
        font-size: .72rem;
    }

    .vrm-problem-field textarea {
        min-height: 82px;
        max-height: 82px;
    }

    .vrm-choice-card {
        min-height: 67px;
        padding: 6px 4px;
    }

    .choice-icon {
        width: 28px;
        height: 28px;
        margin-bottom: 2px;
        font-size: .9rem;
    }

    .vrm-contact-grid input {
        min-height: 34px;
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .vrm-step-actions .btn {
        min-height: 38px;
        padding-top: 7px;
        padding-bottom: 7px;
    }
}

/* Landscape phones: use the width and keep the active step fully visible. */
@media (max-width: 920px) and (orientation: landscape) and (max-height: 520px) {
    .vrm-modal {
        padding: 5px;
    }

    .vrm-modal-dialog {
        max-height: calc(100dvh - 10px);
    }

    .vrm-modal-header {
        padding: 6px 48px 6px 10px;
    }

    .vrm-popup-form {
        padding: 0 10px 7px;
    }

    .vrm-step-heading {
        margin: 4px auto;
    }

    .vrm-step-heading h3,
    .vrm-step-heading h3:first-child {
        font-size: 1.05rem;
    }

    .vrm-step-heading > p:not(.eyebrow) {
        display: none;
    }

    .vrm-problem-field textarea {
        min-height: 65px;
        max-height: 65px;
    }

    .vrm-choice-grid {
        margin: 4px 0;
    }

    .vrm-choice-card {
        min-height: 60px;
        flex-direction: row;
        gap: 5px;
    }

    .choice-icon {
        width: 27px;
        height: 27px;
        margin: 0;
    }

    .vrm-choice-card small {
        display: none;
    }

    .vrm-contact-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        margin: 4px 0;
    }

    .vrm-step-actions {
        margin-top: 4px;
    }
}

/* Accessibility: allow page zoom without clipping on exceptionally tiny viewports. */
@media (max-width: 330px), (max-height: 500px) and (orientation: portrait) {
    .vrm-modal-dialog {
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}
