@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;600;700;800;900&display=swap');

/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }

:root {
  /* Content (light) */
  --bg:      #f7f8fc;
  --card:    #ffffff;
  --border:  rgba(0,0,0,.07);
  --border2: rgba(0,0,0,.11);
  --text:    #1a202c;
  --muted:   #718096;
  --muted2:  #4a5568;
  --dimmed:  #a0aec0;
  /* Accent */
  --red:     #e53935;
  --red2:    #ff5252;
  --accent:  #e53935;
  --accent2: #ff5252;
  --success: #38a169;
  /* Aliases for backward compat */
  --surface:  #ffffff;
  --surface2: #f1f5f9;
}

html { scroll-behavior: smooth; font-size: 15px }

body {
  font-family: 'Sarabun', 'Noto Sans Thai', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  padding-top: 60px;
}

a { text-decoration: none; color: inherit }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px }

/* ─── Navbar (always dark — matches main site) ──────────────────────────────── */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(8,8,16,.92);
  backdrop-filter: blur(18px) saturate(1.5);
  border-bottom: 1px solid rgba(255,255,255,.07);
  height: 60px;
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px; gap: .75rem;
}
/* homepage uses .navbar-inner for max-width centering */
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 1100px; margin: 0 auto;
  padding: 0; gap: .75rem;
}

/* Logo */
.logo {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  font-size: 1.1rem; font-weight: 800; color: #fff; text-decoration: none;
}
.logo a { color: inherit; text-decoration: none; font-weight: 800 }
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1rem; color: #fff;
}
.logo-text { font-size: 1.1rem; font-weight: 800; color: #fff; letter-spacing: .3px }
.logo-dot  { color: var(--red) }

.th-flag {
  background: linear-gradient(90deg,
    #A51931 0%, #A51931 25%,
    #bbbbc8 25%, #bbbbc8 37.5%,
    #2E3192 37.5%, #2E3192 62.5%,
    #bbbbc8 62.5%, #bbbbc8 75%,
    #A51931 75%, #A51931 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 900;
}

/* Nav links */
.nav-links { display: flex; gap: 28px }
.nav-links a {
  color: rgba(255,255,255,.65); font-weight: 600; font-size: .88rem;
  transition: color .2s;
}
.nav-links a:hover { color: #fff }

/* User area */
#user-area {
  display: flex; align-items: center; gap: .65rem; flex-shrink: 0;
}
#user-info {
  display: none; align-items: center; gap: .65rem;
}
#user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.22); object-fit: cover;
}
#user-name { font-size: .88rem; font-weight: 700; color: #fff }
.nav-welcome-text { display: flex; flex-direction: column; line-height: 1.2 }
.nav-welcome-label { font-size: .68rem; color: rgba(255,255,255,.55); font-weight: 600 }
.nav-welcome-name  { font-size: .88rem; font-weight: 800; color: #fff }

#user-plan { display: none }
.plan-badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 900; text-transform: uppercase;
  background: rgba(229,57,53,.25); color: #fc8181;
}

/* Logout btn */
#logout-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .38rem .85rem; border-radius: 9px;
  border: 1.5px solid #9ca3af;
  background: transparent;
  color: #9ca3af;
  font-size: .8rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all .15s;
}
#logout-btn:hover { background: rgba(156,163,175,.15); border-color: #6b7280; color: #6b7280 }

/* Nav home link (tool pages) */
.nav-home-link {
  color: rgba(255,255,255,.5); font-size: .8rem; font-weight: 600;
  padding: .3rem .75rem; border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.nav-home-link:hover { color: #fff; border-color: rgba(255,255,255,.4) }

/* Login btn in dark navbar */
#login-btn.btn-primary {
  background: var(--red); color: #fff;
}

/* Hamburger */
.hamburger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.hamburger span {
  display: block; width: 22px; height: 2px; background: #fff;
  border-radius: 2px; transition: all .25s;
}
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px,5px) }
.hamburger.open span:nth-child(2) { opacity: 0 }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px) }

.mobile-nav {
  display: none; flex-direction: column; padding: 12px 24px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  background: rgba(8,8,16,.97);
  position: absolute; top: 60px; left: 0; right: 0;
}
.mobile-nav.open { display: flex }
.mobile-nav a {
  color: rgba(255,255,255,.8); padding: 10px 0; font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.07); font-size: .95rem;
}
.mobile-nav a:last-child { border-bottom: none }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 24px; border-radius: 11px; border: none; cursor: pointer;
  font-family: inherit; font-size: .95rem; font-weight: 900; text-decoration: none;
  transition: transform .15s, box-shadow .15s, background .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--red); color: #fff;
  box-shadow: 0 2px 16px rgba(229,57,53,.3);
}
.btn-primary:hover {
  background: var(--red2); transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(229,57,53,.45);
}
.btn-ghost {
  background: rgba(0,0,0,.04); color: var(--muted2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: rgba(0,0,0,.08); color: var(--text) }
.btn-success { background: var(--success); color: #fff; font-weight: 700 }
.btn-success:hover { background: #2f855a }
.btn-link { background: none; color: var(--accent2); border: none; padding: 0; cursor: pointer; font-weight: 600 }
.btn-xl  { padding: 14px 32px; font-size: 1.05rem; border-radius: 13px }
.btn-lg  { padding: .85rem 2rem; font-size: 1.1rem; border-radius: 12px }
.btn-sm  { padding: .38rem .85rem; font-size: .82rem; border-radius: 7px }
.btn-block { width: 100%; justify-content: center }

/* ─── Hero ────────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4.5rem 1rem 3rem;
  background: linear-gradient(160deg, #fff 0%, #f0f4ff 60%, #fff 100%);
  border-bottom: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 55% at 50% -5%, rgba(229,57,53,.08) 0%, transparent 70%);
  pointer-events: none;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  background: rgba(229,57,53,.08); border: 1px solid rgba(229,57,53,.2);
  color: var(--red); border-radius: 999px;
  padding: .35rem 1rem; font-size: .85rem; font-weight: 700;
  margin-bottom: 1.5rem; letter-spacing: .3px;
}
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 900; line-height: 1.2; color: var(--text);
  margin-bottom: 1rem; position: relative;
}
.hero h1 em { font-style: normal; color: var(--red) }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 500px; margin: 0 auto 2rem; position: relative }
.hero .btn { position: relative }

.hero-stats {
  display: inline-flex; gap: 2.5rem; flex-wrap: wrap; justify-content: center;
  margin-top: 1.5rem; position: relative;
}
.hero-stat { text-align: center }
.hero-stat-num { font-size: 1.6rem; font-weight: 900; color: var(--red); line-height: 1 }
.hero-stat-label { font-size: .8rem; color: var(--muted); margin-top: .2rem }

/* ─── Tool section ───────────────────────────────────────────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 0 1rem 4rem }

#tools { margin-top: 2.5rem }

.tool-category { margin-bottom: 2.75rem }

.category-header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem }

.category-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem 1rem; border-radius: 999px;
  font-size: .82rem; font-weight: 700; letter-spacing: .3px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .875rem;
}

.tool-card {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: 1.35rem 1rem 1.1rem;
  background: var(--card);
  border-radius: 14px;
  border: 1.5px solid var(--border2);
  color: inherit; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.tool-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--card-accent, var(--red));
  border-radius: 14px 14px 0 0;
  opacity: 0; transition: opacity .18s;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  border-color: var(--card-accent, var(--red));
}
.tool-card:hover::before { opacity: 1 }

.tool-icon { font-size: 2.1rem; line-height: 1 }
.tool-name { font-weight: 700; font-size: .92rem; text-align: center; color: var(--text) }
.tool-desc { font-size: .76rem; color: var(--muted); text-align: center; line-height: 1.35 }

/* Category pill colors (light-friendly) */
.cat-organize { background: rgba(229,57,53,.08);  color: #c53030; border: 1px solid rgba(229,57,53,.2) }
.cat-convert  { background: rgba(49,130,206,.08); color: #2b6cb0; border: 1px solid rgba(49,130,206,.2) }
.cat-to-pdf   { background: rgba(47,133,90,.08);  color: #276749; border: 1px solid rgba(47,133,90,.2) }
.cat-edit     { background: rgba(107,70,193,.08); color: #553c9a; border: 1px solid rgba(107,70,193,.2) }
.cat-security { background: rgba(214,126,36,.08); color: #c05621; border: 1px solid rgba(214,126,36,.2) }

/* ─── Plans ──────────────────────────────────────────────────────────────────── */
.plans { padding: 3rem 0 1rem; border-top: 1px solid var(--border) }
.plans-heading { text-align: center; margin-bottom: 2.5rem }
.plans-heading h2 { font-size: 2rem; font-weight: 900; color: var(--text) }
.plans-heading p { color: var(--muted); margin-top: .5rem }

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.plan-card {
  background: var(--card); border: 1.5px solid var(--border2); border-radius: 16px;
  padding: 1.75rem; display: flex; flex-direction: column; gap: .75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: transform .18s, box-shadow .18s;
}
.plan-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0,0,0,.1) }
.plan-card.featured {
  border-color: var(--red);
  box-shadow: 0 0 0 1px rgba(229,57,53,.2), 0 4px 20px rgba(229,57,53,.1);
}
.plan-badge-top {
  display: inline-block; background: var(--red); color: #fff;
  font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .5px;
  padding: .2rem .6rem; border-radius: 999px; margin-bottom: .25rem;
}
.plan-card h3 { font-size: 1.15rem; font-weight: 700; color: var(--text) }
.price { font-size: 2.4rem; font-weight: 900; color: var(--text); line-height: 1.1 }
.price small { font-size: 1rem; font-weight: 400; color: var(--muted) }
.plan-card ul {
  list-style: none; display: flex; flex-direction: column;
  gap: .45rem; flex: 1; margin: .5rem 0;
}
.plan-card ul li { display: flex; align-items: center; gap: .5rem; font-size: .92rem; color: var(--muted2) }
.plan-card ul li::before { content: '✓'; color: var(--success); font-weight: 900; flex-shrink: 0 }

/* ─── Misc inputs / upload ───────────────────────────────────────────────────── */
.upload-box {
  border: 2px dashed var(--border2); border-radius: 12px; padding: 3rem 2rem;
  text-align: center; cursor: pointer; transition: border-color .2s;
  background: var(--card);
}
.upload-box:hover, .upload-box.drag-over { border-color: var(--red) }

.tabs { display: flex; gap: .5rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem }
.tab {
  padding: .6rem 1.2rem; background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: color .15s;
}
.tab.active { color: var(--red); border-bottom-color: var(--red); font-weight: 600 }

.format-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin: 1rem 0;
}
.format-grid label {
  display: flex; align-items: center; gap: .5rem;
  padding: .75rem 1rem; border: 1px solid var(--border2); border-radius: 8px;
  cursor: pointer; background: var(--card); color: var(--text); transition: border-color .15s;
}
.format-grid label:hover { border-color: var(--red) }

#html-input {
  width: 100%; padding: 1rem; border: 1px solid var(--border2); border-radius: 8px;
  font-family: monospace; font-size: .9rem; resize: vertical;
  background: var(--bg); color: var(--text);
}

#result {
  margin-top: 2rem; padding: 1.5rem; background: var(--card);
  border-radius: 12px; text-align: center; border: 1px solid var(--border2);
}

/* ─── Cross-service section (TSB) — stays slightly gray ─────────────────────── */
.tsb {
  background: #f1f5f9;
  border-top: 1px solid var(--border);
  padding: 2.75rem 1rem 2.25rem; margin-top: 2.5rem;
}
.tsb-inner { max-width: 1100px; margin: 0 auto }
.tsb-eyebrow {
  text-align: center; font-size: .72rem; font-weight: 800;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--dimmed); margin-bottom: .5rem;
}
.tsb-headline {
  text-align: center; font-size: 1.15rem; font-weight: 800;
  color: var(--text); margin-bottom: 1.75rem;
}
.tsb-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px }
.tsb-card {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: 1.4rem .75rem 1.1rem; background: var(--card);
  border: 1.5px solid var(--border2); border-radius: 16px;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.tsb-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3.5px;
  background: var(--tc, var(--red)); border-radius: 16px 16px 0 0;
  opacity: 0; transition: opacity .2s;
}
.tsb-card:hover {
  transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,.1);
  border-color: var(--tc, var(--red));
}
.tsb-card:hover::after { opacity: 1 }
.tsb-card.tsb-now { border-color: var(--tc, var(--red)) }
.tsb-card.tsb-now::after { opacity: 1 }
.tsb-badge {
  position: absolute; top: 8px; right: 8px; background: var(--tc, var(--red));
  color: #fff; font-size: .58rem; font-weight: 800;
  padding: 2px 7px; border-radius: 999px;
}
.tsb-icon { font-size: 2rem; line-height: 1 }
.tsb-name { font-size: .8rem; font-weight: 800; color: var(--text); text-align: center; line-height: 1.3 }
.tsb-desc { font-size: .68rem; color: var(--muted); text-align: center }
.tsb-home { display: flex; justify-content: center; margin-top: 1.5rem }
.tsb-home-link {
  display: inline-flex; align-items: center; gap: .4rem;
  color: var(--muted); font-size: .82rem; font-weight: 600;
  padding: .45rem 1.25rem; border: 1px solid var(--border2); border-radius: 999px;
  transition: all .15s;
}
.tsb-home-link:hover { color: var(--red); border-color: rgba(229,57,53,.35) }

/* ─── Tool-page shared classes ──────────────────────────────────────────────── */
.ipdf-main { max-width: 960px; margin: 0 auto; padding: 2rem 1rem }
.ipdf-back {
  color: var(--muted); font-size: .9rem;
  display: inline-block; margin-bottom: 1.5rem;
}
.ipdf-back:hover { color: var(--red) }

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
footer {
  text-align: center; padding: 2.5rem 1rem;
  color: var(--dimmed); font-size: .85rem;
  border-top: 1px solid var(--border);
  background: #f1f5f9;
}
footer a { color: var(--muted) }
footer a:hover { color: var(--red) }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .nav-links { display: none }
  .hamburger { display: flex }
  .hero { padding: 3rem 1rem 2.5rem }
  .hero-stats { gap: 1.5rem }
  .tool-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem }
  .plans-grid { grid-template-columns: 1fr }
  .tsb-grid { grid-template-columns: repeat(3, 1fr) }
  .tsb-card:nth-child(n+4) { display: none }
  .nav-welcome-text { display: none }
  #logout-btn { display: none }   /* mobile: use hamburger menu instead */
}
