/*
 * GoTripBroker — mobile app shell (logged-in users, screens <= 1024px).
 * Plain CSS loaded after main.css; desktop and guests are not affected.
 * Markup: resources/views/partials/mobile-app-shell.blade.php
 */
.mapp-top, .mapp-tabs, .mapp-sheet { display: none; }

@media (max-width: 1024px) {
  body.mapp-on {
    --mapp-green: #19694F;
    --mapp-green-dark: #0f4a37;
    --mapp-ink: #1c2321;
    --mapp-muted: #6c776f;
    --mapp-line: #e7e3d8;
    --mapp-top-h: 56px;
    --mapp-tabs-h: 64px;
    padding-top: calc(var(--mapp-top-h) + env(safe-area-inset-top));
    padding-bottom: calc(var(--mapp-tabs-h) + env(safe-area-inset-bottom) + 8px);
    -webkit-tap-highlight-color: transparent;
  }

  /* Website chrome that the app shell replaces */
  body.mapp-on .tqh-navbar,
  body.mapp-on .tqh-bottomnav,
  /* Only the layout's "Back to Dashboard" strip - content pages reuse .tqh_content_innerPage */
  body.mapp-on .tqh-back-dashboard,
  body.mapp-on .tqh-footer,
  body.mapp-on .gtbw { display: none !important; }

  /* Cookie banner sits above the tabs instead of under them */
  body.mapp-on #cookieBanner { bottom: calc(var(--mapp-tabs-h) + env(safe-area-inset-bottom)) !important; }

  /* ---------- Top bar ---------- */
  body.mapp-on .mapp-top {
    display: flex; align-items: center; gap: 6px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 1001;
    height: calc(var(--mapp-top-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 8px 0 4px;
    background: #fff; border-bottom: 1px solid var(--mapp-line);
    box-shadow: 0 1px 8px rgba(16, 24, 20, .05);
  }
  .mapp-logo { display: flex; align-items: center; padding-left: 10px; flex: 1; min-width: 0; }
  .mapp-logo img { height: 34px; width: auto; }
  .mapp-back {
    width: 44px; height: 44px; border: 0; background: none; color: var(--mapp-ink);
    display: grid; place-items: center; border-radius: 12px; flex: none;
  }
  .mapp-back:active { background: #f1efe8; }
  .mapp-title {
    flex: 1; min-width: 0; font: 700 17px/1.2 'Space Grotesk', 'Manrope', sans-serif; color: var(--mapp-ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mapp-bell {
    position: relative; width: 44px; height: 44px; display: grid; place-items: center;
    color: var(--mapp-ink); border-radius: 12px; flex: none;
  }
  .mapp-bell:active { background: #f1efe8; }

  /* ---------- Bottom tabs ---------- */
  body.mapp-on .mapp-tabs {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001;
    height: calc(var(--mapp-tabs-h) + env(safe-area-inset-bottom));
    padding: 4px 4px env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--mapp-line);
    box-shadow: 0 -2px 14px rgba(16, 24, 20, .06);
  }
  .mapp-tab {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: #8a8f98; text-decoration: none; border: 0; background: none; padding: 4px 0;
    font: 600 11px/1.1 'Manrope', sans-serif;
  }
  .mapp-tab.is-active { color: var(--mapp-green); }
  .mapp-tab.is-active .mapp-tab-lb { font-weight: 800; }
  .mapp-tab-ic { position: relative; display: grid; place-items: center; height: 28px; }
  .mapp-tab-lb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .mapp-tab.is-centre .mapp-tab-ic {
    width: 48px; height: 48px; margin-top: -22px; border-radius: 50%;
    background: var(--mapp-green); color: #fff; box-shadow: 0 6px 16px rgba(25, 105, 79, .35);
  }
  .mapp-tab.is-centre { color: var(--mapp-green); }

  .mapp-badge {
    position: absolute; top: -4px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: #e5484d; color: #fff; font: 700 10.5px/18px 'Manrope', sans-serif;
    text-align: center; box-shadow: 0 0 0 2px #fff;
  }
  .mapp-bell .mapp-badge { top: 4px; right: 2px; }

  /* ---------- "More" sheet ---------- */
  body.mapp-on .mapp-sheet { display: block; position: fixed; inset: 0; z-index: 1100; }
  .mapp-sheet[hidden] { display: none !important; }
  .mapp-sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 20, 16, .45); opacity: 0; transition: opacity .2s; }
  .mapp-sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow-y: auto;
    background: #fff; border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
    transform: translateY(100%); transition: transform .22s ease-out;
  }
  .mapp-sheet.is-open .mapp-sheet-backdrop { opacity: 1; }
  .mapp-sheet.is-open .mapp-sheet-panel { transform: translateY(0); }
  .mapp-sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: #d9d5ca; margin: 4px auto 12px; }
  .mapp-sheet-user { display: flex; align-items: center; gap: 12px; padding: 4px 4px 14px; border-bottom: 1px solid var(--mapp-line); margin-bottom: 4px; }
  .mapp-sheet-user b { display: block; font-size: 16px; color: var(--mapp-ink); }
  .mapp-sheet-user small { color: var(--mapp-muted); font-size: 13px; }
  .mapp-avatar {
    width: 44px; height: 44px; border-radius: 50%; background: var(--mapp-green); color: #fff;
    display: grid; place-items: center; font: 800 18px/1 'Manrope', sans-serif; flex: none;
  }
  .mapp-sheet-link {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    min-height: 52px; padding: 0 4px; border: 0; border-bottom: 1px solid #f1efe8; background: none;
    color: var(--mapp-ink); font: 600 15.5px/1.2 'Manrope', sans-serif; text-decoration: none; text-align: left;
  }
  .mapp-sheet-link span { color: #b3b0a6; font-size: 22px; }
  .mapp-logout { color: #c2410c; border-bottom: 0; }
  .mapp-install { color: var(--mapp-green); font-weight: 800; }

  /* Running as the installed app: no install offer needed */
  @media (display-mode: standalone) { .mapp-install { display: none !important; } }

  /* ---------- Page fixes ---------- */
  /* Agent "Direct requests": stack trip details above the action button */
  body.mapp-on .vendorLeadsPage .tqh_card_inner { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  body.mapp-on .vendorLeadsPage .card_inner_div2 { position: static; display: flex; }
  body.mapp-on .vendorLeadsPage .card_inner_div2 > * { flex: 1; text-align: center; }

  /* ---------- Trip page: agents and quotes first ---------- */
  body.mapp-on .tripsShowPage .myTrips_backFeed_link,
  body.mapp-on .tripsShowPage > .container > .tqh-eyebrow,
  body.mapp-on .tripsShowPage .tqh-compare-tip,
  body.mapp-on .tripsShowPage .tqh-coupon-tip,
  body.mapp-on .tripsShowPage .ts-status-banner .tqh-btn-ghost { display: none !important; }
  body.mapp-on .tripsShowPage > .container > .tqh-sect-title { font-size: 20px; margin: 0 0 8px; }
  body.mapp-on .tripsShowPage .tqh-compare-trip-card { margin-top: 0; padding: 12px 14px; }
  body.mapp-on .tripsShowPage .ts-status-banner { padding: 12px; gap: 10px; }
  body.mapp-on .tripsShowPage .tqh-quotes-grid { grid-template-columns: 1fr; }
  body.mapp-on .tripsShowPage .tqh-sort-bar { flex-wrap: wrap; gap: 4px; }
  /* "Message selected agents" stays reachable above the tabs while picking */
  body.mapp-on .js-pack-bar {
    position: sticky; z-index: 5;
    bottom: calc(var(--mapp-tabs-h) + env(safe-area-inset-bottom) + 8px);
    box-shadow: 0 -6px 22px rgba(16, 24, 20, .12);
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px;
  }
  /* Compact on phones: the button already says "Free" or the price */
  body.mapp-on .js-pack-bar > .tqh-muted { display: none; }
  body.mapp-on .js-pack-bar > .u-fw-700 { font-size: 13px; width: 100%; }
  body.mapp-on .js-pack-bar .js-pack-send { margin-top: 0 !important; flex: 1; }
  body.mapp-on .js-pack-bar .js-pack-count { font-size: 12px; }

  /* ---------- Chat before booking: conversation first, typing box fixed ---------- */
  body.mapp-on .leadChatPage .container { display: flex; flex-direction: column; }
  body.mapp-on .leadChatPage .container > a.tqh-muted,
  body.mapp-on .leadChatPage .tqh-eyebrow,
  body.mapp-on .leadChatPage .container > .tqh-sect-title { display: none; }
  body.mapp-on .leadChatPage .tqh-compare-trip-card { order: 1; margin: 0 0 10px; padding: 12px 14px; }
  body.mapp-on .leadChatPage .leadChat__box { order: 2; margin-top: 0 !important; }
  body.mapp-on .leadChatPage .leadChat__quote { order: 3; }
  body.mapp-on .leadChatPage .leadChat__messages { max-height: none !important; min-height: 38vh; }
  body.mapp-on .leadChat__composer {
    position: sticky; z-index: 4; display: flex; align-items: flex-end; gap: 8px;
    bottom: calc(var(--mapp-tabs-h) + env(safe-area-inset-bottom) + 6px);
    background: #fff; padding: 8px 0 2px; margin-top: 8px !important;
  }
  body.mapp-on .leadChat__bubble {
    display: inline-block; max-width: 84%; border-radius: 18px; padding: 9px 13px; margin-top: 3px;
    font: 500 15px/1.4 'Manrope', sans-serif; background: #f1efe8; color: #1c2321; border: 0;
  }
  body.mapp-on .leadChat__msg.is-them .leadChat__bubble { border-bottom-left-radius: 6px; }
  body.mapp-on .leadChat__msg.is-mine .leadChat__bubble { background: var(--mapp-green); color: #fff; border-bottom-right-radius: 6px; }
  body.mapp-on .leadChat__composer textarea { flex: 1; margin: 0; min-height: 46px; border-radius: 22px; padding: 12px 16px; resize: none; }
  body.mapp-on .leadChat__composer button { margin: 0 !important; border-radius: 22px; min-width: 72px; }

  /* ---------- Booking chat: single column, typing box fixed ---------- */
  body.mapp-on .tqh-chat-layout { grid-template-columns: 1fr; }
  body.mapp-on .tqh-chat-thread { max-height: 55vh; }
  body.mapp-on .chatInput__sec {
    position: sticky; z-index: 4; background: #fff; padding-top: 8px;
    bottom: calc(var(--mapp-tabs-h) + env(safe-area-inset-bottom) + 6px);
  }

  /* ---------- App feel for page content ---------- */
  body.mapp-on main .container { padding-left: 14px; padding-right: 14px; }
  body.mapp-on .tqh-content { padding-top: 14px; }
  body.mapp-on .tqh-card, body.mapp-on .tqh-quote-card { border-radius: 16px; }
  body.mapp-on .tqh-btn-primary, body.mapp-on .tqh-btn-ghost, body.mapp-on .tqh-accept-btn { min-height: 44px; }
}
