/* Saga Test Store — sandbox webshop chrome.
   Deliberately plain: this is the merchant's site, and it must never leak
   styles into the checkout widget. Everything here is prefixed .ts- so a
   selector collision with .sagapay-* is impossible. */

:root {
  --ts-bg: #f6f6f4;
  --ts-surface: #ffffff;
  --ts-ink: #16161a;
  --ts-muted: #6b6b76;
  --ts-line: #e4e4e0;
  --ts-accent: #1a4d3a;
  --ts-accent-ink: #ffffff;
  --ts-radius: 14px;
  --ts-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  --ts-max: 1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ts-bg);
  color: var(--ts-ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Sandbox banner ---------- */

.ts-sandbox-bar {
  background: #7c2d12;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 7px 16px;
  letter-spacing: 0.01em;
}

.ts-sandbox-bar code {
  background: rgba(255, 255, 255, 0.16);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---------- Header ---------- */

.ts-header {
  background: var(--ts-surface);
  border-bottom: 1px solid var(--ts-line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.ts-header-inner {
  max-width: var(--ts-max);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ts-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.ts-logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--ts-accent);
  color: var(--ts-accent-ink);
  display: grid;
  place-items: center;
  font-size: 15px;
  flex: 0 0 auto;
}

.ts-cart-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ts-ink);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}

.ts-cart-btn:hover { opacity: 0.85; }
.ts-cart-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

.ts-cart-count {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  min-width: 20px;
  padding: 0 6px;
  font-size: 12px;
  text-align: center;
  line-height: 20px;
}

/* ---------- Layout ---------- */

.ts-main {
  max-width: var(--ts-max);
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.ts-hero { margin-bottom: 32px; }

.ts-hero h1 {
  font-size: clamp(26px, 5vw, 38px);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.ts-hero p {
  color: var(--ts-muted);
  margin: 0;
  max-width: 58ch;
}

/* ---------- Product grid ---------- */

.ts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.ts-card {
  background: var(--ts-surface);
  border: 1px solid var(--ts-line);
  border-radius: var(--ts-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ts-card-img {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  font-size: 52px;
  background: linear-gradient(140deg, #eceae4, #dcdad2);
}

.ts-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.ts-card-name { font-weight: 600; font-size: 15px; }
.ts-card-desc { color: var(--ts-muted); font-size: 13px; flex: 1; }

.ts-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.ts-price { font-weight: 700; font-size: 16px; white-space: nowrap; }

.ts-add {
  border: 1px solid var(--ts-line);
  background: #fff;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ts-add:hover { background: var(--ts-bg); border-color: #cfcfc8; }
.ts-add.is-added { background: var(--ts-accent); border-color: var(--ts-accent); color: #fff; }

/* ---------- Cart drawer ---------- */

.ts-drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 90;
}

.ts-drawer-scrim.is-open { opacity: 1; pointer-events: auto; }

.ts-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 100%);
  background: var(--ts-surface);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.24s ease;
  display: flex;
  flex-direction: column;
}

.ts-drawer.is-open { transform: translateX(0); }

.ts-drawer-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--ts-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ts-drawer-head h2 { margin: 0; font-size: 17px; }

.ts-icon-btn {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--ts-muted);
  padding: 4px 8px;
  font-family: inherit;
}

.ts-drawer-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px;
  -webkit-overflow-scrolling: touch;
}

.ts-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--ts-line);
}

.ts-line:last-child { border-bottom: 0; }

.ts-line-img {
  width: 46px;
  height: 46px;
  border-radius: 9px;
  background: linear-gradient(140deg, #eceae4, #dcdad2);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex: 0 0 auto;
}

.ts-line-info { flex: 1; min-width: 0; }
.ts-line-name { font-size: 14px; font-weight: 600; }
.ts-line-sub { font-size: 12px; color: var(--ts-muted); }

.ts-qty { display: flex; align-items: center; gap: 6px; }

.ts-qty button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--ts-line);
  background: #fff;
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  font-family: inherit;
}

.ts-empty { color: var(--ts-muted); font-size: 14px; padding: 40px 0; text-align: center; }

.ts-drawer-foot { padding: 18px 20px; border-top: 1px solid var(--ts-line); }

.ts-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 6px;
}

.ts-total-note { color: var(--ts-muted); font-size: 12px; margin-bottom: 14px; }

.ts-checkout-btn {
  display: block;
  width: 100%;
  background: var(--ts-accent);
  color: var(--ts-accent-ink);
  border: 0;
  border-radius: 11px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.ts-checkout-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ---------- Checkout page ---------- */

.ts-checkout-layout {
  max-width: var(--ts-max);
  margin: 0 auto;
  padding: 28px 20px 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  .ts-checkout-layout { grid-template-columns: 1fr; }
  /* Summary above checkout on mobile, matching real shop behaviour */
  .ts-aside { order: -1; }
}

.ts-panel {
  background: var(--ts-surface);
  border: 1px solid var(--ts-line);
  border-radius: var(--ts-radius);
  padding: 18px 20px;
}

.ts-panel + .ts-panel { margin-top: 16px; }

.ts-panel h2 { margin: 0 0 12px; font-size: 15px; }

/* The widget mounts here. No padding/background — the widget owns its own
   surface, and wrapping it in shop chrome is what makes embeds look wrong. */
#saga-checkout { min-height: 420px; }

.ts-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 11px;
  font-size: 14px;
  background: #fff;
  border: 1px solid var(--ts-line);
}

.ts-status.is-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.ts-status.is-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

.ts-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--ts-line);
  border-top-color: var(--ts-accent);
  border-radius: 50%;
  animation: ts-spin 0.7s linear infinite;
  flex: 0 0 auto;
}

@keyframes ts-spin { to { transform: rotate(360deg); } }

/* ---------- Debug console ---------- */

.ts-debug {
  position: fixed;
  right: 0;
  bottom: 0;
  width: min(460px, 100%);
  max-height: 60vh;
  background: #14141a;
  color: #d6d6e0;
  z-index: 80;
  border-radius: 12px 0 0 0;
  display: flex;
  flex-direction: column;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.3);
  transform: translateY(calc(100% - 38px));
  transition: transform 0.2s ease;
}

.ts-debug.is-open { transform: translateY(0); }

.ts-debug-head {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  flex: 0 0 auto;
  user-select: none;
}

.ts-debug-head strong { font-weight: 600; font-size: 12px; }
.ts-debug-head span { color: #7a7a8c; }

.ts-debug-log {
  overflow-y: auto;
  padding: 0 14px 14px;
  -webkit-overflow-scrolling: touch;
}

.ts-log-row {
  padding: 6px 0;
  border-top: 1px solid #24242e;
  display: flex;
  gap: 8px;
  align-items: baseline;
  word-break: break-word;
}

.ts-log-t { color: #55556a; flex: 0 0 auto; }
.ts-log-tag { flex: 0 0 auto; font-weight: 600; }
.ts-log-tag.evt { color: #6ee7b7; }
.ts-log-tag.err { color: #fca5a5; }
.ts-log-tag.net { color: #93c5fd; }
.ts-log-tag.inf { color: #c4b5fd; }
.ts-log-msg { flex: 1; min-width: 0; white-space: pre-wrap; }

/* ---------- Config form ---------- */

.ts-field { margin-bottom: 12px; }

.ts-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ts-muted);
  margin-bottom: 4px;
}

.ts-field input,
.ts-field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--ts-line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: inherit;
}

.ts-hint { font-size: 12px; color: var(--ts-muted); margin: 6px 0 0; }

.ts-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ts-row > * { flex: 1; min-width: 140px; }

.ts-btn-sm {
  border: 1px solid var(--ts-line);
  background: #fff;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.ts-btn-sm:hover { background: var(--ts-bg); }

.ts-summary-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 14px;
}

.ts-summary-line.is-total {
  border-top: 1px solid var(--ts-line);
  margin-top: 6px;
  padding-top: 12px;
  font-weight: 700;
  font-size: 16px;
}

.ts-summary-line span:first-child { color: var(--ts-muted); }
.ts-summary-line.is-total span:first-child { color: inherit; }
