/* ===== Design Tokens ===== */
:root {
  --bg: #f8f5f2;          /* light tan background */
  --panel: #ffffff;       /* white panels */
  --accent: #6c63ff;      /* futuristic purple */
  --accent-alt: #00c7b7;  /* teal highlight */
  --text: #2a2a2a;        /* soft black text */
  --muted: #7a7a7a;       /* secondary text */
  --border: #e0ddd9;      /* soft neutral border */
  --shadow: rgba(0, 0, 0, 0.08);
  --ok: #00c7b7;
  --warn: #f5a623;
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "IBM Plex Sans Thai", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.center {
  display: block;
  text-align: center;
}

.inline {
  display: inline-block;
}

.hidden {
  display: none;
}

/* ===== Layout / Containers ===== */
.container {
  max-width: 860px;
  margin: 40px auto;
  padding: 32px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 10px 30px var(--shadow);
  border: 1px solid var(--border);
}

.row {
  display: flex;
  gap: 16px;
}

.row > * {
  flex: 1;
}

/* Responsive layout */
@media (max-width: 720px) {
  .row {
    flex-wrap: wrap;
  }
  .row > * {
    flex: 1 1 100%;
  }
}

/* ===== Typography ===== */
h1 {
  font-size: 30px;
  letter-spacing: 0.3px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 1rem;
}

h2 {
  font-size: 28px;
  letter-spacing: 0.3px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 1rem;
}

label {
  display: block;
  margin: 16px 0 8px;
  color: var(--muted);
  font-weight: 500;
}

.help {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}

.normal {
  color: var(--text);
  font-size: 16px;
  margin: 4px 0 0;
}

/* ===== Inputs ===== */
input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fafafa;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  outline: none;
}

textarea {
  min-height: 220px;
  resize: vertical;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.25);
  background: var(--panel);
}

/* ===== Buttons ===== */
button.primary {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  color: var(--panel);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
  width: auto;
  min-width: 180px;
  text-align: center;
}

button.primary:hover {
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

button.primary:active {
  transform: translateY(1px);
}

button.primary:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

#backToTop {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  z-index: 999;
}

/* Shared action row (forms + results) */
.row.actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
}

.row.actions > * {
  flex: 0 0 auto;
}

/* Language switch button */
.lang-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 120px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: #e5e7eb;
  padding: 0 8px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  outline: none;
  appearance: none;
  font: inherit;
  color: inherit;
  direction: ltr;
  unicode-bidi: isolate;
}

.lang-switch:focus-visible {
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.4);
}

.lang-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 1;
  color: var(--muted);
  -webkit-user-select: none; /* Safari / iOS */
  user-select: none;
  direction: ltr;
  unicode-bidi: isolate;
}

.lang-knob {
  position: absolute;
  width: 32px;
  height: 26px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  left: 44px; /* EN position (center) */
  transition: left 0.18s ease;
}

/* Active state: EN */
.lang-switch.lang-en .lang-label[data-lang-value="en"] {
  color: var(--accent);
  font-weight: 600;
}

/* Active state: TH */
.lang-switch.lang-th .lang-label[data-lang-value="th"] {
  color: var(--accent);
  font-weight: 600;
}

/* Active state: AR */
.lang-switch.lang-ar .lang-label[data-lang-value="ar"] {
  color: var(--accent);
  font-weight: 600;
}

/* Move knob for TH (right position) */
.lang-switch.lang-th .lang-knob {
  left: 86px;
}

/* Move knob for AR (left position) */
.lang-switch.lang-ar .lang-knob {
  left: 2px;
}

/* ===== FAQ Section ===== */
/* separator between FAQ title and first question */
#faq h2 + .faq-item {
  border-top: 1px solid var(--border);
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

/* turn the question into a flex container */
.faq-question {
  width: 100%;
  padding: 12px 0;
  text-align: left;
  font-size: 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;

  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* the + icon */
.faq-question::after {
  content: "+";
  font-size: 32px;
  font-weight: 200;
  color: var(--border);
  transition: transform 0.2s ease;
}

/* rotate + when active */
.faq-question.active::after {
  transform: rotate(45deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.faq-answer p {
  margin: 8px 0;
}

/* ===== Cards / Separators / Badges ===== */
.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 0 2px 6px var(--shadow);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--panel);
  font-weight: 500;
}

/* ===== Youtube placeholder ===== */
.yt-lite {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;          /* centers horizontally */
  padding-top: 56.25%;     /* 16:9 ratio */
  background-size: cover;
  background-position: center;
  cursor: pointer;
  border-radius: 12px;     /* optional, looks cleaner */
  overflow: hidden;        /* ensures rounded corners work */
}

/* dark overlay */
.yt-lite::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
}

/* play icon */
.yt-lite::after {
  content: "▶";
  position: absolute;
  color: white;
  font-size: 64px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

/* iframe styling */
.yt-lite iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Hide the play icon after clicking */
.yt-lite.playing::after {
  opacity: 0;
}
.yt-lite.playing::before {
  opacity: 0;
}

/* ===== Links ===== */
a,
a:visited {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover,
a:focus {
  color: var(--accent-alt);
  text-decoration: underline;
}

/* ===== Payment block (inline Stripe UI) ===== */
#pay-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 1.5rem;
}

#pay-inline.hidden {
  display: none;
}

#pay-inline h3 {
  margin-top: 0.5rem;
  color: var(--accent);
}

#pay-inline .help {
  margin-bottom: 1rem;
}

/* ===== Spinner ===== */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(108, 99, 255, 0.3);
  border-top-color: var(--accent-alt);
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Results page ===== */
.mono {
  white-space: pre-wrap;
  font-family: "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
  background: var(--bg);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
}

/* ===== Markdown rendering tweaks ===== */
.markdown p {
  margin: 6px 0;
}

.markdown ul,
.markdown ol {
  margin: 8px 0 8px 20px;
  padding: 0;
}

.markdown li {
  margin: 4px 0;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin: 12px 0 6px;
}

.markdown table {
  margin: 12px 0;
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
}

.markdown table th,
.markdown table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  vertical-align: top;
}

.markdown table thead th {
  background: #f9fafb;
  font-weight: 600;
}

/* ===== RTL (Arabic) adjustments for Markdown ===== */
html[dir="rtl"] .markdown {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .markdown table {
  direction: rtl;
}

html[dir="rtl"] .markdown table th,
html[dir="rtl"] .markdown table td {
  text-align: right;
}

html[dir="rtl"] .markdown ul,
html[dir="rtl"] .markdown ol {
  margin: 8px 20px 8px 0;
}

/* ===== RTL (Arabic) hard override for any tables on the page (Results safety net) ===== */
html[dir="rtl"] table {
  direction: rtl;
}

html[dir="rtl"] th,
html[dir="rtl"] td {
  text-align: right;
}

/* Keep code-like content readable inside RTL contexts */
html[dir="rtl"] code,
html[dir="rtl"] pre {
  direction: ltr;
  text-align: left;
}