
/* ============================================================
   SHARED STYLES  –  ระบบเอกสารกฎระเบียบ
   ============================================================ */
:root {
  --blue:      #1e56c8;
  --blue-dark: #163fa0;
  --blue-light:#e8f0fe;
  --green:     #16a34a;
  --green-dark:#15803d;
  --text:      #111827;
  --text-soft: #6b7280;
  --border:    #e5e7eb;
  --bg-page:   #f4f6f9;
  --bg-card:   #ffffff;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: Prompt, 'Sarabun', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.6;
}

/* ── Header ── */
.site-header {
  background: var(--blue);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.site-header .logo {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  color: #fff;
}
.header-search {
  flex: 1;
  display: flex;
  gap: 8px;
  max-width: 520px;
}
.header-search input {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: var(--radius);
  padding: 0 14px;
  font-size: 14px;
  font-family: inherit;
  background: rgba(255,255,255,.15);
  color: #fff;
  outline: none;
  transition: background .2s;
}
.header-search input::placeholder { color: rgba(255,255,255,.6); }
.header-search input:focus { background: rgba(255,255,255,.25); }
.header-search button {
  height: 38px;
  padding: 0 16px;
  background: #fff;
  color: var(--blue);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.header-search button:hover { background: #f0f4ff; }
.menu-toggle {
  display: none;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

/* ── Page wrapper ── */
.page-wrap {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: start;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  position: sticky;
  top: 72px;
  box-shadow: var(--shadow);
}
.sidebar-head {
  background: var(--blue);
  color: #fff;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-head::before {
  content: "📋";
  font-size: 16px;
}
.sidebar-nav { list-style: none; padding: 8px; }
.sidebar-nav li { }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--blue-light); color: var(--blue); }
.sidebar-nav a.active {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
}
.sidebar-nav a .nav-icon { font-size: 16px; flex-shrink: 0; }

/* ── Document card list ── */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.doc-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.doc-card:last-of-type { border-bottom: none; }
.doc-card:hover { background: #fafbff; }

.doc-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: #fef2f2;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.doc-body { flex: 1; min-width: 0; }
.doc-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
}
.doc-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: filter .15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-detail {
  background: var(--blue);
  color: #fff;
}
.btn-detail:hover { filter: brightness(1.1); }
.btn-pdf {
  background: var(--green);
  color: #fff;
}
.btn-pdf:hover { background: var(--green-dark); }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 0 0 14px 14px;
  flex-wrap: wrap;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  background: #fff;
  transition: all .15s;
  cursor: pointer;
}
.page-btn:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.page-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-soft);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .page-wrap { grid-template-columns: 1fr; }
  .menu-toggle { display: flex; align-items: center; }
  .sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 50;
    border-radius: 0;
    top: 0;
    overflow-y: auto;
  }
  .welcome-card h1 { font-size: 14px; margin-bottom: 8px; font-weight: 500; }
  .welcome-card p  { font-size: 12px; opacity: .88; margin: 0; }
  .sidebar.open { display: block; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 49;
  }
  .sidebar-overlay.open { display: block; }
}
@media (max-width: 480px) {
  .site-header { padding: 0 12px; gap: 8px; }
  .header-search { display: none; }
  .page-wrap { margin: 12px auto; padding: 0 12px; }
  .doc-card { padding: 14px 14px; gap: 12px; }
  .doc-icon { display: none; }
}

.welcome-card {
  background: linear-gradient(135deg, var(--blue) 0%, #2563eb 100%);
  color: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(30,86,200,.25);
}
.welcome-card h1 { font-size: 14px; margin-bottom: 8px; font-weight: 500; }
.welcome-card p  { font-size: 12px; opacity: .88; margin: 0; }
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow .15s, border-color .15s, transform .15s;
  box-shadow: var(--shadow);
}
.cat-card:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 14px rgba(30,86,200,.15);
  transform: translateY(-2px);
}
.cat-card .cat-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-light);
  border-radius: 10px;
}
.cat-card .cat-label { font-size: 15px; font-weight: 600; line-height: 1.4; }


/* ── เพิ่มเติมสำหรับหน้าแบบดึงจากฐานข้อมูล ── */
.cat-card .cat-count { margin-left:auto; font-size:12.5px; color:var(--text-soft); white-space:nowrap; }
.cat-head { display:flex; align-items:center; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.cat-head h1 { font-size:19px; font-weight:600; }
.cat-head .count-pill { background:var(--blue-light); color:var(--blue-dark); border-radius:999px; padding:3px 12px; font-size:13px; }
.doc-meta { font-size:12.5px; color:var(--text-soft); margin-top:2px; }
.doc-tag { display:inline-block; font-size:11.5px; padding:2px 8px; border-radius:999px; border:1px solid var(--border); color:var(--text-soft); margin-right:5px; }
.doc-tag.repealed { background:#fef2f2; border-color:#fecaca; color:#b91c1c; }
.doc-tag.amended  { background:#fffbeb; border-color:#fde68a; color:#92400e; }
.empty-note { background:var(--bg-card); border:1px dashed var(--border); border-radius:12px; padding:36px 20px; text-align:center; color:var(--text-soft); }
.admin-link { display:block; padding:12px 18px; border-top:1px solid var(--border); font-size:13px; color:var(--text-soft); text-decoration:none; }
.admin-link:hover { color:var(--blue); background:var(--blue-light); }
