/* ═══════════════════════════════════════════
   Site-wide mobile enhancements
   ═══════════════════════════════════════════ */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ─── App header & navigation drawer ─── */
@media (max-width: 768px) {
  .app-header-inner {
    height: 56px;
    padding: 0 12px;
    gap: 8px;
  }

  .app-logo-text small { display: none; }
  .app-logo-text strong { font-size: 0.92rem; }
  .app-logo-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .app-back {
    width: 34px;
    height: 34px;
  }

  .app-actions { display: none; }

  .app-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-left: auto;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: #fff;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.2s ease;
  }
  .app-nav-toggle.is-open {
    background: var(--accent-light);
    border-color: rgba(0, 0, 153, 0.25);
  }
  .app-nav-toggle.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .app-nav-toggle.is-open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  .app-nav-toggle.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
  .app-nav-toggle span {
    transition: transform 0.25s ease, opacity 0.2s ease;
  }

  .app-nav-backdrop {
    position: fixed;
    inset: 0;
    top: 56px;
    z-index: 98;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .app-nav-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .app-nav {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    z-index: 99;
    flex: none;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    max-height: calc(100dvh - 56px);
    overflow-y: auto;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
    -webkit-overflow-scrolling: touch;
  }
  .app-nav.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .app-nav-sheet {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
  }
  .app-nav-link {
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    font-size: 0.95rem;
    border-radius: 12px;
    min-height: 48px;
    display: flex;
    align-items: center;
  }
  .app-nav-link.is-active {
    box-shadow: 0 4px 14px rgba(0, 0, 153, 0.18);
  }

  .app-nav-sheet-foot {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
  }
  .app-nav-user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--gray-50);
    border-radius: 12px;
    border: 1px solid var(--gray-200);
  }
  .app-nav-user-row .app-user-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }
  .app-nav-user-row strong {
    display: block;
    font-size: 0.9rem;
    color: var(--gray-900);
  }
  .app-nav-user-row span {
    font-size: 0.75rem;
    color: var(--gray-500);
  }
  .app-btn-logout--block {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 0.9rem;
    border-radius: 12px;
    text-align: center;
  }

  body.app-nav-open {
    overflow: hidden;
    touch-action: none;
  }
}

@media (min-width: 769px) {
  .app-nav-sheet-foot,
  .app-nav-backdrop { display: none !important; }
  .app-nav-sheet {
    display: contents;
  }
}

/* ─── Page shells ─── */
@media (max-width: 768px) {
  .dashboard-page {
    overflow-x: hidden;
  }
  .dashboard-page .dashboard-main,
  .sales-main {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .edit-main {
    max-width: none;
    padding: 12px;
  }

  .inbox-top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .inbox-title { font-size: 1.2rem; }
  .inbox-sub { font-size: 0.85rem; }
  .app-welcome-cta {
    width: 100%;
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .panel {
    border-radius: 16px;
  }
  .dashboard-page .panel h2 {
    padding: 14px 16px;
    font-size: 0.95rem;
  }
  .dashboard-page .ticket-form {
    padding: 14px;
  }

  /* Touch-friendly inputs */
  .dashboard-page .form-group input,
  .dashboard-page .form-group select,
  .dashboard-page .login-input-wrap input,
  .login-input-wrap input {
    min-height: 48px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .dashboard-page .btn,
  .login-submit {
    min-height: 48px;
    touch-action: manipulation;
  }
  .btn-link {
    padding: 6px 4px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* ─── Booking form ─── */
@media (max-width: 768px) {
  .form-section-title {
    font-size: 0.78rem;
  }
  .flight-search-card {
    padding: 14px;
    border-radius: 12px;
  }
  .flight-search-lead { font-size: 0.8rem; }

  .route-picker {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 8px;
  }
  .route-iata-box:first-child { grid-column: 1; }
  .route-swap-btn {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: end;
    margin-bottom: 0;
    width: 44px;
    height: 44px;
  }
  .route-picker-mid {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    margin: 2px 0 6px;
  }
  .route-iata-box:last-child { grid-column: 1 / -1; grid-row: 3; }
  .route-iata-input {
    font-size: 1.2rem !important;
    padding: 14px 10px !important;
  }

  .btn-fetch-flight {
    width: 100%;
    min-width: 0;
    min-height: 48px;
  }
  .flight-fetch-status {
    width: 100%;
    min-width: 0;
    text-align: center;
  }

  .flight-details-route { grid-template-columns: 1fr; }
  .flight-details-mid { order: -1; }

  .dashboard-page .passenger-row {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    background: var(--gray-50);
  }
  .dashboard-page .passenger-row select {
    width: 72px;
    min-height: 48px;
  }
  .dashboard-page .passenger-row select.passenger-type {
    width: 88px;
  }
  .dashboard-page .passenger-row input {
    flex: 1 1 calc(100% - 90px);
    min-height: 48px;
  }
  .dashboard-page .passenger-row input.passenger-dob {
    flex: 1 1 100%;
  }
  .dashboard-page .btn-remove-pax {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    margin-left: auto;
  }
  .dashboard-page .add-pax-btns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  .dashboard-page .add-pax-btns .btn-outline-sm {
    min-height: 44px;
    justify-content: center;
    margin-top: 0;
    font-size: 0.78rem;
    padding: 8px 6px;
  }

  .checkbox-group {
    flex-direction: column;
    gap: 10px;
  }
  .checkbox-label {
    min-height: 44px;
    padding: 4px 0;
  }

  .dashboard-page .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 16px -14px -14px;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, #fff 30%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
  }
  .dashboard-page .form-actions .btn-primary {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
  }
}

/* ─── Live preview ─── */
@media (max-width: 768px) {
  .preview-panel {
    position: static;
    max-height: none;
    top: auto;
  }
  .preview-panel-head { padding: 12px 14px 0; }
  .preview-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 10px;
  }
  .preview-tabs::-webkit-scrollbar { display: none; }
  .preview-tab {
    flex: 0 0 auto;
    min-width: 100px;
    min-height: 44px;
    padding: 10px 14px;
    white-space: nowrap;
  }
  .live-preview { padding: 12px; }
  .et-route { grid-template-columns: 1fr; gap: 12px; }
  .et-route-mid { order: -1; }
  .et-meta-bar { grid-template-columns: 1fr; }
  .et-footer { flex-direction: column; text-align: center; gap: 12px; }
  .et-ticket-no { text-align: center; }
  .et-banner { padding: 12px 14px; min-height: auto; }
  .et-slogan { display: none; }
}

/* ─── Sales history — card layout ─── */
@media (max-width: 768px) {
  .recent-table-wrap {
    padding: 8px;
    overflow: visible;
  }
  .recent-table thead { display: none; }
  .recent-table,
  .recent-table tbody,
  .recent-table tr,
  .recent-table td {
    display: block;
    width: 100%;
  }
  .recent-table tbody tr {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 4px 4px 8px;
    margin: 0 0 12px;
  }
  .recent-table tbody tr:hover {
    transform: none;
    box-shadow: var(--shadow);
  }
  .recent-table td {
    border: none;
    padding: 10px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
  }
  .recent-table td::before {
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gray-500);
    flex: 0 0 72px;
    padding-top: 2px;
  }
  .recent-table td:first-child {
    padding-top: 14px;
    border-bottom: 1px solid var(--gray-100);
    margin-bottom: 4px;
  }
  .recent-table td:first-child::before { display: none; }
  .recent-table td:first-child code {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
  }
  .recent-table .ticket-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }
  .recent-table .ticket-actions .btn-link {
    justify-content: center;
    padding: 10px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    font-weight: 600;
    margin: 0;
  }
  .recent-table .ticket-actions .btn-link-wa {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
  }
  .recent-table .empty {
    display: block;
    text-align: center;
    padding: 24px 16px;
  }
  .recent-table .empty::before { display: none; }
}

/* ─── Login ─── */
@media (max-width: 768px) {
  .login-page {
    overflow-x: hidden;
  }
  .login-split {
    min-height: 100dvh;
  }
  .login-hero {
    padding: max(28px, env(safe-area-inset-top)) 18px 100px;
  }
  .login-hero-title {
    font-size: clamp(1.45rem, 6vw, 1.75rem);
  }
  .login-hero-features li {
    font-size: 0.88rem;
  }
  .login-main {
    padding: 0 16px  max(28px, env(safe-area-inset-bottom));
  }
  .login-card {
    margin-top: -56px;
    width: 100%;
    max-width: 100%;
    padding: 28px 22px 24px;
    border-radius: 20px;
  }
  .login-input-wrap input {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .login-hero {
    padding-bottom: 88px;
  }
  .login-hero-support {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .login-ticket-mock { display: none; }
  .login-card {
    margin-top: -44px;
    padding: 24px 18px 20px;
  }
  .login-card-head h1 { font-size: 1.35rem; }
}

/* ─── Small phones ─── */
@media (max-width: 380px) {
  .app-logo-text strong { font-size: 0.85rem; }
  .dashboard-page .add-pax-btns {
    grid-template-columns: 1fr;
  }
  .preview-tab { min-width: 88px; font-size: 0.72rem; }
}
