* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #16181d;
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  background: #f4f5f7;
  border-right: 1px solid #e7e9ed;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  padding: 0.25rem 0.5rem;
  margin-bottom: 1.75rem;
}
.sidebar-brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: #16181d;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa0ab;
  padding: 0.5rem;
  margin-top: 0.5rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 0.1rem; flex: 1; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  color: #5b6270;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}
.sidebar-link:hover { background: #e9ebef; color: #16181d; }
.sidebar-link.active { background: #fff; color: #16181d; box-shadow: 0 1px 3px rgba(20,20,40,.08); }
.sidebar-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.1em; opacity: .75; }
.sidebar-spacer { flex: 1; }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.5rem;
  margin-top: 1rem;
  border-top: 1px solid #e7e9ed;
  padding-top: 1rem;
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #dde1e8;
  color: #4b5162;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.sidebar-user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.72rem; color: #9aa0ab; text-transform: capitalize; }
.sidebar-user-logout { color: #9aa0ab; text-decoration: none; font-size: 0.9rem; padding: 0.3rem; border-radius: 6px; }
.sidebar-user-logout:hover { background: #e9ebef; color: #16181d; }

.content { flex: 1; padding: 2rem 2.5rem; min-width: 0; }

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #f0f0f3;
}
.page-header h1 { margin: 0 0 0.25rem; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.01em; }
.page-subtitle { margin: 0; font-size: 0.88rem; color: #9aa0ab; }
.btn-back-top {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
  background: none;
  color: #8a8f98;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  box-shadow: none;
  margin-bottom: 0.4rem;
}
.btn-back-top:hover { color: #2f6bff; }

/* ---------- Flash ---------- */
.flash {
  background: #e3f7e9;
  border: 1px solid #b7e9c7;
  color: #1e7d3a;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 10px;
  background: #2f6bff;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(47,107,255,.2);
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: #1f56e0; box-shadow: 0 4px 10px rgba(47,107,255,.25); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-secondary { background: #f0f1f5; color: #16181d; box-shadow: none; }
.btn-secondary:hover { background: #e3e5ec; box-shadow: none; }
.btn-danger { background: #fde8e8; color: #c62828; box-shadow: none; }
.btn-danger:hover { background: #fad3d3; box-shadow: none; }
.btn-ghost { background: #fff; color: #2f6bff; border: 1.5px solid #d6e0ff; box-shadow: none; }
.btn-ghost:hover { background: #f3f6ff; border-color: #2f6bff; }

/* ---------- Tables ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #f0f0f3;
  border-radius: 14px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f4f4f7;
  text-align: left;
  font-size: 0.88rem;
}
.data-table th {
  background: #fafafc;
  color: #8a8f98;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table .actions { white-space: nowrap; }
.data-table .actions a { margin-right: 0.6rem; color: #2f6bff; text-decoration: none; font-weight: 500; font-size: 0.85rem; }
.data-table .actions a:hover { text-decoration: underline; }

code { background: #f0f1f5; padding: 0.15rem 0.4rem; border-radius: 5px; font-size: 0.82rem; }
.api-key-cell { display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; cursor: default; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-draft { background: #f0f1f5; color: #6b7280; }
.badge-scheduled { background: #fff3d6; color: #a16a00; }
.badge-published { background: #e3f7e9; color: #1e7d3a; }

/* ---------- Filter bar ---------- */
.filter-bar { margin-bottom: 1rem; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { padding: 0.45rem 0.75rem; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 0.88rem; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.25rem; }

/* ---------- Forms ---------- */
.form-error { color: #c62828; font-size: 0.9rem; margin: 0; }
.form-section {
  background: #fff;
  border: 1px solid #f0f0f3;
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.form-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid #f0f0f3;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { margin-bottom: 0.7rem; min-width: 0; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.3rem; color: #4b5162; }
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=number],
.form-group input[type=datetime-local],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.87rem;
  font-family: inherit;
  background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: #2f6bff; box-shadow: 0 0 0 3px rgba(47,107,255,.1); }
.form-group textarea { resize: vertical; }
.form-group input[type=file] { border: none; padding: 0; }
.form-group input.slug-fixed { background: #f4f5f7; color: #9aa0ab; cursor: not-allowed; }
.form-group small { display: block; margin-top: 0.3rem; color: #9aa0ab; font-size: 0.78rem; }

/* ---------- Menu section cards (site form: news/freepage/gambling) ---------- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  align-items: start;
}
@media (max-width: 900px) {
  .menu-grid { grid-template-columns: 1fr; }
}
.taxonomy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
.taxonomy-grid .form-section { margin-bottom: 0; }
@media (max-width: 900px) {
  .taxonomy-grid { grid-template-columns: 1fr; }
}

/* ---------- Taxonomy chips + modal (categories/tags on site edit page) ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.chip {
  border: 1px solid #e5e7eb;
  background: #f7f8fa;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: #16181d;
}
.chip:hover { background: #eef1ff; border-color: #c7d2ff; }

.taxonomy-modal {
  border: none;
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  width: min(640px, 92vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.taxonomy-modal::backdrop { background: rgba(20,20,24,0.45); }
.taxonomy-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f0f0f3;
  font-size: 1rem;
}
.taxonomy-modal-head .modal-close {
  border: none;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: #9aa0ab;
  padding: 0.1rem 0.4rem;
}
.taxonomy-modal-head .modal-close:hover { color: #16181d; }
.taxonomy-modal-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

/* ---------- Rich text editor (article content) ---------- */
.rte-wrap {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.5rem;
  background: #f7f8fa;
  border-bottom: 1px solid #e5e7eb;
}
.rte-toolbar select {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
  background: #fff;
  color: #16181d;
  margin-right: 0.25rem;
}
.rte-toolbar button {
  border: none;
  background: transparent;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #4b5162;
  font-size: 0.95rem;
  font-family: inherit;
}
.rte-toolbar button:hover { background: #eef1ff; color: #2f6bff; }
.rte-toolbar button.active { background: #2f6bff; color: #fff; }
.rte-toolbar .rte-sep { width: 1px; align-self: stretch; background: #e5e7eb; margin: 0.2rem 0.3rem; }
.rte-body {
  min-height: 260px;
  max-height: 520px;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #16181d;
}
.rte-body:focus { outline: none; }
.rte-body img { max-width: 100%; border-radius: 6px; }
.rte-body[data-empty="true"]::before {
  content: attr(data-placeholder);
  color: #9aa0ab;
  pointer-events: none;
}
.rte-body table { border-collapse: collapse; width: 100%; margin: 0.75rem 0; }
.rte-body th, .rte-body td { border: 1px solid #d7dae0; padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; }
.rte-body th { background: #f7f8fa; font-weight: 600; }
/* ---------- Category/tag checkbox picker (article form) ---------- */
.picker-filter {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.87rem;
  font-family: inherit;
  margin-bottom: 0.5rem;
}
.picker-filter:focus { outline: none; border-color: #2f6bff; box-shadow: 0 0 0 3px rgba(47,107,255,.1); }
.picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  max-height: 260px;
  overflow-y: auto;
}
.picker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.picker-item input[type=checkbox] { width: 15px; height: 15px; accent-color: #2f6bff; cursor: pointer; }
.picker-item.picker-match span { background: #fff3d6; border-radius: 3px; padding: 0 2px; }
.picker-empty { color: #9aa0ab; font-size: 0.85rem; }
.picker-group-label {
  flex-basis: 100%;
  font-size: 0.75rem;
  font-weight: 600;
  color: #9aa0ab;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-top: 0.4rem;
}
.picker-group-label:first-child { margin-top: 0; }

.rte-source-bar {
  padding: 0.4rem 1rem;
  background: #fff3d6;
  color: #a16a00;
  font-size: 0.78rem;
  font-weight: 600;
  border-bottom: 1px solid #f0d999;
}
.rte-source {
  width: 100%;
  min-height: 260px;
  max-height: 520px;
  border: none;
  padding: 0.9rem 1rem;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  color: #16181d;
  resize: vertical;
}
.menu-card {
  border: 1px solid #ecedf1;
  border-radius: 12px;
  overflow: hidden;
  background: #fbfbfd;
}
.menu-card[open] { background: #fff; }
.menu-card summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.9rem;
  font-weight: 700;
  font-size: 0.88rem;
  user-select: none;
}
.menu-card summary::-webkit-details-marker { display: none; }
.menu-card summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #9aa0ab;
  border-bottom: 2px solid #9aa0ab;
  transform: rotate(-45deg);
  margin-left: auto;
  transition: transform 0.15s ease;
}
.menu-card[open] summary::after { transform: rotate(45deg); }
.menu-card-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: #eef1ff;
  flex-shrink: 0;
}
.menu-card-title-en { font-weight: 500; color: #9aa0ab; font-size: 0.78rem; margin-left: 0.15rem; }
.menu-card-body {
  padding: 0.15rem 0.9rem 0.9rem;
  border-top: 1px solid #f0f0f3;
}
.field-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9aa0ab;
  margin: 0.75rem 0 0.35rem;
}
.field-group-label:first-child { margin-top: 0.65rem; }
.lang-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.03rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.3rem;
  vertical-align: middle;
}
.lang-tag-th { background: #e3f7e9; color: #1e7d3a; }
.lang-tag-en { background: #e3ecff; color: #2f5bd7; }

/* ---------- Login ---------- */
.login-body { margin: 0; min-height: 100vh; background: #e4e6eb; display: flex; align-items: center; justify-content: center; }
.login-split {
  display: flex;
  width: 100%;
  max-width: 1000px;
  min-height: 600px;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.12);
}
.login-split-left {
  flex: 1 1 50%;
  padding: 3rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-brand { font-size: 1rem; font-weight: 700; margin-bottom: 2rem; display: flex; align-items: center; gap: 0.5rem; }
.login-brand-mark { font-size: 1.2rem; }
.login-heading h1 { font-size: 1.8rem; font-weight: 800; margin: 0 0 0.5rem; }
.login-heading p { color: #6b7280; margin: 0 0 1.75rem; }
.login-form-split { display: flex; flex-direction: column; gap: 0.9rem; max-width: 380px; }
.login-form-split label { font-size: 0.85rem; font-weight: 600; margin-bottom: -0.4rem; }
.login-form-split input { padding: 0.75rem 1rem; border: 1px solid #e5e7eb; border-radius: 10px; font-size: 0.95rem; }
.login-form-split input:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.1); }
.login-form-split button {
  margin-top: 0.75rem;
  padding: 0.8rem;
  border: none;
  border-radius: 12px;
  background: #7c3aed;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.login-form-split button:hover { background: #6d28d9; }
.login-split-right {
  flex: 1 1 50%;
  background: linear-gradient(160deg, #7c5cff 0%, #9b6bff 55%, #b487ff 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.login-illustration { width: 260px; height: 260px; opacity: .9; }
.login-illustration-caption { color: rgba(255,255,255,.85); font-size: 0.95rem; font-weight: 600; margin-top: 1.5rem; }

@media (max-width: 680px) {
  .login-split { flex-direction: column; max-width: 480px; }
  .login-split-right { display: none; }
  .login-split-left { padding: 2.5rem 2rem; }
  .sidebar { display: none; }
  .content { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
}
