/* Royal Travel mobile-first layout corrections.
   Loaded after page styles so phone rules win over legacy desktop widths. */
*, *::before, *::after { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
img, svg, video, iframe { max-width: 100%; }
button, input, select, textarea { max-width: 100%; }

@media (max-width: 767.98px) {
    .container { width: 100%; max-width: 100%; padding-left: 16px; padding-right: 16px; }
    .row { width: 100%; max-width: 100%; margin-left: 0; margin-right: 0; }
    [class*="col-"] { min-width: 0; }

    /* Header */
    .navbar { padding: 8px 0; }
    .navbar > .container { padding-left: 12px; padding-right: 12px; }
    .navbar-brand { display: inline-flex; align-items: center; min-width: 0; margin-right: 8px; }
    .navbar-brand img { width: auto; height: 48px; max-width: 150px; object-fit: contain; }
    .navbar-brand-text { font-size: 18px; line-height: 1.1; }
    .navbar-toggler { flex: 0 0 auto; padding: 6px 8px; }
    .navbar-collapse { width: 100%; }
    .navbar-nav { width: 100%; }
    .navbar-nav .nav-link { padding: 10px 8px !important; }
    .navbar .nav-info-box, .navbar .my-cash-link, .navbar .user-profile { max-width: 100%; }
    .navbar .my-cash-item { margin: 6px 0; }

    /* Hero and heading */
    .hero-section { min-height: 0; padding: 28px 0 44px; }
    .hero-heading { max-width: 100%; padding: 0 10px; font-size: 1.25rem; line-height: 1.3; letter-spacing: .2px; margin-bottom: 16px; white-space: normal; overflow-wrap: anywhere; }
    .search-box-container { width: calc(100% - 20px); max-width: none; margin: 0 10px; padding: 12px; border-radius: 12px; }

    /* Trip type tabs */
    .search-type-selector { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
    .search-type-selector .form-check-inline { display: inline-flex; align-items: center; gap: 5px; margin: 0; min-width: 0; }
    .search-type-selector .form-check-label { font-size: 12px; line-height: 1.2; white-space: nowrap; }
    .search-type-selector .form-check-input { width: 16px; height: 16px; margin: 0; flex: 0 0 16px; }

    /* One-way/round-trip search fields: two compact columns, traveller full width. */
    .search-fields-row { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; margin: 0 !important; border-radius: 10px; overflow: visible; }
    .search-fields-row > .search-field { width: auto !important; max-width: none !important; min-width: 0; min-height: 74px; flex: none !important; padding: 10px 9px; border-right: 0 !important; border-bottom: 1px solid #eceff1; }
    .search-fields-row > .search-field:nth-child(odd) { border-right: 1px solid #eceff1 !important; }
    .search-fields-row > .search-field:last-child { grid-column: 1 / -1; border-right: 0 !important; border-bottom: 0; }
    .search-field label { max-width: 100%; margin-bottom: 5px; font-size: 11px; line-height: 1.2; }
    .search-field input[type="date"], .search-field .airport-input, .search-field input[type="number"], .search-field select { width: 100%; min-width: 0 !important; height: 40px; padding: 7px 9px; font-size: 13px; }
    .search-field .airport-input { padding-right: 28px; }
    .search-field input[type="date"]::-webkit-calendar-picker-indicator { width: 16px; height: 16px; }
    .traveler-class-selector { min-width: 0; width: 100%; }
    .field-main { min-width: 0; max-width: 100%; font-size: 16px; line-height: 1.2; white-space: normal; overflow-wrap: anywhere; }
    .field-sub { max-width: 100%; font-size: 10px; white-space: nowrap; }
    .swap-button { right: -18px; width: 34px; height: 34px; font-size: 15px; z-index: 3; }

    /* Fare choices: readable two-column chips rather than a clipped single row. */
    .fare-type-section { display: block; width: 100%; margin-top: 10px; padding: 11px 10px; }
    .fare-type-label { display: block; min-width: 0; margin-bottom: 8px; font-size: 13px; }
    .fare-type-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 8px 6px; overflow: visible; }
    .fare-type-option { display: flex; align-items: center; min-width: 0; }
    .fare-type-radio { width: 17px; height: 17px; flex: 0 0 17px; margin-right: 5px; }
    .fare-type-label-text { min-width: 0; font-size: 11.5px; line-height: 1.2; white-space: normal; }
    .btn-search { width: 100%; margin-top: 12px; padding: 12px 16px; font-size: 16px; }

    /* Multicity and group forms */
    .multicity-fields .row, .group-booking-fields .search-fields-row { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); width: 100%; margin: 0 !important; }
    .multicity-fields .row > .search-field, .group-booking-fields .search-fields-row > .search-field { width: auto !important; max-width: none !important; min-width: 0; padding: 9px; }
    .multicity-fields .row > .search-field:last-child { grid-column: 1 / -1; }
    .group-booking-fields .search-fields-row > .search-field:last-child { grid-column: 1 / -1; }
    .multicity-fields .row > .search-field:nth-child(odd), .group-booking-fields .search-fields-row > .search-field:nth-child(odd) { border-right: 1px solid #eceff1 !important; }
    .multicity-fields .row > .search-field:last-child, .group-booking-fields .search-fields-row > .search-field:last-child { border-right: 0 !important; }
    .mc-segment-card { padding: 22px 10px 12px; }
    .mc-segment-card .row { gap: 0; }
    .group-booking-fields .search-fields-row { margin-bottom: 8px !important; }

    /* Trending routes: one full-width card per row, with a compact action area. */
    .trending-section { overflow: hidden; }
    .trending-section .row { display: flex; gap: 12px 0; }
    .trending-section [class*="col-"] { width: 100%; max-width: 100%; flex: 0 0 100%; padding-left: 0; padding-right: 0; }
    .route-card { width: 100%; min-width: 0; min-height: 80px; gap: 8px; padding: 8px; }
    .route-img { width: 54px; height: 54px; margin-right: 0; flex: 0 0 54px; }
    .route-info { min-width: 0; overflow: hidden; }
    .route-cities { max-width: 100%; font-size: 12px; line-height: 1.25; white-space: normal; overflow-wrap: anywhere; }
    .route-codes { font-size: 11px; }
    .route-date { font-size: 10px; }
    .route-actions { width: 92px; flex: 0 0 92px; margin-top: 0; }
    .route-actions .btn { display: block; width: 100%; padding: 6px 5px; font-size: 10px; line-height: 1.15; white-space: normal; }

    /* Promo/features/footer sections */
    .promo-banner-section, .features-section, .feature-section { overflow: hidden; }
    .promo-content, .promo-banner { max-width: 100%; }
    .promo-content { grid-template-columns: 1fr !important; }
    .promo-image, .promo-image img { max-width: 100%; width: 100%; }

    /* Shared cards, forms, tables and action rows. */
    .card, .detail-card, .action-card, .booking-card, .form-card, .summary-card { max-width: 100%; }
    .table-responsive { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-responsive table { min-width: 560px; }
    .btn, button { max-width: 100%; }
    .booking-actions, .confirmation-actions, .action-buttons { gap: 8px; }
}

@media (max-width: 420px) {
    .container { padding-left: 12px; padding-right: 12px; }
    .navbar-brand img { height: 43px; max-width: 132px; }
    .navbar-brand-text { font-size: 16px; }
    .search-box-container { width: calc(100% - 12px); margin-left: 6px; margin-right: 6px; padding: 9px; }
    .search-type-selector { gap: 7px 9px; }
    .search-type-selector .form-check-label { font-size: 11px; }
    .search-field { padding-left: 7px !important; padding-right: 7px !important; }
    .search-field input[type="date"], .search-field .airport-input { font-size: 12px; padding-left: 7px; padding-right: 7px; }
    .field-main { font-size: 14px; }
    .fare-type-label-text { font-size: 10.5px; }
    .route-actions { width: 84px; flex-basis: 84px; }
}

/* Results pages: stack legacy fixed columns inside each card. Date strips remain
   intentionally horizontally scrollable because they contain four date choices. */
@media (max-width: 767.98px) {
    .flight-card { width: 100%; max-width: 100%; min-width: 0; padding: 14px; }
    .flight-card-main { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
    .flight-card-main > .flight-card-col, .flight-card-main > [class*="-col"] { width: 100%; min-width: 0; max-width: 100%; align-items: flex-start; text-align: left; }
    .airline-col, .departure-col, .arrival-col, .price-col, .book-col, .duration-col { min-width: 0 !important; width: 100%; }
    .duration-col { padding: 8px 0; border-top: 1px solid #edf0f2; border-bottom: 1px solid #edf0f2; }
    .price-col { text-align: left; }
    .price-large { font-size: 22px; }
    .book-col { width: 100%; }
    .book-btn-large { width: 100%; min-width: 0; }
    .flight-card-body { width: 100%; max-width: 100%; }
    .filters-sidebar, .results-main, .results-content { width: 100%; max-width: 100%; min-width: 0; }
    .sorting-bar, .sort-options { max-width: 100%; }
    .sort-options { overflow-x: auto; white-space: nowrap; }
    .date-fare-strip { width: 100%; max-width: 100%; overflow-x: auto; }
    .date-fare-items { min-width: 520px; }
    .trip-summary-strip { width: 100%; max-width: 100%; flex-wrap: wrap; }
    .results-header { width: 100%; max-width: 100%; min-width: 0; padding: 10px 12px !important; margin-left: 0 !important; margin-right: 0 !important; display: flex !important; flex-direction: row !important; align-items: center !important; justify-content: space-between !important; gap: 8px !important; overflow: hidden; }
    .results-header h2 { flex: 1 1 auto; min-width: 0; margin: 0 !important; font-size: 19px !important; line-height: 1.2 !important; white-space: nowrap; }
    .results-header h2 i { margin-right: 4px; }
    .results-header .results-count { flex: 0 0 auto; max-width: 43%; font-size: 12px; line-height: 1.2; text-align: right; }
}

/* Booking and checkout pages. */
@media (max-width: 767.98px) {
    .booking-container, .payment-container, .confirmation-container { width: 100%; max-width: 100%; grid-template-columns: minmax(0, 1fr) !important; }
    .booking-details, .booking-summary, .confirmation-actions, .booking-main { width: 100%; max-width: 100%; min-width: 0; }
    .detail-card, .action-card, .pnr-card, .form-card, .summary-card { padding: 14px; }
    .pnr-info, .flight-meta, .payment-info { min-width: 0; }
    .flight-route { width: 100%; max-width: 100%; }
    .passenger-table, .fare-details { max-width: 100%; overflow-x: auto; }
    .booking-header, .success-banner { gap: 10px; }
    .booking-header { flex-wrap: wrap; }
    .booking-header > * { min-width: 0; }
}

/* Homepage contrast and ultra-narrow phone refinements. These rules are
   intentionally scoped to mobile widths so desktop styling remains unchanged. */
@media (max-width: 767.98px) {
    .trending-section .section-title,
    .faq-section .section-title {
        color: #ffffff !important;
        text-shadow: 0 1px 1px rgba(0, 0, 0, .18);
    }

    .trending-section .section-title .text-primary-blue {
        color: #4db8ff !important;
    }

    .feature-card h4 {
        color: #1b2940 !important;
    }

    .feature-card p {
        color: #536274 !important;
    }

    .feature-card {
        padding: 22px 14px;
    }

    .feature-icon {
        width: 54px;
        height: 54px;
        margin-bottom: 14px;
        font-size: 21px;
    }

    .feature-card h4 {
        font-size: 16px;
        margin-bottom: 9px;
    }

    .feature-card p {
        font-size: 12px;
        line-height: 1.45;
    }

    .faq-header {
        margin-bottom: 22px;
    }

    .faq-subtitle {
        color: #d9e5f2 !important;
        font-size: 13px;
        line-height: 1.45;
    }

    .faq-question-text {
        line-height: 1.3;
    }

    .faq-icon {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }
}

@media (max-width: 320px) {
    .container {
        padding-left: 8px;
        padding-right: 8px;
    }

    .hero-section {
        padding-top: 22px;
        padding-bottom: 32px;
    }

    .hero-heading {
        padding: 0 4px;
        font-size: 1.1rem;
        line-height: 1.25;
        margin-bottom: 12px;
    }

    .search-box-container {
        width: calc(100% - 4px);
        margin-left: 2px;
        margin-right: 2px;
        padding: 8px;
        border-radius: 10px;
    }

    .search-type-selector {
        gap: 7px 8px;
        margin-bottom: 9px;
    }

    .search-type-selector .form-check-label {
        font-size: 10px;
    }

    .search-type-selector .form-check-input {
        width: 15px;
        height: 15px;
        flex-basis: 15px;
    }

    .search-fields-row > .search-field {
        min-height: 68px;
        padding: 8px 6px;
    }

    .search-field label {
        font-size: 10px;
        margin-bottom: 4px;
    }

    .search-field input[type="date"],
    .search-field .airport-input,
    .search-field input[type="number"],
    .search-field select {
        min-width: 0 !important;
        height: 37px;
        padding: 6px;
        font-size: 11px;
    }

    .search-field .airport-input {
        padding-right: 22px;
    }

    .field-main {
        font-size: 13px;
    }

    .field-sub {
        font-size: 9px;
    }

    .swap-button {
        right: -15px;
        width: 30px;
        height: 30px;
        font-size: 13px;
    }

    .fare-type-section {
        padding: 9px 8px;
        margin-top: 8px;
    }

    .fare-type-label {
        font-size: 12px;
        margin-bottom: 7px;
    }

    .fare-type-options {
        gap: 7px 4px;
    }

    .fare-type-label-text {
        font-size: 10px;
    }

    .fare-type-radio {
        width: 16px;
        height: 16px;
        flex-basis: 16px;
        margin-right: 4px;
    }

    .btn-search {
        margin-top: 9px;
        padding: 10px 12px;
        font-size: 15px;
    }

    .trending-section .section-title,
    .faq-section .section-title,
    .features-section .section-title {
        font-size: 1.35rem;
        line-height: 1.25;
    }

    .route-card {
        min-height: 74px;
        padding: 7px;
    }

    .route-img {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
    }

    .route-cities {
        font-size: 11px;
    }

    .route-codes,
    .route-date {
        font-size: 10px;
    }

    .route-actions {
        width: 76px;
        flex-basis: 76px;
    }

    .route-actions .btn {
        padding: 5px 3px;
        font-size: 9px;
    }

    .faq-question {
        padding: 12px 11px;
    }

    .faq-question-text {
        font-size: 12px;
        padding-right: 8px;
    }

    .faq-icon {
        width: 26px;
        height: 26px;
        min-width: 26px;
        font-size: 1.1rem;
    }
}

/* Final mobile control reset for browsers that stretch native radios.
   Explicit min/max dimensions keep each control circular at all phone widths. */
@media (max-width: 767.98px) {
    .search-type-selector {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: center;
        gap: 8px 10px;
    }

    .search-type-selector .form-check-inline {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 5px;
        min-height: 28px;
    }

    .search-type-selector .form-check-input,
    .fare-type-section .fare-type-radio {
        appearance: none !important;
        -webkit-appearance: none !important;
        display: inline-block !important;
        width: 16px !important;
        min-width: 16px !important;
        max-width: 16px !important;
        height: 16px !important;
        min-height: 16px !important;
        max-height: 16px !important;
        flex: 0 0 16px !important;
        padding: 0 !important;
        margin: 0 !important;
        border: 2px solid #dbe5ef !important;
        border-radius: 50% !important;
        background: #ffffff !important;
        background-image: none !important;
        transform: none !important;
        box-shadow: none !important;
    }

    .search-type-selector .form-check-input:checked,
    .fare-type-section .fare-type-radio:checked {
        border-color: #0d8abc !important;
        background: #0d8abc !important;
        box-shadow: inset 0 0 0 4px #ffffff !important;
    }

    .search-type-selector .form-check-label,
    .fare-type-section .fare-type-label-text {
        min-width: 0;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 320px) {
    .search-type-selector {
        gap: 6px 7px;
    }

    .search-type-selector .form-check-label {
        font-size: 10px;
    }
}

/* Defensive final reset for mobile browsers with form-control stretching. */
@media (max-width: 767.98px) {
    .search-type-selector input[type="radio"].form-check-input {
        inline-size: 16px !important;
        block-size: 16px !important;
        width: 16px !important;
        height: 16px !important;
        min-inline-size: 16px !important;
        max-inline-size: 16px !important;
        min-block-size: 16px !important;
        max-block-size: 16px !important;
        aspect-ratio: 1 / 1 !important;
        align-self: center !important;
        writing-mode: horizontal-tb !important;
        border-radius: 50% !important;
    }
}

/* Use label pseudo-elements for phone radios. This avoids native browser
   radio rendering being stretched into an oval while keeping inputs functional. */
@media (max-width: 767.98px) {
    .search-type-selector .form-check-input,
    .fare-type-section .fare-type-radio {
        position: absolute !important;
        inline-size: 1px !important;
        block-size: 1px !important;
        width: 1px !important;
        height: 1px !important;
        min-width: 1px !important;
        min-height: 1px !important;
        max-width: 1px !important;
        max-height: 1px !important;
        margin: -1px !important;
        padding: 0 !important;
        border: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
        clip: rect(0 0 0 0) !important;
        clip-path: inset(50%) !important;
        white-space: nowrap !important;
    }

    .search-type-selector .form-check-label,
    .fare-type-section .fare-type-label-text {
        position: relative;
        display: inline-flex !important;
        align-items: center;
        gap: 5px;
        min-width: 0;
        cursor: pointer;
    }

    .search-type-selector .form-check-label::before,
    .fare-type-section .fare-type-label-text::before {
        content: "";
        display: inline-block;
        inline-size: 16px;
        block-size: 16px;
        width: 16px;
        height: 16px;
        min-width: 16px;
        min-height: 16px;
        max-width: 16px;
        max-height: 16px;
        flex: 0 0 16px;
        box-sizing: border-box;
        border: 2px solid #dbe5ef;
        border-radius: 50%;
        background: #ffffff;
    }

    .search-type-selector .form-check-input:checked + .form-check-label::before,
    .fare-type-section .fare-type-radio:checked + .fare-type-label-text::before {
        border-color: #0d8abc;
        background: #0d8abc;
        box-shadow: inset 0 0 0 4px #ffffff;
    }

    .search-type-selector .form-check-input:focus-visible + .form-check-label::before,
    .fare-type-section .fare-type-radio:focus-visible + .fare-type-label-text::before {
        outline: 2px solid #4db8ff;
        outline-offset: 2px;
    }
}

@media (max-width: 320px) {
    .search-type-selector .form-check-label::before,
    .fare-type-section .fare-type-label-text::before {
        inline-size: 15px;
        block-size: 15px;
        width: 15px;
        height: 15px;
        min-width: 15px;
        min-height: 15px;
        max-width: 15px;
        max-height: 15px;
        flex-basis: 15px;
    }
}
