/* ═══════════════════════════════════════════════════════════════════
   ITS ACCOUNT — Royal Blue Minimal Design System
   Based on: windsurf-design-system-prompt.md
   Stack: Node.js + Sails.js + plain CSS + CSS Variables
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;500;600;700&display=swap');

/* ── 1) Design Tokens — Colors ── */
:root {
  /* Brand — Royal Blue */
  --primary:        #0026E1;
  --primary-hover:  #001FBE;
  --primary-active: #0019A3;
  --primary-soft:   #EEF1FD;
  --primary-border: #C7D0F5;

  /* Background & Surface */
  --bg-page:     #F4F5FB;
  --bg-gradient: linear-gradient(135deg, #DAE1EF 0%, #C9CFE6 50%, #AEB1D5 100%);
  --surface:     #FFFFFF;
  --surface-alt: #F7F8FC;

  /* Text */
  --text-primary:   #0A0818;
  --text-secondary: #3D3E52;
  --text-muted:     #6B6C82;
  --text-on-primary:#FFFFFF;

  /* Backward-compatible aliases (used by legacy inline styles) */
  --text-main:   var(--text-primary);
  --text-sub:    var(--text-secondary);
  --card:        var(--surface);
  --bg:          var(--bg-page);
  --radius:      var(--radius-md);
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --shadow-xs:   0 1px 3px rgba(17,15,35,0.04);
  --shadow-sm:   0 2px 8px rgba(17,15,35,0.04);
  --shadow-md:   0 4px 16px rgba(17,15,35,0.06);
  --shadow-lg:   0 12px 32px rgba(17,15,35,0.10);
  --ok:          var(--success);
  --ok-light:    var(--success-bg);
  --warn:        var(--warning);
  --warn-light:  var(--warning-bg);
  --danger:      var(--danger);
  --danger-light:var(--danger-bg);
  --sel-bg:      var(--primary-soft);
  --hover-bg:    var(--surface-alt);

  /* Border & Divider */
  --border:        #E8E9F1;
  --border-strong: #D8D9E6;
  --divider:       #F0F1F7;

  /* Status — Success */
  --success:       #00C875;
  --success-hover: #00A060;
  --success-bg:    #DDFBEC;
  --success-soft:  #F2FDF8;

  /* Status — In Progress / Info (purple) */
  --info:         #6E3AFF;
  --info-bg:      #EFEBFF;

  /* Status — Danger */
  --danger:       #F43F5E;
  --danger-bg:    #FFEBF0;
  --danger-hover: #DB2950;

  /* Status — Warning */
  --warning:       #FFA800;
  --warning-hover: #E09500;
  --warning-bg:    #FFF4D6;

  /* Tag/Chip colors */
  --tag-orange-bg:#FFF1E3; --tag-orange:#E07B12;
  --tag-pink-bg:  #FDEBF8; --tag-pink:  #D9319A;
  --tag-blue-bg:  #E7F3FE; --tag-blue:  #2380D6;
  --tag-green-bg: #E5F9EE; --tag-green: #1E9E5C;

  /* Misc */
  --pill-neutral-bg: #EFF2F6;
  --online-dot:      #2BC553;

  /* Radius & Shadow */
  --radius-card:  20px;
  --radius-btn:   10px;
  --radius-pill:  999px;
  --radius-input: 10px;
  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --shadow-card:  0 10px 30px rgba(17, 15, 35, 0.06);
  --shadow-modal: 0 24px 60px rgba(17, 15, 35, 0.14);
  --shadow-sm:    0 2px 8px rgba(17, 15, 35, 0.04);
  --ring-focus:   0 0 0 3px rgba(0, 38, 225, 0.18);

  /* Typography scale (compact — notebook-friendly) */
  --fs-display: 16px;
  --fs-h2:      15px;
  --fs-h3:      14px;
  --fs-body:    13px;
  --fs-small:   12px;
  --fs-caption: 11px;
  --fs-badge:   11px;
  --fs-tiny:    10px;
  --fs-micro:   10px;
}

/* ── 2) Typography ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Poppins', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
}

h1, h2, h3, .heading {
  font-family: 'Poppins', 'Sarabun', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
}

h1 { font-size: var(--fs-display); line-height: 1.2; }
h2 { font-size: var(--fs-h2);      line-height: 1.3; }
h3 { font-size: var(--fs-h3);      line-height: 1.4; }

.subtitle, .text-muted { color: var(--text-muted); font-size: var(--fs-caption); }
.text-secondary { color: var(--text-secondary); font-size: var(--fs-small); }

/* ── 3) Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  font: 500 12px 'Poppins', 'TH Sarabun New', sans-serif;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: all .18s cubic-bezier(0.4,0,0.2,1);
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover    { border-color: var(--border-strong); color: var(--text-primary); background: var(--surface-alt); }
.btn:active   { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,38,225,0.12);
}
.btn-primary:hover  { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; box-shadow: 0 2px 8px rgba(0,38,225,0.2); }
.btn-primary:active { background: var(--primary-active); border-color: var(--primary-active); box-shadow: 0 1px 2px rgba(0,38,225,0.1); }
.btn-primary:focus-visible { box-shadow: var(--ring-focus); outline: none; }

.btn-secondary {
  background: #fff;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-alt); color: var(--text-primary); border-color: var(--text-muted); }

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

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover { background: var(--danger-bg); border-color: #fca5a5; color: var(--danger); }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  box-shadow: 0 1px 3px rgba(0,200,117,0.12);
}
.btn-success:hover { background: var(--success-hover); border-color: var(--success-hover); color: #fff; box-shadow: 0 2px 8px rgba(0,200,117,0.2); }

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
  box-shadow: 0 1px 3px rgba(255,168,0,0.12);
}
.btn-warning:hover { background: var(--warning-hover); border-color: var(--warning-hover); color: #fff; box-shadow: 0 2px 8px rgba(255,168,0,0.2); }

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--surface-alt); color: var(--primary); }

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 7px;
}

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 4) Tables ── */
.table-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
}
.table-card .table-title {
  font: 600 var(--fs-h2) 'Poppins', 'Sarabun', sans-serif;
  margin-bottom: 4px;
}
.table-card .table-subtitle {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-bottom: 16px;
}
.table-card .table-subtitle a { color: var(--info); text-decoration: none; }

/* Standard data table */
table.ds-table {
  width: 100%;
  border-collapse: collapse;
}
.ds-table thead th {
  text-align: left;
  font: 600 var(--fs-caption) 'Poppins', 'Sarabun', sans-serif;
  color: var(--text-muted);
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ds-table tbody td {
  padding: 8px 10px;
  font: var(--fs-body) 'Poppins', 'Sarabun', sans-serif;
  color: var(--text-primary);
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
/* สถานะ DB column - smaller font */
.ds-table thead th:nth-child(7),
.ds-table tbody td:nth-child(7) {
  font-size: 12px;
}
.ds-table tbody tr:last-child td { border-bottom: none; }
.ds-table tbody tr:hover { background: var(--primary-soft); }
.ds-table tbody tr { transition: background 0.15s ease; }

/* Compact table variant */
table.ds-table-compact thead th { padding: 6px 10px; }
table.ds-table-compact tbody td { padding: 6px 10px; }

/* Sticky header */
.ds-table thead th.sticky {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  z-index: 10;
}

/* Sort indicator */
.ds-table th .sort { margin-left: 6px; color: var(--text-muted); cursor: pointer; }
.ds-table th .sort:hover { color: var(--primary); }

/* ── 5) Badge / Pill ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font: 600 var(--fs-badge) 'Poppins', 'Sarabun', sans-serif;
}
.badge svg { width: 14px; height: 14px; }

.badge-success    { background: var(--success-bg); color: var(--success); }
.badge-info       { background: var(--info-bg);    color: var(--info); }
.badge-danger     { background: var(--danger-bg);  color: var(--danger); }
.badge-warning    { background: var(--warning-bg); color: var(--warning); }
.badge-neutral    { background: var(--pill-neutral-bg); color: var(--text-secondary); }

/* Small badge variant */
.badge-sm {
  padding: 3px 8px;
  font-size: 11px;
}

/* Status dot inside badge */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.success   { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.status-dot.info      { background: var(--info);      box-shadow: 0 0 0 3px var(--info-bg); }
.status-dot.danger    { background: var(--danger);    box-shadow: 0 0 0 3px var(--danger-bg); }
.status-dot.warning   { background: var(--warning);  box-shadow: 0 0 0 3px var(--warning-bg); }
.status-dot.pending   { background: var(--text-muted); }
.status-dot.processing{ background: var(--warning); }
.status-dot.synced    { background: var(--success); }

/* ── 6) Input / Select / Search ── */
.input, .select {
  height: 36px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-input);
  background: #fff;
  font: 400 var(--fs-body) 'Poppins', 'Sarabun', sans-serif;
  color: var(--text-primary);
  transition: all .18s ease;
  font-family: inherit;
}
.input::placeholder { color: var(--text-muted); }
.input:hover, .select:hover { border-color: var(--text-muted); }
.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: var(--ring-focus);
  outline: none;
}

.search-wrap { position: relative; }
.search-input {
  padding-left: 40px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A8BA1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 14px center;
}

.select { cursor: pointer; appearance: none; }

/* ── 7) Cards & Modal ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
}

.card-sm {
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.card-header-band {
  background: var(--primary-soft);
  border-radius: 14px;
  padding: 12px 16px;
}

.modal {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-modal);
}

/* ── 8) Tabs ── */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
  font-family: inherit;
}
.tab:hover { background: var(--surface-alt); border-color: var(--border-strong); color: var(--text-primary); }
.tab.active {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,38,225,0.15);
}
.tab .count {
  background: rgba(255,255,255,0.2);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
}

/* ── 9) Page Layout ── */
.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 20px 24px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
}
.page-head h1 {
  font: 600 var(--fs-display) 'Poppins', 'Sarabun', sans-serif;
  margin: 0;
  line-height: 1.2;
}
.page-head .sub {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

/* ── 10) Token Bar ── */
.token-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: var(--fs-small);
}
.token-bar.no-token  { background: var(--warning-bg); border-color: #fde8b8; }
.token-bar.has-token { background: var(--success-bg);  border-color: #bbf7d0; }
.token-val {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 11px;
  color: var(--text-secondary);
}
.token-exp { font-size: 11px; color: var(--text-muted); }

/* ── 11) Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 0 16px;
}
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── 12) Selection Bar ── */
.selection-bar {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 14px;
  font-size: var(--fs-small);
}
.selection-bar.show { display: flex; }

/* ── 13) Log Panel ── */
.log-panel {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-top: 16px;
  max-height: 240px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
}
.log-line { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.log-line:last-child { border-bottom: none; }
.log-ts { color: #94a3b8; margin-right: 8px; }
.log-ok { color: #4ade80; }
.log-err { color: #f87171; }
.log-info { color: #60a5fa; }
.log-warn { color: #fbbf24; }

/* ── 14) Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  font-size: var(--fs-small);
  font-weight: 600;
  color: white;
  box-shadow: var(--shadow-modal);
  transform: translateY(12px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

/* ── 15) Empty State ── */
.empty-state {
  text-align: center;
  padding: 36px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.35; margin-bottom: 14px; }

/* ── 16) Progress Ring ── */
.progress-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) var(--pct), var(--border) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.progress-ring-inner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── 17) Spinners ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ds-spin 0.7s linear infinite;
}
.spinner-dark {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ds-spin 0.7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ── 18) Stepper ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.step.active .step-circle {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,38,225,0.1);
}
.step.completed .step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,38,225,0.2);
}
.step-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.step.active .step-label {
  color: var(--text-primary);
  font-weight: 600;
}
.step-line {
  width: 24px;
  height: 1px;
  background: var(--divider);
}

/* ── 19) Utilities ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'SF Mono', 'Consolas', 'Monaco', monospace; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

/* Row highlight states */
.row-success { background: var(--success-bg) !important; }
.row-danger  { background: var(--danger-bg) !important; }
.row-warning { background: var(--warning-bg) !important; }
.row-info    { background: var(--info-bg) !important; }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
