/* ThaiLawOnline — Living Will Generator
 * Embeddable prototype styles
 * Scoped under .tlo-lw to avoid clashing with WordPress theme styles
 */

/* Thai-capable font stack: Sarabun (Google Fonts, loaded in index.html)
   → Noto Sans Thai (ships with most modern browsers/OS)
   → Inter (Latin) → Helvetica fallback.
   This is what every preview and the print-to-PDF sample PDF use. */

.tlo-lw {
  --tlo-primary: #1e3a8a;       /* deep navy — matches typical legal site */
  --tlo-primary-dark: #152b65;
  --tlo-accent: #c9a449;         /* gold — premium feel */
  --tlo-accent-dark: #a4842a;
  --tlo-bg: #fafaf7;
  --tlo-paper: #ffffff;
  --tlo-text: #1a1a1a;
  --tlo-muted: #6b6b6b;
  --tlo-border: #e5e7eb;
  --tlo-success: #166534;
  --tlo-warn: #b45309;
  --tlo-error: #991b1b;
  --tlo-radius: 6px;
  --tlo-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

  font-family: "Sarabun", "Noto Sans Thai", "Inter", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  color: var(--tlo-text);
  line-height: 1.55;
  background: var(--tlo-bg);
  padding: 24px 16px 64px;
  max-width: 980px;
  margin: 0 auto;
  font-size: 16px;
}

.tlo-lw * { box-sizing: border-box; }

.tlo-lw h1, .tlo-lw h2, .tlo-lw h3 { color: var(--tlo-primary); font-weight: 700; }
.tlo-lw h1 { font-size: 1.9rem; margin: 0 0 8px; }
.tlo-lw h2 { font-size: 1.35rem; margin: 28px 0 12px; }
.tlo-lw h3 { font-size: 1.05rem; margin: 18px 0 8px; }
.tlo-lw p  { margin: 0 0 12px; }
.tlo-lw small { color: var(--tlo-muted); }

/* Layout */
.tlo-lw .panel {
  background: var(--tlo-paper);
  border: 1px solid var(--tlo-border);
  border-radius: var(--tlo-radius);
  padding: 28px;
  box-shadow: var(--tlo-shadow);
  margin-bottom: 20px;
}

.tlo-lw .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 720px) {
  .tlo-lw .row { grid-template-columns: 1fr; }
  .tlo-lw .panel { padding: 18px; }
}

/* Wizard stepper */
.tlo-lw .stepper {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
  gap: 4px;
  flex-wrap: wrap;
}
.tlo-lw .stepper .step {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.78rem;
  padding: 8px 4px;
  border-bottom: 3px solid var(--tlo-border);
  color: var(--tlo-muted);
  white-space: nowrap;
  min-width: 80px;
}
.tlo-lw .stepper .step.active {
  border-bottom-color: var(--tlo-accent);
  color: var(--tlo-primary);
  font-weight: 600;
}
.tlo-lw .stepper .step.done {
  border-bottom-color: var(--tlo-primary);
  color: var(--tlo-primary);
}

/* Form fields */
.tlo-lw label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--tlo-text);
  margin: 12px 0 6px;
}
.tlo-lw label .req { color: var(--tlo-error); margin-left: 2px; }
.tlo-lw label .opt { color: var(--tlo-muted); font-weight: 400; font-style: italic; }

.tlo-lw input[type="text"],
.tlo-lw input[type="email"],
.tlo-lw input[type="tel"],
.tlo-lw input[type="date"],
.tlo-lw select,
.tlo-lw textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--tlo-border);
  border-radius: var(--tlo-radius);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--tlo-text);
}
.tlo-lw input:focus, .tlo-lw select:focus, .tlo-lw textarea:focus {
  outline: 2px solid var(--tlo-accent);
  outline-offset: 1px;
  border-color: var(--tlo-accent);
}
.tlo-lw textarea { min-height: 90px; resize: vertical; }

.tlo-lw .help {
  font-size: 0.82rem;
  color: var(--tlo-muted);
  margin-top: 4px;
}

.tlo-lw .field-with-suggest {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.tlo-lw .field-with-suggest input { flex: 1; }
.tlo-lw .suggest-btn {
  flex: 0 0 auto;
  padding: 0 12px;
  background: var(--tlo-primary);
  color: #fff;
  border: none;
  border-radius: var(--tlo-radius);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.tlo-lw .suggest-btn:hover { background: var(--tlo-primary-dark); }
.tlo-lw .suggest-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Checkboxes & radios */
.tlo-lw .check-group { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.tlo-lw .check-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px; border: 1px solid var(--tlo-border); border-radius: var(--tlo-radius);
  cursor: pointer; transition: background 0.15s;
}
.tlo-lw .check-row:hover { background: #f8f8f5; }
.tlo-lw .check-row input { margin-top: 3px; }
.tlo-lw .check-row .check-label { font-size: 0.95rem; }
.tlo-lw .check-row .check-label small { display: block; color: var(--tlo-muted); margin-top: 2px; }

/* Buttons */
.tlo-lw .btn {
  display: inline-block;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--tlo-radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, transform 0.05s;
}
.tlo-lw .btn:active { transform: translateY(1px); }
.tlo-lw .btn-primary { background: var(--tlo-primary); color: #fff; }
.tlo-lw .btn-primary:hover { background: var(--tlo-primary-dark); }
.tlo-lw .btn-accent { background: var(--tlo-accent); color: #fff; }
.tlo-lw .btn-accent:hover { background: var(--tlo-accent-dark); }
.tlo-lw .btn-ghost { background: transparent; color: var(--tlo-primary); border: 1px solid var(--tlo-border); }
.tlo-lw .btn-ghost:hover { background: #f5f5f0; }
.tlo-lw .nav-row { display: flex; justify-content: space-between; margin-top: 24px; gap: 12px; }

/* Disclaimer / warning boxes */
.tlo-lw .disclaimer {
  background: #fff8e6;
  border-left: 4px solid var(--tlo-accent);
  padding: 14px 16px;
  border-radius: 0 var(--tlo-radius) var(--tlo-radius) 0;
  margin: 16px 0;
  font-size: 0.93rem;
}
.tlo-lw .disclaimer strong { color: var(--tlo-accent-dark); }
.tlo-lw .info {
  background: #eff6ff;
  border-left: 4px solid var(--tlo-primary);
  padding: 14px 16px;
  border-radius: 0 var(--tlo-radius) var(--tlo-radius) 0;
  margin: 16px 0;
  font-size: 0.93rem;
}

/* Hero / welcome */
.tlo-lw .hero {
  background: linear-gradient(135deg, var(--tlo-primary) 0%, var(--tlo-primary-dark) 100%);
  color: #fff;
  padding: 36px 28px;
  border-radius: var(--tlo-radius);
  text-align: center;
  margin-bottom: 20px;
}
.tlo-lw .hero h1 { color: #fff; margin-bottom: 4px; font-size: 2rem; }
.tlo-lw .hero .hero-th { color: var(--tlo-accent); font-weight: 600; font-size: 1.1rem; margin-bottom: 18px; }
.tlo-lw .hero .price-tag {
  display: inline-block;
  background: var(--tlo-accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 12px 0;
}
.tlo-lw .hero .price-tag .strike { text-decoration: line-through; opacity: 0.55; margin-right: 6px; font-weight: 400; }
.tlo-lw .hero .hero-subtitle { font-size: 1rem; opacity: 0.92; max-width: 640px; margin: 0 auto; }

/* Feature grid on welcome */
.tlo-lw .features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.tlo-lw .feature {
  background: #fff;
  border: 1px solid var(--tlo-border);
  border-radius: var(--tlo-radius);
  padding: 14px 16px;
}
.tlo-lw .feature .icon { font-size: 1.4rem; margin-bottom: 6px; }
.tlo-lw .feature h3 { color: var(--tlo-primary); font-size: 0.95rem; margin: 0 0 4px; }
.tlo-lw .feature p { font-size: 0.85rem; color: var(--tlo-muted); margin: 0; }

/* Sample download CTA */
.tlo-lw .sample-cta {
  background: #f0f9ff;
  border: 1px dashed var(--tlo-primary);
  border-radius: var(--tlo-radius);
  padding: 16px 20px;
  margin: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.tlo-lw .sample-cta .sample-text strong { color: var(--tlo-primary); }
.tlo-lw .sample-cta .sample-text small { display: block; color: var(--tlo-muted); margin-top: 4px; }

/* Bilingual document preview */
.tlo-lw .doc-preview {
  background: #fff;
  border: 1px solid var(--tlo-border);
  border-radius: var(--tlo-radius);
  padding: 32px 36px;
  font-family: "Sarabun", "Noto Sans Thai", "Georgia", serif;
  font-size: 0.95rem;
  line-height: 1.6;
  max-height: 600px;
  overflow-y: auto;
  margin: 16px 0;
}
.tlo-lw .doc-preview .doc-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--tlo-text);
}
.tlo-lw .doc-preview .doc-title-th { text-align: center; font-size: 1.15rem; margin-bottom: 20px; color: var(--tlo-text); }
.tlo-lw .doc-preview .bilingual-block { margin-bottom: 14px; }
.tlo-lw .doc-preview .bilingual-block .en { margin-bottom: 4px; }
.tlo-lw .doc-preview .bilingual-block .th { color: #333; }
.tlo-lw .doc-preview .doc-section {
  text-align: center;
  font-weight: 700;
  margin: 22px 0 10px;
  padding: 8px 0;
  border-top: 1px solid var(--tlo-border);
  border-bottom: 1px solid var(--tlo-border);
}
.tlo-lw .doc-preview ul { margin: 8px 0 14px 24px; padding: 0; }
.tlo-lw .doc-preview li { margin-bottom: 4px; }
.tlo-lw .doc-preview .sig-line { border-top: 1px solid var(--tlo-text); margin: 32px 0 6px; padding-top: 6px; max-width: 340px; }
.tlo-lw .doc-preview .witness-block { margin-top: 28px; padding-top: 20px; border-top: 2px dashed var(--tlo-border); }

/* Payment & confirmation */
.tlo-lw .price-box {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #fafaf7 0%, #fff 100%);
  border: 1px solid var(--tlo-border);
  border-radius: var(--tlo-radius);
  padding: 18px 22px;
  margin: 16px 0;
}
.tlo-lw .price-box .price-amount { font-size: 1.6rem; font-weight: 700; color: var(--tlo-primary); }
.tlo-lw .price-box small { display: block; color: var(--tlo-muted); }

.tlo-lw #paypal-button-container { margin: 16px 0; max-width: 480px; }

.tlo-lw .success-icon {
  font-size: 4rem;
  text-align: center;
  margin: 8px 0;
}

/* Status messages */
.tlo-lw .field-error { color: var(--tlo-error); font-size: 0.82rem; margin-top: 4px; display: none; }
.tlo-lw input.invalid, .tlo-lw select.invalid, .tlo-lw textarea.invalid {
  border-color: var(--tlo-error);
  background: #fef2f2;
}

/* Spinner */
.tlo-lw .spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: tlo-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes tlo-spin { to { transform: rotate(360deg); } }

/* Print-only styles for sample / preview */
@media print {
  .tlo-lw .no-print { display: none !important; }
  .tlo-lw .doc-preview { max-height: none; overflow: visible; border: none; padding: 0; }
}

/* ---------------- Language toggle ---------------- */
.tlo-lw .lang-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  color: var(--tlo-muted);
}
.tlo-lw .lang-toggle .lang-label { margin-right: 4px; }
.tlo-lw .lang-toggle .lang-btn {
  border: 1px solid var(--tlo-border);
  background: #fff;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--tlo-muted);
  font-family: inherit;
  transition: all 0.15s;
}
.tlo-lw .lang-toggle .lang-btn:hover { background: #f5f5f0; color: var(--tlo-primary); }
.tlo-lw .lang-toggle .lang-btn.active {
  background: var(--tlo-primary);
  color: #fff;
  border-color: var(--tlo-primary);
  font-weight: 600;
}

/* ---------------- Watermarked, copy-protected preview ---------------- */
.tlo-lw .doc-preview-wrap {
  position: relative;
  margin: 16px 0;
}

/* Lock the entire preview against text selection, image-saving, drag, etc. */
.tlo-lw .doc-preview.no-copy {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;       /* iOS: no long-press copy menu */
  -webkit-user-drag: none;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}
.tlo-lw .doc-preview.no-copy * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Diagonal SAMPLE watermark, repeated across the preview */
.tlo-lw .doc-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  align-items: center;
  justify-items: center;
  transform: rotate(-22deg) scale(1.15);
  transform-origin: center center;
  opacity: 0.18;
}
.tlo-lw .doc-watermark span {
  display: block;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--tlo-error);
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  font-family: "Helvetica Neue", Arial, sans-serif;
}

/* Mask the partial pair — looks like classified ink */
.tlo-lw .doc-preview .bilingual-block.partial {
  position: relative;
  background: linear-gradient(90deg, transparent 0 30%, #f0eee2 30% 100%);
  border-radius: 3px;
  padding: 8px;
}
.tlo-lw .doc-preview .bilingual-block.partial::after {
  content: "🔒 Full text in your paid document";
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--tlo-error);
  background: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid #f3c3c3;
  pointer-events: none;
}

@media print {
  /* If someone tries to print the preview, the watermark stays */
  .tlo-lw .doc-watermark { opacity: 0.25; }
}
