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

:root {
  --navy:    #0d1b2a;
  --navy2:   #1a3a5c;
  --teal:    #0e7490;
  --teal2:   #0891b2;
  --gold:    #d4a017;
  --white:   #ffffff;
  --off:     #f8f9fa;
  --light:   #e9ecef;
  --muted:   #6c757d;
  --text:    #1a1a2e;
  --border:  #dee2e6;

  /* Category colors */
  --cat-rd:   #1a5276;
  --cat-tfac: #6c3483;
  --cat-dbd:  #1e8449;
  --cat-gen:  #7f8c8d;

  --radius:  8px;
  --radius-lg: 12px;
  --shadow:  0 2px 8px rgba(0,0,0,0.08);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Sarabun', 'Tahoma', sans-serif;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  background: var(--off);
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal2); text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ── Layout ────────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.page-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 2rem;
  padding: 2rem 0;
}

.main-content { min-width: 0; }

/* ── Header ────────────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  flex-wrap: wrap;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: contain;
  background: var(--navy2);
}

.brand-icon { font-size: 1.8rem; line-height: 1; }

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.2;
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  flex: 1;
}

.site-nav a {
  color: #cbd5e1;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover { background: var(--navy2); color: var(--white); }

.header-search {
  display: flex;
  gap: 0;
  flex-shrink: 0;
}

.header-search input {
  padding: 0.4rem 0.75rem;
  border: 1px solid #374151;
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  background: #1e293b;
  color: var(--white);
  font-family: inherit;
  font-size: 0.875rem;
  width: 180px;
  outline: none;
}

.header-search input::placeholder { color: #64748b; }
.header-search input:focus { border-color: var(--teal); }

.header-search button {
  padding: 0.4rem 0.75rem;
  background: var(--teal);
  color: white;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.15s;
}

.header-search button:hover { background: var(--teal2); }

/* ── Category badges ───────────────────────────────────────── */
.cat-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  color: white;
  white-space: nowrap;
}

.cat-badge.cat-กรมสรรพากร        { background: var(--cat-rd); }
.cat-badge.cat-สภาวิชาชีพบัญชี   { background: var(--cat-tfac); }
.cat-badge.cat-กรมพัฒนาธุรกิจการค้า { background: var(--cat-dbd); }
.cat-badge.cat-ทั่วไป             { background: var(--cat-gen); }

/* ── Featured post ─────────────────────────────────────────── */
.featured-post {
  display: block;
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  color: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.featured-post::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(14,116,144,0.3), transparent 70%);
  pointer-events: none;
}

.featured-badge {
  display: inline-block;
  background: var(--gold);
  color: var(--navy);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.75rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.featured-post h2 {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0.5rem 0;
  color: white;
}

.featured-post p { color: #cbd5e1; font-size: 0.95rem; margin: 0.5rem 0; }
.featured-date { font-size: 0.8rem; color: #94a3b8; }

/* ── Posts grid ────────────────────────────────────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.post-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
}

.post-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.post-card-meta time { font-size: 0.78rem; color: var(--muted); }

.post-card h2 {
  font-size: 0.975rem;
  font-weight: 600;
  line-height: 1.5;
  flex: 1;
}

.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--teal); text-decoration: none; }

.post-excerpt { font-size: 0.875rem; color: var(--muted); line-height: 1.6; flex: 1; }

.post-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--light);
}

.source-label { font-size: 0.75rem; color: var(--muted); }

.read-more {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--teal);
  white-space: nowrap;
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.page-btn {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1.25rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--teal);
  text-decoration: none;
  transition: background 0.15s;
}

.page-btn:hover { background: var(--light); text-decoration: none; }
.page-info { font-size: 0.875rem; color: var(--muted); }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 1.25rem; }

.sidebar-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.sidebar-card h3 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--teal);
}

.cat-list { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }

.cat-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}

.cat-list a:hover, .cat-list a.active { background: var(--light); color: var(--teal); }

.cat-count {
  font-size: 0.75rem;
  background: var(--light);
  color: var(--muted);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
}

.recent-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }

.recent-list li { display: flex; flex-direction: column; gap: 0.15rem; }

.recent-list a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  text-decoration: none;
}

.recent-list a:hover { color: var(--teal); }
.recent-list span { font-size: 0.75rem; color: var(--muted); }

/* ── Seminar CTA sidebar ───────────────────────────────────── */
.seminar-cta {
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  color: white;
  border: none;
}

.cta-label { font-size: 0.8rem; font-weight: 700; color: var(--gold); margin-bottom: 0.25rem; }
.cta-date { font-size: 1.1rem; font-weight: 700; color: white; margin-bottom: 0.25rem; }
.cta-desc { font-size: 0.82rem; color: #cbd5e1; margin-bottom: 1rem; line-height: 1.5; }

.cta-btn {
  display: block;
  text-align: center;
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: opacity 0.15s;
}

.cta-btn:hover { opacity: 0.9; text-decoration: none; color: var(--navy); }

/* ── Section header ────────────────────────────────────────── */
.section-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.section-header h1 { font-size: 1.5rem; font-weight: 700; }
.section-header p { font-size: 0.875rem; color: var(--muted); margin-top: 0.25rem; }

/* ── Single post ───────────────────────────────────────────── */
.single-post {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.single-post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.single-post-meta time { font-size: 0.85rem; color: var(--muted); }

.single-post-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 1.5rem;
  color: var(--navy);
}

/* Post body typography */
.post-body { line-height: 1.9; }
.post-body h2 { font-size: 1.2rem; font-weight: 700; margin: 1.75rem 0 0.75rem; color: var(--navy); }
.post-body h3 { font-size: 1rem; font-weight: 700; margin: 1.25rem 0 0.5rem; }
.post-body p { margin-bottom: 1rem; }
.post-body ul, .post-body ol { margin: 0.75rem 0 1rem 1.5rem; }
.post-body li { margin-bottom: 0.4rem; }
.post-body strong { font-weight: 700; }
.post-body a { color: var(--teal); }

.source-link {
  margin-top: 2rem;
  padding: 0.875rem 1rem;
  background: var(--off);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.875rem;
}

/* Social caption box */
.social-caption {
  margin-top: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.caption-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--light);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 600;
}

.copy-btn {
  background: var(--teal);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0.3rem 0.75rem;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

.copy-btn:hover { background: var(--teal2); }

.social-caption p {
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Post nav */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.back-link, .cat-link {
  font-size: 0.875rem;
  color: var(--teal);
  text-decoration: none;
}

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem;
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ── Footer ────────────────────────────────────────────────── */
.site-footer {
  background: var(--navy);
  color: #94a3b8;
  margin-top: 4rem;
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 2.5rem 1.25rem;
}

.footer-brand strong { color: white; display: block; margin-bottom: 0.5rem; }
.footer-brand p { font-size: 0.875rem; line-height: 1.6; }

.footer-links { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

.footer-links strong { color: white; display: block; font-size: 0.85rem; margin-bottom: 0.5rem; }

.footer-links a {
  display: block;
  font-size: 0.825rem;
  color: #94a3b8;
  text-decoration: none;
  margin-bottom: 0.3rem;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--teal2); }

.footer-bottom {
  border-top: 1px solid #1e293b;
  padding: 1rem 1.25rem;
  font-size: 0.8rem;
  color: #64748b;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
  .footer-inner { grid-template-columns: 1fr; }
  .posts-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .header-inner { gap: 0.75rem; }
  .site-nav { gap: 0.1rem; }
  .site-nav a { padding: 0.3rem 0.5rem; font-size: 0.82rem; }
  .header-search input { width: 130px; }
  .posts-grid { grid-template-columns: 1fr; }
  .single-post { padding: 1.25rem; }
  .single-post-title { font-size: 1.25rem; }
  .footer-links { grid-template-columns: 1fr; }
}
