/* Custom bits layered on top of Tailwind (CDN). Component classes are plain CSS
   so they work reliably regardless of Tailwind's JIT scanning. */

:root {
  --card-el-border: #d1d5db;
}

* { -webkit-tap-highlight-color: transparent; }

body {
  background: #f3f4f6;
  color: #111827;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Mode banner ─────────────────────────────────────────────── */
#mode-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 10px 12px;
  font-size: 0.95rem;
}
#mode-banner.live {
  background: #dc2626;
  color: #fff;
  animation: livePulse 1.8s ease-in-out infinite;
}
#mode-banner.test { background: #facc15; color: #713f12; }
#mode-banner.unknown { background: #6b7280; color: #fff; }
@keyframes livePulse {
  0%, 100% { background: #dc2626; }
  50% { background: #b91c1c; }
}
@media (prefers-reduced-motion: reduce) {
  #mode-banner.live { animation: none; }
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;               /* touch-friendly */
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.12s ease;
  user-select: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:not(:disabled):hover { background: #4338ca; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:not(:disabled):hover { background: #b91c1c; }
.btn-neutral { background: #e5e7eb; color: #111827; }
.btn-neutral:not(:disabled):hover { background: #d1d5db; }
.btn-ghost { background: transparent; color: #4f46e5; border-color: #c7d2fe; min-height: 38px; padding: 6px 12px; }
.btn-ghost:not(:disabled):hover { background: #eef2ff; }
.btn-sm { min-height: 34px; padding: 5px 10px; font-size: 0.8rem; border-radius: 8px; }

/* ── Inputs ──────────────────────────────────────────────────── */
.label { display: block; font-size: 0.8rem; font-weight: 600; color: #374151; margin-bottom: 4px; }
.input, .select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  font-size: 0.95rem;
  color: #111827;
}
.input:focus, .select:focus { outline: 2px solid #a5b4fc; outline-offset: 0; border-color: #6366f1; }
.field { margin-bottom: 12px; }

/* ── Cards / accordions ──────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 700;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary::after {
  content: "▸";
  margin-left: auto;
  transition: transform 0.15s ease;
  color: #9ca3af;
}
.card[open] > summary::after { transform: rotate(90deg); }
.card .card-body { padding: 0 18px 18px; }

/* Visually separate money-moving actions from read-only info. */
.danger-zone {
  border: 1px dashed #fca5a5;
  background: #fef2f2;
  border-radius: 12px;
  padding: 14px;
}
.readonly-zone {
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 12px;
  padding: 14px;
}
.section-note {
  font-size: 0.8rem;
  color: #6b7280;
  background: #f9fafb;
  border-left: 3px solid #d1d5db;
  padding: 8px 10px;
  border-radius: 6px;
  margin-top: 10px;
}
.subhead { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #6b7280; font-weight: 700; margin: 4px 0 8px; }

/* ── Stripe Elements card container ──────────────────────────── */
#card-element {
  padding: 12px;
  border: 1px solid var(--card-el-border);
  border-radius: 10px;
  background: #fff;
  min-height: 44px;
}
#card-element.StripeElement--focus { outline: 2px solid #a5b4fc; border-color: #6366f1; }
#card-element.StripeElement--invalid { border-color: #dc2626; }

/* ── Lists of Stripe objects ─────────────────────────────────── */
.obj-list { display: flex; flex-direction: column; gap: 8px; }
.obj-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  font-size: 0.9rem;
}
.obj-row.selected { border-color: #6366f1; background: #eef2ff; }
.obj-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; color: #4338ca; word-break: break-all; }
.pill { font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.pill-green { background: #dcfce7; color: #166534; }
.pill-yellow { background: #fef9c3; color: #854d0e; }
.pill-red { background: #fee2e2; color: #991b1b; }
.pill-gray { background: #f3f4f6; color: #374151; }
.muted { color: #6b7280; }
.grow { flex: 1 1 auto; min-width: 0; }

/* Active-customer indicator */
#active-customer-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #111827;
  color: #fff;
  font-size: 0.85rem;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Session Log ─────────────────────────────────────────────── */
#log-card { border-color: #cbd5e1; }
.log-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
#log-entries {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}
.log-entry {
  border: 1px solid #e5e7eb;
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  font-size: 0.82rem;
}
.log-entry.success { border-left-color: #16a34a; background: #f0fdf4; }
.log-entry.error   { border-left-color: #dc2626; background: #fef2f2; }
.log-entry.info    { border-left-color: #9ca3af; background: #f9fafb; }
.log-entry .log-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.log-entry .log-action { font-weight: 700; }
.log-entry .log-time { color: #6b7280; font-size: 0.72rem; }
.log-entry pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  color: #1f2937;
  margin: 4px 0 0;
}

/* ── Inline result / error banners ───────────────────────────── */
.result { margin-top: 10px; border-radius: 10px; padding: 10px 12px; font-size: 0.85rem; display: none; }
.result.show { display: block; }
.result.ok  { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.result.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.result .obj-id { color: inherit; }

/* ── Modal (confirmation dialog) ─────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}
#modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  padding: 22px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
.modal h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 8px; }
.modal .modal-body { font-size: 0.92rem; color: #374151; margin-bottom: 18px; }
.modal .modal-amount { font-size: 1.4rem; font-weight: 800; color: #111827; margin: 6px 0; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.btn-neutral .spinner, .btn-ghost .spinner { border: 2px solid rgba(0,0,0,0.25); border-top-color: #111827; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast (copy confirmation) ───────────────────────────────── */
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 640px) {
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}
