/* =========================================================
   CloudPay POS — legacy layout fallbacks
   Target: Android 5.1.1 / Chromium 38 WebView (Urovo i9000S)

   Loaded after app.css. Every rule here is scoped so that
   modern browsers (which support CSS Grid, flex gap and the
   modern shorthand properties) keep the original rendering.
   ========================================================= */

/* ---------- CSS Grid fallbacks ---------- */
@supports not (display: grid) {
  /* icon / centering boxes (display:grid + place-items:center) */
  .boot-mark,
  .brand-tile,
  .app-back,
  .method-icon,
  .method-card.selected .method-check,
  .terminal-visual,
  .tap-anim,
  .cash-anim,
  .offline-anim,
  .auth-strip .auth-check,
  .result-icon,
  .bill-icon,
  .bill-delete,
  .empty-state-icon,
  .merchant-logo,
  .modal-close,
  .receipt .r-logo,
  .side-avatar,
  .side-logout,
  .topbar-icon,
  .icon-btn,
  .stat-icon,
  .notice-icon,
  .notice-close,
  .report-icon,
  .exchange-step-num,
  .admin-user-avatar,
  .admin-error-icon {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
  }

  /* numeric / card keypad: 3 columns, 4 rows */
  .keypad {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
  }

  .keypad .key {
    -webkit-flex: 0 0 33.3333%;
    flex: 0 0 33.3333%;
    box-sizing: border-box;
  }

  .sales-screen .amount-keypad {
    padding: 0 3px;
  }

  .sales-screen .amount-keypad .key {
    -webkit-flex: 0 0 calc(33.3333% - 6px);
    flex: 0 0 calc(33.3333% - 6px);
    height: calc(25% - 6px);
    min-height: 52px;
    margin: 3px;
  }

  .manual-keypad-card .keypad .key {
    min-height: 46px;
  }

  /* bottom navigation */
  .bottom-nav {
    display: -webkit-flex;
    display: flex;
  }

  .bottom-nav .nav-btn {
    -webkit-flex: 1 1 0;
    flex: 1 1 0;
  }

  /* success page secondary actions */
  .success-secondary {
    display: -webkit-flex;
    display: flex;
  }

  .success-secondary-btn {
    -webkit-flex: 1 1 0;
    flex: 1 1 0;
  }

  .success-secondary-btn + .success-secondary-btn {
    margin-left: 10px;
  }

  /* payment method cards: one per row */
  .method-grid {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
  }

  .method-grid > .method-card {
    margin: 0 0 8px;
  }

  /* manual-entry two-column field rows */
  .field-row {
    display: -webkit-flex;
    display: flex;
  }

  .field-row > * {
    -webkit-flex: 1 1 0;
    flex: 1 1 0;
    min-width: 0;
  }

  .field-row > * + * {
    margin-left: 9px;
  }

  /* payment simulator action buttons */
  .sim-actions {
    display: -webkit-flex;
    display: flex;
  }

  .sim-actions > * {
    -webkit-flex: 1 1 0;
    flex: 1 1 0;
  }

  .sim-actions > * + * {
    margin-left: 7px;
  }

  /* transaction detail modal */
  .modal-txn-grid {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
  }

  .modal-txn-grid > * + * {
    margin-top: 18px;
  }

  /* merchant dashboard stat cards */
  .stat-grid {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    margin-left: -7.5px;
    margin-right: -7.5px;
  }

  .stat-grid > * {
    -webkit-flex: 0 0 calc(50% - 15px);
    flex: 0 0 calc(50% - 15px);
    margin: 0 7.5px 15px;
  }

  .dash-grid,
  .settings-grid,
  .exchange-grid,
  .dash-side {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
  }

  .dash-grid > * + *,
  .settings-grid > * + *,
  .exchange-grid > * + *,
  .dash-side > * + * {
    margin-top: 15px;
  }

  .today-grid {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    margin-left: -6px;
    margin-right: -6px;
  }

  .today-grid > * {
    -webkit-flex: 0 0 calc(50% - 12px);
    flex: 0 0 calc(50% - 12px);
    margin: 0 6px 12px;
  }

  .sett-summary {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    margin-left: -7.5px;
    margin-right: -7.5px;
  }

  .sett-summary > * {
    -webkit-flex: 0 0 calc(50% - 15px);
    flex: 0 0 calc(50% - 15px);
    margin: 0 7.5px 15px;
  }

  .report-grid,
  .form-grid {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
  }

  .report-grid > *,
  .form-grid > * {
    -webkit-flex: 0 0 100%;
    flex: 0 0 100%;
    margin-bottom: 13px;
  }

  /* merchant portal overview pages */
  .progress-steps,
  .upload-grid,
  .info-grid {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-justify-content: space-between;
    justify-content: space-between;
  }

  .progress-steps > * {
    -webkit-flex: 0 0 calc(25% - 9px);
    flex: 0 0 calc(25% - 9px);
    margin-bottom: 10px;
  }

  .upload-grid > *,
  .info-grid > * {
    -webkit-flex: 0 0 calc(50% - 5px);
    flex: 0 0 calc(50% - 5px);
    margin-bottom: 10px;
  }

  @media (max-width: 900px) {
    .progress-steps > * {
      -webkit-flex-basis: calc(50% - 6px);
      flex-basis: calc(50% - 6px);
    }

    .info-grid > * {
      -webkit-flex-basis: 100%;
      flex-basis: 100%;
    }
  }

  @media (max-width: 720px) {
    .upload-grid > * {
      -webkit-flex-basis: 100%;
      flex-basis: 100%;
    }
  }
}

/* ---------- flex `gap` fallbacks ---------- */
@supports not (gap: 1px) {
  .btn > .icon:first-child {
    margin-right: 8px;
  }

  .nav-btn .icon {
    margin-bottom: 4px;
  }

  .method-card > * + * {
    margin-left: 9px;
  }

  .method-text > * + * {
    margin-top: 2px;
  }

  .summary-row > * + *,
  .page-head-row > * + *,
  .bill-item > * + *,
  .merchant-card > * + *,
  .setting-row > * + *,
  .link-row > * + *,
  .toast > * + *,
  .modal-head > * + *,
  .modal-actions > * + *,
  .receipt .r-row > * + *,
  .txn-detail-row > * + *,
  .timeline-item > * + *,
  .confirm-actions > * + *,
  .side-link > * + *,
  .side-brand > * + *,
  .side-user > * + *,
  .side-pos-link > * + *,
  .portal-topbar > * + *,
  .topbar-actions > * + *,
  .portal-page-head > * + *,
  .portal-head-actions > * + *,
  .card-head > * + *,
  .card-head-actions > * + *,
  .chart-head > * + *,
  .pager > * + *,
  .form-actions > * + *,
  .exchange-rate > * + *,
  .auth-brand > * + *,
  .auth-submit > * + *,
  .auth-foot > * + *,
  .notice-banner > * + *,
  .stat-delta > * + *,
  .status-pill > * + *,
  .notif-item > * + * {
    margin-left: 9px;
  }

  .portal-banner > * + *,
  .banner-copy > * + *,
  .alert-row > * + *,
  .progress-header > * + *,
  .mini-progress-head > * + *,
  .mini-progress-meta > * + *,
  .exchange-rate-line > * + *,
  .exchange-label-row > * + *,
  .exchange-progress-meter > * + *,
  .activation-head > * + *,
  .wallet-empty > * + *,
  .upload-box > * + * {
    margin-left: 9px;
  }

  .settlement-actions > * + * {
    margin-left: 8px;
  }

  .activation-meta > * + * {
    margin-left: 8px;
  }

  .exchange-progress-row > * + * {
    margin-left: 9px;
  }

  .exchange-column > * + * {
    margin-top: 15px;
  }

  .progress-header > div > * + * {
    margin-top: 3px;
  }

  .flow-actions > * + * {
    margin-left: 12px;
  }

  .segment > * + * {
    margin-left: 2px;
  }

  .bill-right > * + *,
  .form-field > * + *,
  .exchange-field > * + *,
  .auth-field > * + * {
    margin-top: 5px;
  }

  .table-toolbar > * {
    margin-right: 8px;
    margin-bottom: 6px;
  }
}

/* ---------- landscape layout fallbacks ---------- */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  @supports not (display: grid) {
    .bottom-nav {
      -webkit-flex-direction: column;
      flex-direction: column;
    }

    .bottom-nav .nav-btn {
      -webkit-flex: 1 1 0;
      flex: 1 1 0;
    }

    .sales-screen .screen-body,
    .manual-screen .manual-card {
      display: -webkit-flex;
      display: flex;
      -webkit-flex-direction: column;
      flex-direction: column;
    }

    .sales-screen .keypad-card {
      min-height: 220px;
    }
  }
}
