/* ============================================================
   pay.tripass.ma — Stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --tp-bg:         #f0f4f8;
  --tp-surface:    #ffffff;
  --tp-primary:    #1a56db;
  --tp-primary-h:  #1648c6;
  --tp-success:    #0e9f6e;
  --tp-danger:     #e02424;
  --tp-text:       #111928;
  --tp-muted:      #6b7280;
  --tp-border:     #e5e7eb;
  --tp-radius:     12px;
  --tp-shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 20px rgba(0,0,0,.06);
  --tp-font:       'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: var(--tp-font);
  background: var(--tp-bg);
  color: var(--tp-text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Page wrapper ─────────────────────────────────────────── */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────── */
.tp-header {
  background: #0f172a;
  color: #fff;
  padding: 0 1.5rem;
}
.tp-header__inner {
  max-width: 520px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tp-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.3px;
}
.tp-logo__mark {
  width: 28px;
  height: 28px;
  background: var(--tp-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 800;
  color: #fff;
}
.tp-logo__name { color: #e2e8f0; }
.tp-logo__dot  { color: var(--tp-primary); }
.tp-secure {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  color: #94a3b8;
}

/* ── Main ────────────────────────────────────────────────── */
.tp-main {
  flex: 1;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tp-main--result {
  justify-content: center;
}

/* ── Alert ───────────────────────────────────────────────── */
.alert {
  width: 100%;
  max-width: 520px;
  margin-bottom: 1rem;
  padding: .75rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 500;
}
.alert--error {
  background: #fef2f2;
  color: var(--tp-danger);
  border: 1px solid #fecaca;
}

/* ── Payment form ────────────────────────────────────────── */
.payment-form {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-section {
  background: var(--tp-surface);
  border-radius: var(--tp-radius);
  padding: 1.5rem;
  box-shadow: var(--tp-shadow);
}
.form-section__title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tp-muted);
  margin-bottom: 1rem;
}

/* Transaction summary card */
.txn-card {
  background: #0f172a;
  border-radius: 14px;
  padding: 1.5rem 1.25rem 1.25rem;
  margin-bottom: 1.25rem;
  color: #fff;
}
.txn-card__row--amount {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: center;
  margin-bottom: 1.1rem;
}
.txn-amount-num {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.txn-amount-cur {
  font-size: 1.1rem;
  font-weight: 600;
  color: #94a3b8;
  align-self: flex-end;
  padding-bottom: 4px;
}
.txn-card__divider {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 0 0 1rem;
}
.txn-card__meta {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.txn-meta-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.txn-meta-item--desc {
  align-items: flex-start;
}
.txn-meta-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #475569;
  white-space: nowrap;
  padding-top: 1px;
}
.txn-meta-value {
  font-size: .875rem;
  font-weight: 600;
  color: #e2e8f0;
  text-align: right;
}
.txn-meta-value--mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .8rem;
  color: #94a3b8;
  font-weight: 500;
}
.txn-meta-value--desc {
  font-weight: 400;
  color: #94a3b8;
  font-size: .82rem;
  text-align: right;
}

/* ── Form fields ─────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1rem;
}
.field:last-child { margin-bottom: 0; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.field-row .field { margin-bottom: 0; }

.field-row--phone {
  grid-template-columns: 140px 1fr;
}
.field--prefix,
.field--phone-num { margin-bottom: 0; }
.field__select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  padding-right: 1.8rem;
  cursor: pointer;
}

label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--tp-text);
  display: flex;
  align-items: center;
  gap: 4px;
}
.field__hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tp-border);
  color: var(--tp-muted);
  font-size: .65rem;
  cursor: help;
}
.field__input {
  border: 1.5px solid var(--tp-border);
  border-radius: 8px;
  padding: .6rem .75rem;
  font-size: .95rem;
  font-family: var(--tp-font);
  color: var(--tp-text);
  background: #fafafa;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  width: 100%;
  min-height: 44px; /* touch target */
}
.field__input:focus {
  border-color: var(--tp-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
  background: #fff;
}
.field__input::placeholder { color: #c0c7d1; }

/* CGU checkbox */
.cgu-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: .25rem 0 .75rem;
  user-select: none;
}
.cgu-check__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.cgu-check__box {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid #d1d5db;
  background: #fff;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}
.cgu-check__input:checked + .cgu-check__box {
  background: var(--tp-primary);
  border-color: var(--tp-primary);
}
.cgu-check__input:checked + .cgu-check__box::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}
.cgu-check__text {
  font-size: .82rem;
  color: var(--tp-muted);
  line-height: 1.45;
}
.cgu-check__link {
  color: var(--tp-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Pay button ─────────────────────────────────────────── */
.btn-pay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: var(--tp-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--tp-font);
  cursor: pointer;
  transition: background .2s, transform .1s;
  width: 100%;
}
.btn-pay:hover  { background: var(--tp-primary-h); }
.btn-pay:active { transform: scale(.98); }
.btn-pay:disabled {
  background: #9ab3f5;
  cursor: not-allowed;
  transform: none;
}

.form-notice {
  text-align: center;
  font-size: .75rem;
  color: var(--tp-muted);
  line-height: 1.5;
}

/* ── Result card ────────────────────────────────────────── */
.result-card {
  background: var(--tp-surface);
  border-radius: var(--tp-radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--tp-shadow);
  max-width: 440px;
  width: 100%;
  text-align: center;
}
.result-card--success { border-top: 4px solid var(--tp-success); }
.result-card--fail    { border-top: 4px solid var(--tp-danger);  }

.result-card__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}
.result-card--success .result-card__icon {
  background: #d1fae5;
  color: var(--tp-success);
}
.result-card--fail .result-card__icon {
  background: #fee2e2;
  color: var(--tp-danger);
}

.result-card__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .5rem;
}
.result-card__subtitle {
  color: var(--tp-muted);
  font-size: .95rem;
  margin-bottom: 1.75rem;
}

.result-details {
  background: var(--tp-bg);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.75rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.result-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
}
.result-detail__label {
  font-size: .8rem;
  color: var(--tp-muted);
  white-space: nowrap;
}
.result-detail__value {
  font-size: .85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  text-align: right;
}
.result-detail__value--amount {
  font-size: 1.1rem;
  color: var(--tp-success);
}

.fail-advice {
  font-size: .85rem;
  color: var(--tp-muted);
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.btn-back {
  display: block;
  width: 100%;
  text-align: center;
  background: var(--tp-primary);
  color: #fff;
  border-radius: 8px;
  padding: .875rem 1.75rem;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s;
  min-height: 44px;
  line-height: 1.4;
}
.btn-back:hover { background: var(--tp-primary-h); }
.btn-back--retry {
  background: var(--tp-danger);
}
.btn-back--retry:hover {
  background: #c81e1e;
}

/* ── Footer ─────────────────────────────────────────────── */
.tp-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: .75rem;
  color: var(--tp-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
}

/* ── Responsive ──────────────────────────────────────────── */

/* ── Tablet & small desktop (≤ 600px) ── */
@media (max-width: 600px) {
  .tp-main {
    padding: 1.25rem .75rem;
  }
  .payment-form,
  .alert {
    max-width: 100%;
  }
  .result-card {
    max-width: 100%;
  }
}

/* ── Mobile (≤ 480px) ── */
@media (max-width: 480px) {
  /* Header */
  .tp-header { padding: 0 1rem; }
  .tp-header__inner { height: 52px; }
  .tp-logo__name { font-size: .9rem; }
  .tp-secure { font-size: .7rem; }
  .tp-secure svg { width: 12px; height: 12px; }

  /* Main */
  .tp-main { padding: 1rem .75rem 2rem; }

  /* Transaction card */
  .txn-card { padding: 1.25rem 1rem 1rem; border-radius: 10px; }
  .txn-amount-num { font-size: 2rem; }
  .txn-amount-cur { font-size: .95rem; }
  .txn-meta-label { font-size: .68rem; }
  .txn-meta-value { font-size: .82rem; }

  /* Form sections */
  .payment-form { gap: 1rem; }
  .form-section { border-radius: 8px; padding: 1.1rem 1rem; }
  .form-section__title { font-size: .75rem; margin-bottom: .85rem; }

  /* Fields */
  .field { gap: 5px; margin-bottom: .85rem; }
  .field__input { font-size: .9rem; padding: .55rem .7rem; }
  .field-row { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .field-row--phone { grid-template-columns: 110px 1fr; }
  label { font-size: .75rem; }

  /* CGU */
  .cgu-check { padding: .15rem 0 .65rem; }
  .cgu-check__text { font-size: .78rem; }

  /* Pay button */
  .btn-pay { padding: .8rem 1.25rem; font-size: .95rem; }

  /* Result pages */
  .result-card { padding: 1.5rem 1.1rem; border-radius: 8px; }
  .result-card__icon { width: 60px; height: 60px; margin-bottom: 1rem; }
  .result-card__icon svg { width: 32px; height: 32px; }
  .result-card__title { font-size: 1.25rem; }
  .result-card__subtitle { font-size: .875rem; margin-bottom: 1.25rem; }
  .result-details { padding: .85rem; gap: .6rem; margin-bottom: 1.25rem; }
  .result-detail { gap: .5rem; }
  .result-detail__label { font-size: .75rem; }
  .result-detail__value { font-size: .8rem; }
  .result-detail__value--amount { font-size: 1rem; }
  .fail-advice { font-size: .8rem; }
  .btn-back { font-size: .9rem; padding: .8rem; }

  /* Footer */
  .tp-footer { font-size: .7rem; padding: 1rem; }
}

/* ── Very small screens (≤ 360px) ── */
@media (max-width: 360px) {
  .tp-header__inner { height: 48px; }
  .tp-logo__name { display: none; } /* just the mark on tiny screens */
  .txn-amount-num { font-size: 1.75rem; }
  .txn-meta-item {
    flex-direction: column;
    gap: .15rem;
  }
  .txn-meta-value { text-align: left; }
  .field-row--phone { grid-template-columns: 100px 1fr; }
  .result-detail {
    flex-direction: column;
    align-items: flex-start;
    gap: .15rem;
  }
  .result-detail__value { text-align: left; }
}

/* ── Dev console responsive overrides ── */
@media (max-width: 600px) {
  #devConsole { max-height: 160px !important; font-size: 10px !important; }
  #devConsole + div { height: 160px !important; }
}
