/* หน่วยงานทดสอบ AI - Back Office shared shell & components (extends tokens.css) */

/* ===== Top nav (2 sections since IA consolidation 2026-08-29) is styled by tokens.css ===== */

/* ===== Admin layout: left sub-nav + content ===== */
.admin-layout { display: flex; min-height: calc(100vh - 69px); }
.admin-sidenav {
  width: 240px; flex-shrink: 0;
  background: var(--bg-white); border-right: 1px solid var(--border);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 4px;
}
.admin-sidenav .side-title {
  font-size: 10px; font-weight: 700; color: var(--text-450);
  letter-spacing: .25px; padding: 0 10px 8px;
}
.admin-sidenav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--text-600);
}
.admin-sidenav a img { width: 16px; height: 16px; }
.admin-sidenav a:hover { background: var(--bg-chip); }
.admin-sidenav a.active {
  background: var(--bg-active); border: 1px solid var(--border-active);
  color: var(--color-01); font-weight: 600; padding: 8px 9px;
}
.admin-content { flex: 1; padding: 24px 32px 60px; min-width: 0; }

/* ===== Page head ===== */
.admin-page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.admin-page-head h1 { font-size: 20px; font-weight: 700; color: var(--text-900); }
.admin-page-head .sub { font-size: 13px; color: var(--text-500); margin-top: 4px; }

/* ===== Cards / tables ===== */
.card { background: var(--bg-white); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 15px; font-weight: 700; color: var(--text-900); }
.card .card-sub { font-size: 12px; color: var(--text-500); margin-top: 2px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-500); padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--text-700); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #f8fafc; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 9px; font-size: 13px; font-weight: 600; padding: 9px 16px; border: 1px solid transparent; }
.btn img { width: 14px; height: 14px; }
.btn-primary { background: var(--color-01); color: #fff; }
.btn-primary:hover { background: #1d3a80; }
.btn-secondary { background: var(--bg-white); color: var(--text-700); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-chip); }
.btn-danger { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.icon-btn { padding: 6px; border-radius: 6px; display: inline-flex; }
.icon-btn:hover { background: var(--bg-chip); }
.icon-btn img { width: 14px; height: 14px; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.badge-green { background: var(--success-bg); color: var(--success-700); }
.badge-red { background: #fef2f2; color: var(--red); }
.badge-amber { background: var(--warn-bg); color: var(--warn-700); }
.badge-gray { background: var(--bg-chip); color: var(--text-500); }
.badge-navy { background: var(--bg-active); color: var(--color-01); }
.dot { width: 6px; height: 6px; border-radius: 3px; background: currentColor; }

/* ===== Forms ===== */
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-700); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; color: var(--text-900); background: var(--bg-white);
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--border-active); border-color: var(--border-active); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 48px 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-white); border-radius: 14px; width: 100%; max-width: 560px; overflow: hidden; }
.modal-head { background: var(--color-01); color: #fff; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-head .close { color: #fff; font-size: 18px; line-height: 1; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--color-01); color: #fff; font-size: 13px; font-weight: 500;
  padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: all .2s ease; z-index: 200; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Stat tiles ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { background: var(--bg-white); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; }
.stat .label { font-size: 12px; color: var(--text-500); font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 700; color: var(--text-900); margin-top: 6px; }
.stat .value small { font-size: 12px; font-weight: 500; color: var(--text-500); }
.stat .delta { font-size: 11px; margin-top: 4px; color: var(--text-500); }
