/* =========================================================================
   tools/wht/style.css — Earnest-inspired clean calculator UI (Green theme)
   ========================================================================= */

/* Override token: ทั้งหน้านี้ใช้สีเขียวแบบ Earnest */
body {
  --blue:        #22C485;   /* primary green */
  --blue-dark:   #1AAC73;   /* hover */
  --primary-bg:  #E8F8F1;
  --primary-mid: #C9F0DD;
  --primary-tint: rgba(34, 196, 133, 0.12);
  --primary-text: #15803D;
  --accent-light: #6FE3B0;
}

/* Container & header inner: กว้างสุด 1400px ไม่มี padding ข้าง */
body .container {
  max-width: 1400px;
  padding: 0;
}
body .site-header-inner {
  max-width: 1400px;
  padding: 0.85rem 1.5rem;
}

/* Back link (pill) — มี margin จากขอบ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin: 1.25rem 0 0 1.5rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-pill);
  transition: color 0.15s;
}
.back-link:hover { color: var(--blue); }

/* ============ Heading row — เต็มความกว้าง บน 2 columns ============ */
.calc-header {
  padding: 1.25rem 2rem 1.5rem;
  margin-top: 0.75rem;
}
.calc-header .page-title { margin-bottom: 0.5rem; }
.calc-header .page-subtitle { margin-bottom: 0; }

/* ============ Layout — 2 columns พื้นขาว ============ */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: stretch;
}
.calc-form {
  padding: 2rem 2rem 3rem;
  min-width: 0;
}
.calc-result {
  padding: 2rem 2rem 3rem;
  min-width: 0;
}

/* การ์ดขาว ครอบฟอร์ม / breakdown */
.form-card,
.result-card {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 1.75rem 1.85rem;
  box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 6px 18px rgba(15,23,42,0.04);
}

/* Mobile: stack แนวตั้ง */
@media (max-width: 768px) {
  .calc-header {
    padding: 0.75rem 1rem 1.25rem;
  }
  .calc-layout {
    grid-template-columns: 1fr;
  }
  .calc-form,
  .calc-result {
    padding: 1.25rem 1rem 1.5rem;
  }
  .calc-form { padding-bottom: 0.5rem; }
}
@media (max-width: 480px) {
  .form-card,
  .result-card {
    padding: 1.25rem 1.1rem;
    border-radius: 12px;
  }
}

/* ============ Form column ============ */
.page-title {
  font-size: clamp(1.6rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.6rem;
  color: var(--text);
}
.page-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* Field — clear label + underline input */
.field { margin-bottom: 2rem; }
.field-label {
  display: block;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.7rem;
  letter-spacing: -0.01em;
}

.field-input {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 0.45rem;
  transition: border-color 0.15s;
}
.field-input:focus-within { border-color: var(--blue); }
.field-input.field-input-error { border-bottom-color: #EF4444; }
.field-prefix {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1;
}
.field-input input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1.6rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  padding: 0;
  width: 100%;
  letter-spacing: -0.01em;
  -moz-appearance: textfield;
}
.field-input input::-webkit-outer-spin-button,
.field-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-input input::placeholder {
  color: #CBD5E1;
  font-weight: 400;
}

.error-msg {
  color: #DC2626;
  font-size: 0.85rem;
  margin-top: 0.55rem;
  font-weight: 500;
  display: none;
}
.error-msg.show { display: block; }

/* Select — also underline, custom arrow */
.field-select {
  position: relative;
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 0.45rem;
  transition: border-color 0.15s;
}
.field-select:focus-within { border-color: var(--blue); }
.field-select::after {
  content: "▾";
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-65%);
  pointer-events: none;
  color: var(--muted);
  font-size: 0.95rem;
}
.field-select select {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1.05rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  padding: 0 1.75rem 0 0;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

/* Segmented control */
.seg-control {
  display: flex;
  background: #F1F5F9;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.seg-control input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg-control label {
  flex: 1;
  text-align: center;
  padding: 0.7rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  user-select: none;
  margin: 0;
}
.seg-control label:hover { color: var(--text-soft); }
.seg-control input:checked + label {
  background: #fff;
  color: var(--blue);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15,23,42,0.08);
}

/* Primary button */
.btn {
  display: block;
  width: 100%;
  padding: 1rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 1.5rem;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(34,196,133,0.30);
}
.btn:hover {
  background: var(--blue-dark);
  box-shadow: 0 6px 20px rgba(34,196,133,0.38);
}

/* ============ Result column ============ */
.result-empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--muted);
}
.result-empty .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.55;
}
.result-empty p { font-size: 0.95rem; }

.result-content { animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Summary cards (2 stat cards เหนือ breakdown — ลอยนอก result-card) */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
@media (max-width: 540px) {
  .summary-cards { grid-template-columns: 1fr; }
}
.summary-card {
  padding: 1.25rem 1.4rem;
  border-radius: 14px;
  border: 1px solid;
}
.summary-card-pay {
  background: linear-gradient(140deg, #E8F8F1 0%, #C9F0DD 100%);
  border-color: var(--accent-light);
}
.summary-card-wht {
  background: linear-gradient(140deg, #FEF2F2 0%, #FEE2E2 100%);
  border-color: #FECACA;
}
.summary-card-label {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 0.45rem;
  letter-spacing: -0.005em;
}
.summary-card-value {
  font-size: clamp(1.7rem, 4.5vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 0.35rem;
}
.summary-card-pay .summary-card-value { color: #15803D; }
.summary-card-wht .summary-card-value { color: #B91C1C; }
.summary-card-note {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.summary-card-pay .summary-card-note { color: #15803D; opacity: 0.75; }
.summary-card-wht .summary-card-note { color: #B91C1C; opacity: 0.75; }

/* === Breakdown (receipt-style) — อยู่ใน .result-card แล้ว ไม่ต้องมี border บน === */
.breakdown {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.break-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}
.break-row + .break-row { border-top: 1px dashed #E2E8F0; }
.break-label {
  color: var(--text-soft);
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.break-formula {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}
.break-value {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  text-align: right;
}
.break-add    { color: var(--text-soft); font-weight: 500; }
.break-deduct { color: #DC2626; }

.break-row-subtotal {
  background: #F8FAFC;
  margin: 0.25rem -0.5rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  border-radius: 8px;
  border-top: none !important;
}
.break-row-subtotal + .break-row { border-top: none; }
.break-row-subtotal .break-label { font-weight: 500; color: var(--text); }

.break-row-final {
  margin-top: 0.5rem;
  padding-top: 1.1rem !important;
  border-top: 2px solid var(--text) !important;
}
.break-row-final .break-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.break-final {
  font-size: 1.2rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.rate-badge {
  background: var(--primary-tint);
  color: var(--blue);
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

/* === CTA — สร้างใบ 50 ทวิ === */
.cta-cert {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-top: 1.5rem;
  padding: 1.25rem 1.4rem;
  background: linear-gradient(135deg, #E8F8F1 0%, #C9F0DD 100%);
  border: 1.5px solid var(--accent-light);
  border-radius: 16px;
  text-decoration: none;
  color: var(--primary-text);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.cta-cert:hover {
  transform: translateY(-2px);
  border-color: var(--blue);
  box-shadow: 0 10px 28px rgba(34, 196, 133, 0.20);
}
.cta-cert::before {
  /* decorative glow */
  content: "";
  position: absolute;
  top: -50%;
  right: -10%;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,0.5) 0%, transparent 65%);
  pointer-events: none;
}

.cta-cert-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #fff;
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(34, 196, 133, 0.25);
  position: relative;
  z-index: 1;
}
.cta-cert-icon svg { stroke: currentColor; }

.cta-cert-body {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.cta-cert-tag {
  display: inline-block;
  background: var(--blue);
  color: #fff;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}
.cta-cert-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}
.cta-cert-subtitle {
  font-size: 0.85rem;
  color: var(--text-soft);
  line-height: 1.55;
}

.cta-cert-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--blue);
  color: #fff;
  padding: 0.78rem 1.25rem;
  border-radius: 11px;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(34, 196, 133, 0.32);
  transition: background 0.15s, box-shadow 0.15s;
  position: relative;
  z-index: 1;
}
.cta-cert:hover .cta-cert-btn {
  background: var(--blue-dark);
  box-shadow: 0 6px 18px rgba(34, 196, 133, 0.42);
}
.cta-cert-btn svg {
  stroke: currentColor;
  transition: transform 0.18s;
}
.cta-cert:hover .cta-cert-btn svg { transform: translateX(2px); }

/* Mobile */
@media (max-width: 540px) {
  .cta-cert {
    flex-direction: column;
    text-align: center;
    align-items: stretch;
    padding: 1.4rem 1.1rem;
  }
  .cta-cert-icon { margin: 0 auto; }
  .cta-cert-tag,
  .cta-cert-btn { align-self: center; justify-content: center; }
  .cta-cert-btn { width: 100%; }
}

/* print-only ตัวเลือก default — ซ่อน */
.print-only { display: none; }

/* === Summary callout (green) === */
.summary-callout {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-top: 1.5rem;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(180deg, var(--primary-bg) 0%, var(--primary-mid) 100%);
  border: 1px solid var(--accent-light);
  border-radius: 14px;
}
.summary-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1.4;
}
.summary-text {
  color: var(--primary-text);
  font-size: 0.95rem;
  line-height: 1.7;
  margin: 0;
}
.summary-text strong {
  font-weight: 700;
  color: var(--primary-text);
  white-space: nowrap;
}

/* ============ Info + FAQ — minimal flat, 2 columns ============ */
/* ขยายให้เท่าขอบของ calc-form / calc-result (padding 2rem ด้านนอก) */
.info-grid {
  max-width: 1400px;
  margin: 4rem auto 5rem;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}
@media (max-width: 768px) {
  .info-grid {
    grid-template-columns: 1fr;
    gap: 3rem;
    padding: 0 1rem;
    margin: 3rem auto 4rem;
  }
}

.info-accordion { margin: 0; padding: 0; max-width: none; }

.info-accordion-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0 0 0.5rem;
  padding: 0;
}

/* Accordion item — flat bottom-border style */
.info-acc {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
  margin: 0;
  padding: 0;
  box-shadow: none;
}
.info-acc:first-of-type {
  border-top: 1px solid var(--border-soft);
}

/* FAQ in single column inside its grid cell */
.info-accordion-faq .faq-grid {
  display: block;  /* override any inherited grid */
}

/* Summary */
.info-acc summary {
  padding: 1.25rem 0.25rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  letter-spacing: -0.005em;
  user-select: none;
  transition: color 0.15s;
}
.info-acc summary::-webkit-details-marker { display: none; }
.info-acc summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  margin-bottom: 4px;
  transition: transform 0.25s, border-color 0.15s;
  flex-shrink: 0;
  opacity: 0.7;
}
.info-acc[open] summary::after {
  transform: rotate(225deg);
  margin-bottom: -4px;
  border-color: var(--blue);
  opacity: 1;
}
.info-acc summary:hover { color: var(--text); }
.info-acc summary:hover::after { border-color: var(--text-soft); opacity: 1; }
.info-acc[open] summary { font-weight: 500; color: var(--text); }

/* Body */
.info-acc-body {
  padding: 0 0.25rem 1.4rem;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.85;
}
.info-acc-body p { margin-bottom: 0.8rem; }
.info-acc-body p:last-child { margin-bottom: 0; }
.info-acc-body strong { color: var(--text); font-weight: 600; }
.info-acc-body em { color: var(--text); font-style: normal; font-weight: 500; }

/* Rate list inside accordion */
.rate-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr;
}
.rate-list li {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  background: #F8FAFC;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-soft);
}
.rate-pct {
  flex-shrink: 0;
  min-width: 2.75rem;
  text-align: center;
  background: var(--primary-tint);
  color: var(--blue);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Formula box */
.formula {
  background: #F8FAFC;
  border-radius: 10px;
  padding: 0.95rem 1.15rem;
}
.formula-row {
  padding: 0.45rem 0;
  font-size: 0.9rem;
  color: var(--text-soft);
  line-height: 1.7;
}
.formula-row + .formula-row { border-top: 1px dashed var(--border); }


/* ============ Responsive tweaks ============ */
@media (max-width: 880px) {
  body .container    { padding: 1rem 1rem 3rem; }
  .calc-layout       { gap: 2rem; }
  .field-input input { font-size: 1.4rem; }
  .field-prefix      { font-size: 1.3rem; }
}
@media (max-width: 480px) {
  .seg-control label { padding: 0.6rem 0.35rem; font-size: 0.8rem; }
  .field             { margin-bottom: 1.5rem; }
  .info-grid         { padding: 0 1rem; }
  .info-acc summary  { padding: 1.1rem 0.25rem; font-size: 0.95rem; }
  .result-actions    { justify-content: stretch; }
  .action-btn        { width: 100%; justify-content: center; }
}

/* ============ Print stylesheet ============ */
@media print {
  @page {
    size: A4;
    margin: 1.5cm;
  }

  body, html {
    background: #fff !important;
    color: #000 !important;
    font-size: 10.5pt;
  }

  /* ซ่อนสิ่งที่ไม่จำเป็นในเอกสารพิมพ์ */
  .site-header,
  .site-footer,
  .back-link,
  .calc-form,
  .info-grid,
  .no-print,
  .result-empty {
    display: none !important;
  }

  /* Reset layout เพื่อให้ใบสรุปเต็มหน้ากระดาษ */
  body .container,
  body.home .container { max-width: 100% !important; padding: 0 !important; }

  .calc-layout {
    display: block !important;
    grid-template-columns: 1fr !important;
    background: #fff !important;
    margin: 0 !important;
  }

  .calc-result {
    padding: 0 !important;
    background: none !important;
    border: none !important;
  }
  .result-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: #fff !important;
  }

  /* แสดงหัว/ท้ายเอกสารเฉพาะตอนพิมพ์ */
  .print-only { display: block !important; }
  .print-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 2px solid #000;
  }
  .print-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: #000;
  }
  .print-meta {
    font-size: 0.85rem;
    color: #555;
  }
  .print-meta-sep { margin: 0 0.4rem; opacity: 0.6; }
  .print-footer {
    margin-top: 1.5rem;
    padding-top: 0.85rem;
    border-top: 1px solid #ccc;
    font-size: 0.8rem;
    color: #666;
    text-align: center;
  }

  /* บังคับสีพื้นหลังให้ออกตอนพิมพ์ (สำคัญสำหรับ Chrome) */
  .summary-card,
  .summary-callout,
  .break-row-subtotal,
  .formula,
  .rate-list li {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .summary-cards { page-break-inside: avoid; }
  .breakdown { page-break-inside: avoid; }

  /* ลด animation/transition */
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
