/*
 * Sanrad Payments -- mobile-first stylesheet.
 *
 * Built for one-handed phone use first: a fixed bottom nav within thumb
 * reach, 16px minimum input text (anything smaller makes iOS Safari zoom on
 * focus), and 44px minimum tap targets. The desktop layout is a widening of
 * the same structure, not a separate design.
 *
 * Brand blue #5b9bd5 is sampled from the supplied logo.
 */

:root {
  --brand: #5b9bd5;
  --brand-dark: #3d7cb0;
  --brand-tint: #eaf3fb;

  --ink: #16202b;
  --ink-soft: #5a6b7c;
  --line: #dfe6ee;
  --surface: #ffffff;
  --canvas: #f4f7fa;

  --ok: #1f8a54;
  --ok-tint: #e6f4ec;
  --warn: #a9700a;
  --warn-tint: #fdf3e0;
  --danger: #c23b3b;
  --danger-tint: #fbeaea;
  --info-tint: #eaf3fb;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(22, 32, 43, .06), 0 4px 12px rgba(22, 32, 43, .05);
  --nav-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
}

/* ---------- Layout ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.app-header img { height: 28px; width: auto; }
.app-header .spacer { margin-left: auto; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 28px);
}
@media (min-width: 900px) {
  .page { max-width: 1040px; padding-bottom: 32px; }
}

h1 { font-size: 1.35rem; margin: 4px 0 16px; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 24px 0 10px; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-tight { padding: 12px 14px; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:active { background: var(--brand-tint); }

.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 10px; }

/* Amounts are tabular so columns of money line up. */
.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: -.01em;
}
.amount-lg { font-size: 1.5rem; }

/* ---------- Forms ---------- */
label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 5px; }
.hint { font-size: .8rem; color: var(--ink-soft); margin-top: 4px; font-weight: 400; }

input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=number], input[type=date], input[type=datetime-local],
input[type=file], select, textarea {
  width: 100%;
  /* 16px exactly -- smaller triggers iOS Safari's zoom-on-focus. */
  font-size: 16px;
  font-family: inherit;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(91, 155, 213, .22);
}
.field { margin-bottom: 14px; }
.field-error input, .field-error select { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: .82rem; margin-top: 4px; }

.otp-input {
  font-size: 1.6rem !important;
  letter-spacing: .5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 18px;
  font-size: 1rem; font-weight: 600; font-family: inherit;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--brand); color: #fff;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--canvas); }
.btn-danger { background: var(--danger); }
.btn-sm { min-height: 38px; padding: 7px 12px; font-size: .875rem; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; white-space: nowrap;
}
.pill-requested  { background: var(--info-tint);  color: var(--brand-dark); }
.pill-processing { background: var(--warn-tint);  color: var(--warn); }
.pill-approved   { background: var(--info-tint);  color: var(--brand-dark); }
.pill-processed  { background: var(--ok-tint);    color: var(--ok); }
.pill-complete   { background: var(--ok-tint);    color: var(--ok); }
.pill-rejected   { background: var(--danger-tint);color: var(--danger); }

/* ---------- Messages ---------- */
.alert {
  padding: 11px 14px; border-radius: var(--radius-sm);
  margin-bottom: 12px; font-size: .9rem; border: 1px solid transparent;
}
.alert-success { background: var(--ok-tint); color: var(--ok); border-color: #bfe3ce; }
.alert-error   { background: var(--danger-tint); color: var(--danger); border-color: #f0c5c5; }
.alert-warning { background: var(--warn-tint); color: var(--warn); border-color: #f0dcb4; }
.alert-info    { background: var(--info-tint); color: var(--brand-dark); border-color: #c9e0f2; }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--line);
  /* Clears the iOS home indicator. */
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; min-height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none;
  color: var(--ink-soft); font-size: .68rem; font-weight: 600;
}
.bottom-nav a.active { color: var(--brand); }
.bottom-nav svg { width: 21px; height: 21px; }

.badge {
  position: absolute; transform: translate(12px, -10px);
  background: var(--danger); color: #fff;
  font-size: .62rem; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- Lists & tables ---------- */
.list-item {
  display: block; padding: 13px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.list-item:last-child { border-bottom: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { font-size: .75rem; text-transform: uppercase; color: var(--ink-soft); letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: .92rem; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; text-align: right; font-weight: 550; }

.auth-shell {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px 16px;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { display: block; margin: 0 auto 22px; height: 34px; }

/* QR scanner viewport */
#qr-reader { width: 100%; border-radius: var(--radius-sm); overflow: hidden; }
#qr-reader video { width: 100% !important; height: auto !important; display: block; }

.pagination { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 18px; }
.pagination a, .pagination span { padding: 8px 12px; border-radius: var(--radius-sm); font-size: .875rem; text-decoration: none; }
.pagination a { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.pagination .current { background: var(--brand); color: #fff; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
