/* Thurn — Design System */
:root {
  --teal: #0d6e6e;
  --teal-dark: #094d4d;
  --teal-light: #e0f2f1;
  --gold: #c8a951;
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border: #e5e7eb;
  --border-focus: #0d6e6e;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --red: #dc2626;
  --green: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 8px;
}

/* Dark mode — applied via .dark class on <html> (set by JS) */
html.dark {
  --teal: #2dd4bf;
  --teal-dark: #14b8a6;
  --teal-light: rgba(45, 212, 191, 0.1);
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --border-focus: #2dd4bf;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}
/* Auto dark mode when no manual preference is stored */
@media (prefers-color-scheme: dark) {
  html:not(.light) {
    --teal: #2dd4bf;
    --teal-dark: #14b8a6;
    --teal-light: rgba(45, 212, 191, 0.1);
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --border: #334155;
    --border-focus: #2dd4bf;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.125rem;
}
.logo img { width: 32px; height: 32px; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.lang-switcher { display: flex; gap: 2px; }
.lang-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.lang-btn.active, .lang-btn:hover {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}

/* Main layout */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  gap: 0;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}
.pay-col {
  padding: 0 1.25rem 1.25rem;
  grid-column: 1; /* under form column on desktop */
}
.form-col {
  padding: 1.25rem;
  overflow-y: auto;
  max-height: calc(100vh - 50px);
}
.preview-col {
  border-left: 1px solid var(--border);
  background: var(--bg);
  padding: 1.25rem;
  max-height: calc(100vh - 50px);
  overflow-y: auto;
}
.preview-sticky {
  position: sticky;
  top: 0;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}
.card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Form */
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.1);
}
html.dark input:focus, html.dark select:focus, html.dark textarea:focus {
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}
@media (prefers-color-scheme: dark) {
  html:not(.light) input:focus, html:not(.light) select:focus, html:not(.light) textarea:focus {
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
  }
}
textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.5;
}
.form-group { margin-bottom: 0.75rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-meta { font-size: 0.75rem; color: var(--text-light); margin-top: 0.25rem; display: block; }

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
}
.toggle-row input[type="checkbox"] { width: auto; }

/* Options */
.options-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.option-group { display: flex; gap: 3px; }
.option-btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.option-btn.active {
  background: var(--teal-light);
  color: var(--teal);
  border-color: var(--teal);
}
.option-btn:hover { border-color: var(--teal); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn--primary { background: var(--teal); color: white; }
.btn--primary:hover { opacity: 0.9; }
.btn--full { width: 100%; }
.btn--large { padding: 0.875rem 1.5rem; font-size: 1.05rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Price box */
.pay-card { text-align: center; }
.price-box { margin-bottom: 0.75rem; }
.price-amount {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--teal);
}
.price-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Preview */
.preview-container { position: relative; }
.preview-frame {
  width: 100%;
  aspect-ratio: 210 / 297;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}
.preview-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  padding: 2rem;
  pointer-events: none;
}

/* Address autocomplete */
.address-ac-wrap { position: relative; }
.ac-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}
html.dark .ac-dropdown { box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
@media (prefers-color-scheme: dark) {
  html:not(.light) .ac-dropdown { box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
}
.ac-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: var(--teal-light); }
.link-small {
  font-size: 0.75rem;
  color: var(--teal);
  text-decoration: none;
  margin-top: 0.25rem;
  display: inline-block;
}
.link-small:hover { text-decoration: underline; }

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}
.alert--success { background: #d1fae5; color: #065f46; }
.alert--error { background: #fee2e2; color: #991b1b; }
html.dark .alert--success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
html.dark .alert--error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
@media (prefers-color-scheme: dark) {
  html:not(.light) .alert--success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
  html:not(.light) .alert--error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge--pending { background: #fef3c7; color: #92400e; }
.badge--paid { background: #dbeafe; color: #1e40af; }
.badge--shipped { background: #d1fae5; color: #065f46; }
.badge--failed { background: #fee2e2; color: #991b1b; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-card);
}
.footer a {
  color: var(--text-muted);
  text-decoration: none;
  margin: 0 0.5rem;
}
.footer a:hover { color: var(--teal); }

/* Responsive: stack on narrow screens */
@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }
  .form-col {
    max-height: none;
    overflow-y: visible;
  }
  .preview-col {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
    overflow-y: visible;
  }
  .preview-frame {
    max-height: 60vh;
    aspect-ratio: auto;
    height: 500px;
  }
  .pay-col {
    padding: 0 1.25rem 1.25rem;
  }
}

@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  .options-row { flex-direction: column; align-items: flex-start; }
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  transition: all 0.15s;
}
.theme-toggle:hover { border-color: var(--teal); color: var(--teal); }
/* Show moon in light mode, sun in dark mode */
.theme-icon-dark { display: none; }
html.dark .theme-icon-light { display: none; }
html.dark .theme-icon-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  html:not(.light) .theme-icon-light { display: none; }
  html:not(.light) .theme-icon-dark { display: inline; }
}

/* Track page container (used on track.html) */
.container { max-width: 680px; margin: 0 auto; padding: 0 1.5rem; }
.container-padded { padding-top: 2rem; padding-bottom: 4rem; }
