/* =====================================================================
   kamnuanngern.com — shared design system
   ---------------------------------------------------------------------
   One stylesheet for every calculator page. Token-driven: change colors,
   spacing, radius in :root and every page updates at once.
   ===================================================================== */


/* Reset & base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #0f172a;
  background: #f8fafc;
}


/* Design tokens ----------------------------------------------------- */
:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-soft: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(15,23,42,0.06);
  --shadow-lg: 0 8px 24px rgba(15,23,42,0.08);
}


/* Type -------------------------------------------------------------- */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 700; line-height: 1.3; }
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; margin: 2rem 0 1rem; }
h3 { font-size: 1.125rem; margin: 1.25rem 0 0.5rem; }
p  { margin-bottom: 1rem; }
@media (min-width: 768px) { h1 { font-size: 2.25rem; } }


/* Layout ------------------------------------------------------------ */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }


/* Site header (sticky) --------------------------------------------- */
.site-header {
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
}
.logo:hover { text-decoration: none; }
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  font-size: 1rem;
}
.nav { display: flex; gap: 1.25rem; font-size: 0.95rem; }
.nav a { color: var(--text-muted); }
@media (max-width: 640px) { .nav a:not(.nav-cta) { display: none; } }


/* Ad slots ---------------------------------------------------------- */
.ad-slot {
  border: 2px dashed #cbd5e1;
  background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 10px, #f1f5f9 10px, #f1f5f9 20px);
  color: #94a3b8;
  text-align: center;
  padding: 1.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin: 1.5rem 0;
}
.ad-slot::before {
  content: "พื้นที่โฆษณา · AdSense";
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.ad-leaderboard { min-height: 90px; }
.ad-rectangle  { min-height: 250px; max-width: 336px; margin-left: auto; margin-right: auto; }
.ad-sidebar    { min-height: 600px; }


/* Page hero --------------------------------------------------------- */
.page-hero { text-align: center; padding: 1.5rem 0 0.5rem; }
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.breadcrumb a { color: var(--text-muted); }
.page-hero h1 { color: var(--text); margin-bottom: 0.5rem; }
.page-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0 auto 1rem;
}
.updated-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}


/* Two-column main grid --------------------------------------------- */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 1rem 0 2rem;
}
@media (min-width: 1024px) {
  .main-grid { grid-template-columns: 1fr 300px; gap: 2rem; }
}


/* Calculator card --------------------------------------------------- */
.calc-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  border: 1px solid var(--border);
}
@media (min-width: 768px) { .calc-card { padding: 2rem; } }
.calc-card h2 {
  margin-top: 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-row { margin-bottom: 1.25rem; }
.form-row label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-size: 0.95rem;
}
.form-row .hint { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }

.input-group { position: relative; display: flex; align-items: stretch; }
.input-group input {
  flex: 1;
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1.125rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.15);
}
.input-suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 1rem;
  background: var(--bg-soft);
  border: 2px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.input-group input:has(+ .input-suffix) {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.preset-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.preset {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.preset:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary-light);
}

.calc-button {
  width: 100%;
  padding: 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.125rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 0.5rem;
}
.calc-button:hover  { background: var(--primary-dark); }
.calc-button:active { transform: scale(0.99); }


/* Results ----------------------------------------------------------- */
.results { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.result-headline { text-align: center; margin-bottom: 1.25rem; }
.result-headline .label { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.result-headline .amount { font-size: 2.5rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.result-headline .amount-suffix { font-size: 1rem; color: var(--text-muted); font-weight: 500; }
@media (min-width: 768px) { .result-headline .amount { font-size: 3rem; } }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.25rem; }
.result-cell {
  background: var(--bg-subtle);
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  text-align: center;
}
.result-cell .label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.result-cell .value { font-size: 1.125rem; font-weight: 700; color: var(--text); }


/* Breakdown bar (data-viz) ----------------------------------------- */
.breakdown { margin-top: 1rem; }
.breakdown-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.breakdown-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}
.breakdown-principal { background: var(--primary); }
.breakdown-interest  { background: var(--accent); }
.breakdown-legend {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}


/* Long-form content ------------------------------------------------- */
.content {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) { .content { padding: 2rem; } }
.content p, .content li { color: var(--text); }
.content ul, .content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.content li { margin-bottom: 0.4rem; }
.content strong { color: var(--primary-dark); }

.callout {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 1.25rem 0;
}
.callout strong { color: var(--primary-dark); }

.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table th, table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
}
table td.num { text-align: right; font-variant-numeric: tabular-nums; }


/* FAQ accordion ----------------------------------------------------- */
details.faq {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  overflow: hidden;
}
details.faq[open] { box-shadow: var(--shadow); }
details.faq summary {
  list-style: none;
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after {
  content: "+";
  font-size: 1.5rem;
  color: var(--primary);
  transition: transform 0.2s;
  line-height: 1;
}
details.faq[open] summary::after { transform: rotate(45deg); }
details.faq .faq-body {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}


/* Sidebar ----------------------------------------------------------- */
.sidebar { display: flex; flex-direction: column; gap: 1.5rem; }
.related-calcs {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.related-calcs h3 { margin: 0 0 0.75rem; font-size: 1rem; color: var(--text); }
.related-calcs ul { list-style: none; padding: 0; }
.related-calcs li { margin-bottom: 0.6rem; }
.related-calcs a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background 0.15s;
  font-size: 0.95rem;
}
.related-calcs a:hover { background: var(--bg-soft); text-decoration: none; }
.related-calcs a .icon { color: var(--primary); }
.related-calcs a.coming-soon {
  color: var(--text-muted);
  cursor: not-allowed;
  pointer-events: none;
}
.related-calcs a.coming-soon::after {
  content: "เร็ว ๆ นี้";
  margin-left: auto;
  font-size: 0.75rem;
  background: var(--bg-soft);
  color: var(--text-muted);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}


/* Tile gallery (homepage) ------------------------------------------ */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 2rem 0;
}
@media (min-width: 640px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .tile-grid { grid-template-columns: repeat(3, 1fr); } }

.tile {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--text);
  transition: transform 0.2s, box-shadow 0.2s;
}
.tile:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.tile-icon { font-size: 2rem; display: block; margin-bottom: 0.6rem; }
.tile-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.3rem; }
.tile-desc  { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.tile-cta {
  display: inline-block;
  margin-top: 0.6rem;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
}
.tile-cta::after { content: " ›"; }
.tile.coming-soon {
  background: var(--bg-soft);
  cursor: default;
  pointer-events: none;
}
.tile.coming-soon .tile-cta {
  color: var(--text-muted);
}
.tile.coming-soon .tile-cta::after { content: ""; }
.tile.coming-soon::before {
  content: "เร็ว ๆ นี้";
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: #fef3c7;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.6rem;
}


/* Footer ------------------------------------------------------------ */
.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  padding: 2rem 0 1.5rem;
  margin-top: 3rem;
  font-size: 0.9rem;
}
.site-footer a { color: #cbd5e1; }
.footer-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) { .footer-cols { grid-template-columns: 2fr 1fr 1fr; } }
.footer-cols h4 { color: white; margin-bottom: 0.75rem; font-size: 0.95rem; }
.footer-cols ul { list-style: none; }
.footer-cols li { margin-bottom: 0.4rem; }

.footer-bottom {
  border-top: 1px solid #1e293b;
  padding-top: 1rem;
  color: #64748b;
  font-size: 0.85rem;
  text-align: center;
}
