/* VOM — HumanAI Design System (vanilla CSS port of paypilot tokens)
 * §0 BRAND BLOCK (VOM):
 *   primary = navy   #0F172A   (default button + headline)
 *   cta     = cherry #C8102E   (1 hero CTA per screen — Vorda CI)
 *   brand   = cherry #C8102E   (active state, badge)
 *   accent  = rose   #FB7185   (banner, highlight)
 *   gradient = #FB7185 → #C8102E (signature only — login hero)
 *   fonts:  Prompt (body)  +  Poppins (display)
 */

:root {
  /* Brand palette (§0 — กรอกค่าจริง) */
  --primary:        #0F172A;
  --primary-soft:   #1E293B;
  --cta:            #C8102E;
  --cta-dark:       #A50C24;
  --brand:          #C8102E;
  --brand-50:       #FFF1F2;
  --brand-100:      #FFE4E6;
  --brand-500:      #E11D48;
  --brand-600:      #C8102E;
  --brand-700:      #A50C24;
  --accent:         #FB7185;
  --accent-soft:    #FECDD3;

  /* Neutrals (locked — กลางทุก product) */
  --surface:        #F8FAFC;   /* page bg (gray-50) */
  --surface-soft:   #F1F5F9;
  --card:           #FFFFFF;
  --border:         #E2E8F0;   /* gray-200 */
  --border-strong:  #CBD5E1;
  --text:           #0F172A;   /* gray-900 */
  --text-soft:      #334155;   /* gray-700 */
  --muted:          #64748B;   /* gray-500 */
  --muted-soft:     #94A3B8;   /* gray-400 */

  /* Status (locked) */
  --success:        #16A34A;
  --success-bg:     #DCFCE7;
  --warn:           #D97706;
  --warn-bg:        #FEF3C7;
  --danger:         #DC2626;
  --danger-bg:      #FEE2E2;
  --info:           #2563EB;
  --info-bg:        #DBEAFE;

  /* Foundation tokens (locked) */
  --radius-sm:  6px;
  --radius:     8px;
  --radius-lg:  12px;   /* card */
  --radius-xl:  16px;   /* modal */

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow:    0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Prompt', system-ui, -apple-system, sans-serif;
  background: var(--surface);
  color: var(--text);
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Poppins', 'Prompt', system-ui, sans-serif;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }

::selection { background: var(--brand-100); color: var(--brand-700); }

/* ============ Brand mark (reusable: sidebar / login) ============ */
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--brand) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-weight: 700; font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

/* ============ App shell (sidebar + main) ============ */
body.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700; font-size: 18px;
  color: var(--text);
  letter-spacing: -0.5px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .product-sub {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0;
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.sidebar-nav a:hover { background: var(--surface-soft); color: var(--text); text-decoration: none; }
.sidebar-nav a.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.sidebar-nav a.active [data-lucide] { color: var(--brand-600); }
.sidebar-nav [data-lucide] { color: var(--muted-soft); }
.sidebar-nav a:hover [data-lucide] { color: var(--text-soft); }

.sidebar-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted-soft);
  font-weight: 600;
  padding: 12px 14px 4px;
  margin-top: 4px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--brand) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.sidebar-footer .user-info {
  flex: 1; min-width: 0;
}
.sidebar-footer .user-info .name {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-footer .user-info .role {
  font-size: 11px; color: var(--muted);
}
.sidebar-footer .logout-btn {
  background: transparent; border: none;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sidebar-footer .logout-btn:hover { background: var(--surface-soft); color: var(--danger); }

.main {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
}

/* Mobile topbar (hidden on desktop) */
.mobile-topbar {
  display: none;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 30;
}
.mobile-topbar .menu-toggle {
  background: transparent; border: none;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-soft);
}
.mobile-topbar .menu-toggle:hover { background: var(--surface-soft); }
.mobile-topbar .brand-text {
  font-family: 'Poppins', sans-serif;
  font-weight: 700; font-size: 16px;
  color: var(--text);
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 45;
}
.sidebar-backdrop.show { display: block; }

/* ============ Layout container ============ */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 28px 60px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: stretch; }
.col { flex: 1; min-width: 0; }
.page-title { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.page-sub   { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

/* ============ Card ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 16px; margin-top: 0; }
.card h3 {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  margin: 0 0 12px;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.05s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Default — primary navy (HumanAI brand deck) */
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary-soft); color: #fff; text-decoration: none; }

/* Hero CTA — cherry (1 per screen) */
.btn-cta {
  background: var(--cta);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-cta:hover { background: var(--cta-dark); color: #fff; text-decoration: none; }

/* Secondary — outlined */
.btn-secondary {
  background: var(--card);
  color: var(--text-soft);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-soft); color: var(--text); text-decoration: none; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #B91C1C; color: #fff; text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--surface-soft); }

.btn-sm { padding: 6px 11px; font-size: 12px; gap: 6px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }

/* Icon-only button — has aria-label */
.btn-icon {
  padding: 8px;
  width: 36px; height: 36px;
  justify-content: center;
}

/* ============ Form ============ */
.form-group { margin-bottom: 14px; }
.label, .form-group label {
  display: block;
  font-size: 13px; font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.input, .form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font: inherit;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}
.input::placeholder, .form-group input::placeholder { color: var(--muted-soft); }
.input-error { border-color: var(--danger); }
.input-error:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12); }
.hint, .form-group .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ============ Table ============ */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th {
  background: var(--surface-soft);
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tbody tr:hover td { background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============ Badge ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-soft);
  color: var(--text-soft);
}
.badge-success { background: var(--success-bg); color: #15803D; }
.badge-warn    { background: var(--warn-bg);    color: #92400E; }
.badge-danger  { background: var(--danger-bg);  color: #991B1B; }
.badge-info    { background: var(--info-bg);    color: #1E40AF; }
.badge-brand   { background: var(--brand-50);   color: var(--brand-700); }
.badge-cyan    { background: #CFFAFE;           color: #155E75; }

/* Backwards-compat (existing pages use these classnames) */
.badge-gray   { background: var(--surface-soft); color: var(--muted); }
.badge-blue   { background: var(--info-bg);      color: #1E40AF; }
.badge-green  { background: var(--success-bg);   color: #15803D; }
.badge-red    { background: var(--danger-bg);    color: #991B1B; }
.badge-yellow { background: var(--warn-bg);      color: #92400E; }
.badge-pink   { background: var(--brand-50);     color: var(--brand-700); }

/* ============ Stat ============ */
.stat {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 0;
}
.stat .num {
  font-family: 'Poppins', sans-serif;
  font-size: 28px; font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.stat .label { color: var(--muted); font-size: 13px; }

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-card .num {
  font-family: 'Poppins', sans-serif;
  font-size: 30px; font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.stat-card .delta { font-size: 12px; color: var(--muted); }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  opacity: 0; transition: all 0.2s; z-index: 1000;
  max-width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warn); }

/* ============ Modal / Confirm ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
  animation: fade-in 0.15s ease-out;
}
.modal {
  background: var(--card);
  border-radius: var(--radius-xl);
  max-width: 440px; width: 100%;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  animation: pop-in 0.18s ease-out;
}
.modal h3 {
  font-family: 'Poppins', sans-serif;
  font-size: 17px; font-weight: 600;
  text-transform: none; letter-spacing: 0;
  color: var(--text);
  margin: 0 0 8px;
}
.modal p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ Spinner ============ */
.spinner { display: none; justify-content: center; padding: 24px; }
.spinner::after {
  content: ''; width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Login (signature gradient) ============ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 25% 30%, rgba(251, 113, 133, 0.5) 0%, transparent 45%),
    radial-gradient(circle at 75% 70%, rgba(200, 16, 46, 0.4) 0%, transparent 45%),
    linear-gradient(135deg, #FB7185 0%, #C8102E 60%, #7F1D1D 100%);
  padding: 24px;
}
.login-card {
  background: var(--card);
  padding: 36px 32px;
  border-radius: var(--radius-xl);
  max-width: 380px; width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(127, 29, 29, 0.35);
}
.login-card .logo-mark {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent) 0%, var(--brand) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-weight: 700; font-size: 22px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(200, 16, 46, 0.3);
}
.login-card .logo {
  font-family: 'Poppins', sans-serif;
  font-size: 26px; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.login-card .desc { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card .divider {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0 14px;
  color: var(--muted-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.login-card .divider::before, .login-card .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.login-card .hint { font-size: 12px; color: var(--muted); margin-top: 18px; line-height: 1.6; }

/* ============ Dropzone ============ */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 20px; text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--brand-500);
  background: var(--brand-50);
}
.dropzone p { margin: 6px 0 0; color: var(--text-soft); font-weight: 500; }
.dropzone p span { color: var(--muted); font-weight: 400; font-size: 12px; }
.dropzone input[type="file"] { display: none; }
.dropzone .icon { color: var(--muted-soft); }

/* ============ Pile / list card ============ */
.pile-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--card);
  transition: border-color 0.12s;
}
.pile-card:hover { border-color: var(--brand-500); }
.pile-card .name { font-weight: 500; color: var(--text); }
.pile-card .count {
  font-family: 'Poppins', sans-serif;
  color: var(--brand-600);
  font-size: 20px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ============ Photo grid / radio-card ============ */
.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 12px;
}
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.photo-slots {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.photo-slot {
  aspect-ratio: 1;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
  background: var(--surface);
  position: relative;
  overflow: hidden;
  transition: border-color 0.12s, background 0.12s;
}
.photo-slot:hover { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); }
.photo-slot.required {
  border-color: var(--brand-300, var(--accent));
}
.photo-slot.required::after {
  content: 'จำเป็น';
  position: absolute; top: 6px; right: 6px;
  font-size: 9px; font-weight: 600;
  background: var(--brand-600); color: #fff;
  padding: 2px 6px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.photo-slot.filled {
  border-style: solid;
  border-color: var(--success);
  padding: 0;
}
.photo-slot.filled::after { display: none; }
.photo-slot.filled img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.photo-slot.filled .remove-btn {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 2;
}
.photo-slot .slot-num {
  font-family: 'Poppins', sans-serif;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.radio-card {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--card);
  font-size: 13px; font-weight: 500;
  transition: border-color 0.12s, background 0.12s;
}
.radio-card:hover { border-color: var(--brand-500); }
.radio-card input[type="radio"] {
  accent-color: var(--brand-600);
  width: 16px; height: 16px;
}
.radio-card:has(input:checked) {
  border-color: var(--brand-600);
  background: var(--brand-50);
}

/* ============ Empty state ============ */
.empty {
  text-align: center; padding: 40px 20px;
  color: var(--muted);
}
.empty .icon { color: var(--muted-soft); margin-bottom: 8px; }
.empty p { margin: 4px 0; }

/* ============ Code ============ */
code {
  background: var(--surface-soft);
  color: var(--text-soft);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* ============ Demo / mock banner ============ */
.mock-banner {
  background: var(--brand-50);
  border-bottom: 1px solid var(--brand-100);
  padding: 7px 24px;
  font-size: 12px; color: var(--brand-700);
  text-align: center;
  font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.mock-banner a { color: var(--brand-700); text-decoration: underline; }

/* ============ Lucide icon sizing ============ */
[data-lucide], .lucide {
  width: 16px; height: 16px;
  stroke-width: 2;
  flex-shrink: 0;
}
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 28px; height: 28px; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    z-index: 50;
    box-shadow: 0 0 30px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-topbar { display: flex; }
  .container { padding: 18px 14px 60px; }
  .card { padding: 16px; }
  .stat .num, .stat-card .num { font-size: 22px; }
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }
}
