/* ================================================================
   NBTC AI Portal — Design System
   ================================================================ */

:root {
  /* Brand */
  --nbtc-blue: #003D7E;
  --nbtc-blue-700: #002B5C;
  --nbtc-blue-600: #004A99;
  --nbtc-blue-500: #1A5DA8;
  --nbtc-blue-100: #E8EFF7;
  --nbtc-blue-50:  #F4F8FC;

  --nbtc-gold: #C9A961;
  --nbtc-gold-600: #B89344;
  --nbtc-gold-100: #F8F1DF;

  /* Functional */
  --color-success: #10B981;
  --color-success-bg: #ECFDF5;
  --color-warning: #F59E0B;
  --color-warning-bg: #FFFBEB;
  --color-error: #EF4444;
  --color-error-bg: #FEF2F2;
  --color-info: #3B82F6;
  --color-info-bg: #EFF6FF;

  /* Neutral */
  --gray-900: #111827;
  --gray-800: #1F2937;
  --gray-700: #374151;
  --gray-600: #4B5563;
  --gray-500: #6B7280;
  --gray-400: #9CA3AF;
  --gray-300: #D1D5DB;
  --gray-200: #E5E7EB;
  --gray-100: #F3F4F6;
  --gray-50:  #F9FAFB;

  /* Spacing (8px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* Shadow */
  --sh-sm: 0 1px 2px rgba(0,0,0,0.05);
  --sh-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --sh-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --sh-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

/* ---------------- Base ---------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--nbtc-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Typography ---------------- */
.h1 { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.h2 { font-size: 22px; font-weight: 600; color: var(--gray-900); line-height: 1.3; }
.h3 { font-size: 18px; font-weight: 600; color: var(--gray-900); }
.h4 { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.text-body { font-size: 14px; color: var(--gray-700); }
.text-caption { font-size: 12px; color: var(--gray-500); }
.text-muted { color: var(--gray-500); }
.text-brand { color: var(--nbtc-blue); }

/* ---------------- Layout ---------------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "sidebar header" "sidebar main";
  height: 100vh;
}
.app-header { grid-area: header; background: white; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; padding: 0 var(--sp-5); gap: var(--sp-4); }
.app-sidebar { grid-area: sidebar; background: var(--nbtc-blue); color: white; padding: var(--sp-4) 0; overflow-y: auto; }
.app-main { grid-area: main; overflow-y: auto; padding: var(--sp-5); background: var(--gray-50); }

.brand-logo { display: flex; align-items: center; gap: 10px; padding: 0 var(--sp-4) var(--sp-4); }
.brand-mark { width: 40px; height: 40px; border-radius: var(--r-md); background: linear-gradient(135deg, var(--nbtc-gold), var(--nbtc-gold-600)); color: var(--nbtc-blue); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; }
.brand-mark-img { width: 40px; height: auto; flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)) brightness(1.05); object-fit: contain; }
.brand-text { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-text small { display: block; font-weight: 400; font-size: 11px; opacity: 0.8; }

.nav-section { padding: var(--sp-3) var(--sp-4) var(--sp-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.6; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px var(--sp-4); color: rgba(255,255,255,0.85); cursor: pointer; transition: all 0.15s; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,0.15); color: white; border-left: 3px solid var(--nbtc-gold); padding-left: calc(var(--sp-4) - 3px); }
.nav-item .icon { width: 18px; flex-shrink: 0; }

/* ---------------- Header ---------------- */
.header-search { flex: 1; max-width: 480px; position: relative; }
.header-search input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--gray-200); border-radius: var(--r-md); background: var(--gray-50); }
.header-search input:focus { outline: none; border-color: var(--nbtc-blue); background: white; }
.header-search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

.header-right { display: flex; align-items: center; gap: var(--sp-3); margin-left: auto; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; color: var(--gray-600); position: relative; }
.icon-btn:hover { background: var(--gray-100); }
.icon-btn .badge { position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; border-radius: var(--r-full); background: var(--color-error); color: white; font-size: 10px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: var(--r-full); cursor: pointer; }
.user-chip:hover { background: var(--gray-100); }
.avatar { width: 30px; height: 30px; border-radius: var(--r-full); background: linear-gradient(135deg, var(--nbtc-blue), var(--nbtc-blue-500)); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* ---------------- Buttons ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: var(--r-md); font-weight: 500; font-size: 14px; transition: all 0.15s; border: 1px solid transparent; }
.btn-primary { background: var(--nbtc-blue); color: white; }
.btn-primary:hover { background: var(--nbtc-blue-600); text-decoration: none; }
.btn-secondary { background: white; color: var(--gray-800); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); text-decoration: none; }
.btn-gold { background: var(--nbtc-gold); color: var(--nbtc-blue); }
.btn-gold:hover { background: var(--nbtc-gold-600); }
.btn-ghost { color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: var(--color-error); color: white; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------------- Cards ---------------- */
.card { background: white; border-radius: var(--r-lg); border: 1px solid var(--gray-200); }
.card-pad { padding: var(--sp-5); }
.card-header { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: var(--sp-5); }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: var(--sp-4); }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: var(--r-md); background: white; transition: border-color 0.15s; }
.form-control:focus { outline: none; border-color: var(--nbtc-blue); box-shadow: 0 0 0 3px var(--nbtc-blue-100); }
.form-help { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ---------------- Badges ---------------- */
.badge-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 500; }
.badge-success { background: var(--color-success-bg); color: #047857; }
.badge-warning { background: var(--color-warning-bg); color: #B45309; }
.badge-error { background: var(--color-error-bg); color: #B91C1C; }
.badge-info { background: var(--color-info-bg); color: #1D4ED8; }
.badge-brand { background: var(--nbtc-blue-100); color: var(--nbtc-blue); }
.badge-gold { background: var(--nbtc-gold-100); color: var(--nbtc-gold-600); }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }

/* ---------------- Tables ---------------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--gray-200); background: var(--gray-50); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.table tr:hover td { background: var(--gray-50); }

/* ---------------- Utilities ---------------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 24px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-brand { color: var(--nbtc-blue); }
.text-gold { color: var(--nbtc-gold-600); }
.text-success { color: #047857; }
.text-error { color: #B91C1C; }
.text-warning { color: #B45309; }
.bg-brand { background: var(--nbtc-blue); color: white; }
.bg-gray-50 { background: var(--gray-50); }
.bg-white { background: white; }
.rounded { border-radius: var(--r-md); }
.rounded-lg { border-radius: var(--r-lg); }
.rounded-full { border-radius: var(--r-full); }
.border { border: 1px solid var(--gray-200); }
.border-t { border-top: 1px solid var(--gray-200); }
.border-b { border-bottom: 1px solid var(--gray-200); }
.shadow-sm { box-shadow: var(--sh-sm); }
.shadow-md { box-shadow: var(--sh-md); }
.shadow-lg { box-shadow: var(--sh-lg); }
.cursor-pointer { cursor: pointer; }

/* ---------------- Animation ---------------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes blink { 50% { opacity: 0; } }
.fade-in { animation: fadeIn 0.3s ease-out; }
.pulse { animation: pulse 1.6s infinite; }
.cursor-blink::after { content: '▊'; animation: blink 1s infinite; color: var(--nbtc-blue); }

/* ---------------- Progress ---------------- */
.progress { height: 6px; background: var(--gray-200); border-radius: var(--r-full); overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--nbtc-blue), var(--nbtc-blue-500)); transition: width 0.3s ease; }

/* ---------------- Status Dot ---------------- */
.dot { width: 8px; height: 8px; border-radius: var(--r-full); display: inline-block; }
.dot-green { background: var(--color-success); }
.dot-amber { background: var(--color-warning); }
.dot-red { background: var(--color-error); }
.dot-blue { background: var(--color-info); }

/* ---------------- Standalone (when opened directly) ---------------- */
body.standalone {
  padding: 0;
  margin: 0;
}

/* Frame size for board view rendering */
.frame-web { width: 1280px; min-height: 800px; }
.frame-mobile { width: 360px; min-height: 720px; border-radius: 32px; overflow: hidden; box-shadow: var(--sh-xl); border: 8px solid #1F2937; background: white; }

/* ---------------- Hide all scrollbars (visual only — scroll still works) ---------------- */
* {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE / old Edge */
}
*::-webkit-scrollbar {
  display: none;                /* Chrome, Safari, Edge */
  width: 0;
  height: 0;
}

/* Pages that wrap content in .phone (mobile screens): lock body to viewport — no body scroll */
body:has(> .phone) {
  overflow: hidden;
  height: 100vh;
}

/* ---------------- Toast Notification ---------------- */
.toast-host {
  position: fixed; top: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: white;
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--nbtc-blue);
  border-radius: var(--r-md);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 420px;
  box-shadow: var(--sh-lg);
  font-size: 13px;
  color: var(--gray-800);
  display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in 0.25s ease-out;
  pointer-events: auto;
}
.toast.success { border-left-color: var(--color-success); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.error   { border-left-color: var(--color-error); }
.toast.info    { border-left-color: var(--nbtc-blue); }
.toast .toast-ic { font-size: 18px; line-height: 1; flex-shrink: 0; }
.toast .toast-body { flex: 1; line-height: 1.5; }
.toast .toast-title { font-weight: 600; color: var(--gray-900); margin-bottom: 2px; }
.toast.fade-out { animation: toast-out 0.25s ease-in forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ---------------- Demo Home (floating button — always reachable during live demo) ---------------- */
.demo-home {
  position: fixed; right: 16px; bottom: 16px;
  z-index: 9998;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: rgba(0,61,126,0.92);
  color: white;
  border-radius: var(--r-full);
  font-size: 12px; font-weight: 500;
  box-shadow: var(--sh-md);
  backdrop-filter: blur(8px);
  text-decoration: none;
  transition: all 0.15s;
}
.demo-home:hover { background: var(--nbtc-blue); text-decoration: none; color: white; transform: translateY(-1px); }
.demo-home .dh-ic { font-size: 13px; }
