/* Reset & Global */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  line-height: 1.65;
  font-size: 18px; /* ปรับขนาดให้เหมาะกับ Sarabun เพื่อให้อ่านสบายตา */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: #0f172a;
}

.brand-logo {
  font-size: 1.4rem;
}

.search-wrapper {
  flex-grow: 1;
  max-width: 360px;
}

.search-wrapper input {
  width: 100%;
  padding: 9px 16px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.95rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background-color: #f1f5f9;
  outline: none;
  transition: all 0.2s ease;
}

.search-wrapper input:focus {
  background-color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Container */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 20px;
  flex-grow: 1;
  width: 100%;
}

/* Hero Section */
.hero-section {
  margin-bottom: 32px;
  text-align: left;
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  color: #64748b;
  font-size: 1.1rem;
}

/* Category Tabs */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 6px 18px;
  border-radius: 9999px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  background-color: #f1f5f9;
  color: #1e293b;
}

.tab-btn.active {
  background-color: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

/* Knowledge Cards Grid */
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.doc-card {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}

.doc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.05);
  border-color: #cbd5e1;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: #2563eb;
  background-color: #eff6ff;
  padding: 2px 10px;
  border-radius: 6px;
}

.date {
  font-size: 0.82rem;
  color: #94a3b8;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 10px;
  line-height: 1.4;
}

.card-summary {
  font-size: 0.98rem;
  color: #475569;
  margin-bottom: 18px;
  flex-grow: 1;
}

.card-footer {
  margin-top: auto;
}

.read-more {
  font-size: 0.95rem;
  font-weight: 600;
  color: #2563eb;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #64748b;
  font-size: 1.1rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: #ffffff;
  border-radius: 14px;
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
}

.modal-close:hover {
  color: #0f172a;
}

.modal-body h2 {
  font-size: 1.5rem;
  color: #0f172a;
  margin-bottom: 14px;
}

.modal-body p {
  color: #334155;
  margin-bottom: 14px;
  font-size: 1.05rem;
}

.modal-body pre {
  background-color: #0f172a;
  color: #f8fafc;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: Consolas, monospace;
  font-size: 0.9rem;
  margin: 14px 0;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 0.9rem;
  color: #94a3b8;
  border-top: 1px solid #e2e8f0;
  background-color: #ffffff;
  margin-top: auto;
}
