/* =========================================================================
   Barter Connect — HR Application & DISC
   CI palette: electric blue #1C4DFF, golden yellow #FFC629
   ========================================================================= */
:root {
  --brand: #1C4DFF;          /* electric blue */
  --brand-2: #3A6BFF;
  --brand-dark: #1438C2;
  --brand-ink: #0c1f66;
  --accent: #FFC629;         /* golden yellow */
  --accent-dark: #F0B400;

  --bg: #f4f7ff;
  --card: #ffffff;
  --line: #e4e9f5;
  --line-strong: #cdd7f0;
  --text: #16203a;
  --muted: #6b768f;
  --ok: #16a34a;
  --err: #e23d3d;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(28, 77, 255, .08);
  --shadow-sm: 0 2px 10px rgba(20, 31, 58, .06);
  --ring: 0 0 0 4px rgba(28, 77, 255, .16);

  --font: "Segoe UI Variable", "Segoe UI", "Sarabun", "Leelawadee UI", "Noto Sans Thai", system-ui, Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(28,77,255,.07), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, rgba(255,198,41,.10), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }

/* ---- Brand lockup ---- */
.brandmark { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-icon { width: 40px; height: 40px; display: block; }
.wordmark { font-weight: 900; letter-spacing: -.01em; line-height: 1; font-size: 22px; }
.wordmark .w-barter { color: var(--brand); }
.wordmark .w-co, .wordmark .w-ect { color: var(--brand); }
.wordmark .w-nn { color: var(--accent); }
.wordmark .w-connect { text-transform: uppercase; letter-spacing: .01em; }

/* ---- Top bar ---- */
.topbar {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  padding: 13px 22px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 4px 18px rgba(20,56,194,.25);
}
.topbar .titles h1 { font-size: 16px; margin: 0; font-weight: 800; color: #fff; line-height: 1.1; }
.topbar .titles small { display: block; font-weight: 500; color: rgba(255,255,255,.82); font-size: 12px; margin-top: 2px;}
.topbar .spacer { flex: 1; }
.topbar a, .topbar button {
  color: #fff; text-decoration: none; font-size: 14px; font-weight: 700;
  background: rgba(255,255,255,.16); border: 0; padding: 9px 16px;
  border-radius: 999px; cursor: pointer; font-family: inherit; transition: .15s;
}
.topbar a:hover, .topbar button:hover { background: rgba(255,255,255,.28); }
.topbar a.solid, .topbar button.solid { background: #fff; color: var(--brand); }
.topbar a.solid:hover, .topbar button.solid:hover { background: var(--accent); color: #1a1a1a; }

.brand-logo { height: 38px; display: block; }

/* ---- Layout ---- */
.wrap { max-width: 1000px; margin: 26px auto; padding: 0 18px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow); margin-bottom: 22px;
}

/* ---- Stepper ---- */
.steps { display: flex; gap: 12px; margin: 22px auto 6px; max-width: 1000px; padding: 0 18px; }
.step {
  flex: 1; display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 16px;
  box-shadow: var(--shadow-sm); transition: .2s;
}
.step .num {
  width: 30px; height: 30px; border-radius: 50%; background: #eef1fb; color: var(--muted);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; transition: .2s;
}
.step.active { border-color: var(--brand); box-shadow: 0 6px 18px rgba(28,77,255,.15); }
.step.active .num { background: var(--brand); color: #fff; }
.step.done .num { background: var(--accent); color: #1a1a1a; }
.step b { font-size: 14px; font-weight: 800; }
.step span { display: block; font-size: 11px; color: var(--muted); }

/* ---- Sections / fields ---- */
.section-title {
  font-size: 17px; font-weight: 800; color: var(--brand-ink);
  display: flex; align-items: center; gap: 10px; margin: 30px 0 14px;
}
.section-title::before {
  content: ""; width: 8px; height: 22px; border-radius: 6px;
  background: linear-gradient(var(--brand), var(--brand-2));
}
.section-title:first-child { margin-top: 0; }

.grid { display: grid; gap: 14px 18px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 700; color: var(--text); }
.field label .en { color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 11px 13px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 14.5px; font-family: inherit; background: #fff; color: var(--text); transition: .15s;
}
.field input::placeholder, .field textarea::placeholder { color: #aab2c5; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--brand-2); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
.checks { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.checks label {
  font-weight: 600; display: inline-flex; gap: 8px; align-items: center; font-size: 14px;
  background: #f5f7ff; border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; transition: .15s;
}
.checks label:hover { border-color: var(--brand-2); }
.checks input { accent-color: var(--brand); }
.checks label:has(input:checked) { background: rgba(28,77,255,.10); border-color: var(--brand); color: var(--brand-ink); }

/* photo */
.photo-box { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.photo-preview {
  width: 120px; height: 152px; border: 2.5px dashed var(--line-strong); border-radius: 14px;
  display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center;
  overflow: hidden; background: #f7f9ff; font-weight: 600;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
input[type=file] { font-family: inherit; }
input[type=file]::file-selector-button {
  font-family: inherit; font-weight: 700; border: 0; background: var(--brand); color: #fff;
  padding: 9px 16px; border-radius: 999px; margin-right: 12px; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--brand-dark); }

/* tables */
table.grid-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); }
table.grid-table th, table.grid-table td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; }
table.grid-table tr > *:last-child { border-right: 0; }
table.grid-table tbody tr:last-child > * { border-bottom: 0; }
table.grid-table th { background: #f3f6ff; font-weight: 800; text-align: left; color: var(--brand-ink); }
table.grid-table input, table.grid-table select { width: 100%; border: 1px solid transparent; padding: 7px 6px; font-size: 13px; border-radius: 8px; font-family: inherit; background: transparent; }
table.grid-table input:focus, table.grid-table select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); background:#fff; }
.btn-row { margin-top: 10px; }

/* buttons */
.btn {
  background: var(--brand); color: #fff; border: 0; padding: 12px 24px;
  border-radius: 999px; font-size: 15px; font-weight: 800; cursor: pointer; font-family: inherit;
  transition: .15s; box-shadow: 0 6px 16px rgba(28,77,255,.22);
}
.btn:hover { background: var(--brand-dark); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.secondary { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); box-shadow: none; }
.btn.secondary:hover { background: #f0f4ff; }
.btn.accent { background: var(--accent); color: #1a1a1a; box-shadow: 0 6px 16px rgba(255,198,41,.3); }
.btn.accent:hover { background: var(--accent-dark); }
.btn.ghost { background: #eef1fb; color: var(--text); box-shadow: none; }
.btn.ghost:hover { background: #e2e7f7; }
.btn.danger { background: var(--err); box-shadow: none; }
.btn.small { padding: 7px 14px; font-size: 13px; box-shadow: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; }

.note { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }
.required { color: var(--accent-dark); }

/* ---- DISC test ---- */
.disc-intro {
  background: linear-gradient(135deg, rgba(28,77,255,.06), rgba(255,198,41,.10));
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; font-size: 14.5px;
}
.disc-row { border: 1.5px solid var(--line); border-radius: 14px; margin-bottom: 14px; overflow: hidden; transition: .2s; }
.disc-row.complete { border-color: var(--brand); }
.disc-row.row-bad { border-color: var(--err); box-shadow: 0 0 0 3px rgba(226,61,61,.12); }
.disc-row .rh { background: #f3f6ff; padding: 8px 14px; font-size: 13px; color: var(--brand-ink); font-weight: 700; display:flex; justify-content: space-between; align-items: center; }
.disc-row .rh .ok { color: var(--ok); font-weight: 800; }
.disc-cells { display: grid; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .disc-cells { grid-template-columns: 1fr 1fr; } }
.disc-cell { padding: 14px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); transition: .15s; }
.disc-cell:first-child { border-left: 0; }
.disc-cell.filled { background: #f5f8ff; }
.disc-word { font-weight: 800; font-size: 14.5px; }
.disc-word .th { display:block; font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 2px; }
.disc-cell select {
  margin-top: 10px; width: 74px; padding: 9px; border-radius: 10px; border:1.5px solid var(--line-strong);
  font-size: 16px; font-weight: 800; font-family: inherit; color: var(--brand-ink); cursor: pointer; background:#fff;
}
.disc-cell select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.disc-cell.filled select { border-color: var(--brand); color: var(--brand); }

/* totals bar */
.disc-live {
  position: sticky; bottom: 0; background: #ffffff;
  border-top: 2px solid var(--brand); padding: 12px 16px; display:flex; gap: 16px; flex-wrap: wrap;
  justify-content:center; align-items: center; font-size:14px; font-weight: 700; border-radius: 0 0 14px 14px;
}
.disc-live .chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: #f3f6ff; }
.disc-live b { font-size: 16px; }

/* ---- Admin ---- */
.login-wrap { max-width: 400px; margin: 7vh auto; }
.login-hero { text-align: center; margin-bottom: 18px; }
.login-hero .brand-icon { width: 56px; height: 56px; margin: 0 auto; }
.candidates { width: 100%; border-collapse: separate; border-spacing: 0; background:#fff; border-radius: 14px; overflow: hidden; }
.candidates th, .candidates td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.candidates th { background: #f3f6ff; color: var(--brand-ink); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; }
.candidates tbody tr { transition: .12s; }
.candidates tbody tr:hover td { background: #f7f9ff; }
.candidates tbody tr:last-child td { border-bottom: 0; }
.pill { display:inline-block; min-width: 26px; text-align:center; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 900; color:#fff; }
.toolbar { display:flex; gap:12px; align-items:center; margin-bottom: 16px; flex-wrap: wrap;}
.toolbar input[type=search]{ padding: 11px 16px; border:1.5px solid var(--line-strong); border-radius:999px; min-width: 260px; font-family: inherit; font-size: 14px; }
.toolbar input[type=search]:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 28px; font-weight: 900; color: var(--brand); line-height: 1; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 6px; font-weight: 600; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color:#fff; padding: 13px 22px; border-radius: 999px; font-size:14px; font-weight: 700; z-index: 99;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.msg { padding: 12px 16px; border-radius: 12px; font-size: 14px; margin-top: 12px; font-weight: 600; }
.msg.err { background: #fdeaea; color: var(--err); }
.msg.ok { background: #ecfaf0; color: var(--ok); }

/* table horizontal-scroll wrapper */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
.table-scroll table.grid-table { min-width: 560px; }

/* =========================================================================
   RESPONSIVE — Mobile (≤ 640px)
   ========================================================================= */
@media (max-width: 640px) {

  /* --- Topbar --- */
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar img[alt="Barter Connect"] { height: 32px; }
  .topbar .titles h1 { font-size: 14px; }
  .topbar .titles small { font-size: 11px; }
  .topbar a, .topbar button { padding: 8px 12px; font-size: 13px; }

  /* --- Stepper --- */
  .steps { padding: 0 12px; gap: 6px; margin: 14px auto 4px; }
  .step { padding: 9px 10px; gap: 8px; border-radius: 12px; }
  .step .num { width: 26px; height: 26px; font-size: 12px; }
  .step b { font-size: 12px; }
  .step span { font-size: 10px; }

  /* --- Layout --- */
  .wrap { padding: 0 10px; margin: 12px auto; }
  .card { padding: 16px 14px; border-radius: 14px; }

  /* --- Section titles --- */
  .section-title { font-size: 15px; margin: 22px 0 12px; }

  /* --- Grid overrides (all single column on mobile) --- */
  .g2, .g3, .g4 { grid-template-columns: 1fr !important; }

  /* --- Inputs — 16px prevents iOS auto-zoom --- */
  .field input, .field select, .field textarea {
    font-size: 16px;
    padding: 13px 14px;
    min-height: 48px;
    border-radius: 10px;
  }
  .field label { font-size: 14px; }

  /* --- File input --- */
  input[type=file] { font-size: 14px; }
  input[type=file]::file-selector-button { padding: 10px 14px; font-size: 14px; }

  /* --- Photo box --- */
  .photo-box { flex-direction: column; align-items: flex-start; gap: 14px; }
  .photo-preview { width: 100px; height: 130px; }

  /* --- Radio / checkbox pills --- */
  .checks { gap: 8px; }
  .checks label {
    min-height: 44px;
    padding: 9px 14px;
    font-size: 14px;
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }

  /* --- Table scroll hints --- */
  .table-scroll::before {
    content: "← เลื่อนซ้าย-ขวาได้ / Scroll →";
    display: block;
    font-size: 11px;
    color: var(--muted);
    padding: 4px 2px 6px;
  }
  .table-scroll table.grid-table { min-width: 520px; }
  table.grid-table th, table.grid-table td { padding: 8px 7px; }
  table.grid-table input, table.grid-table select { font-size: 15px; min-height: 40px; }

  /* --- Actions buttons --- */
  .actions { flex-direction: column-reverse; gap: 10px; }
  .actions .btn { width: 100%; padding: 14px; font-size: 16px; text-align: center; }

  /* --- Add-row buttons --- */
  .btn-row .btn { width: 100%; padding: 11px; font-size: 14px; }

  /* ---- DISC test ---- */
  .disc-intro { font-size: 14px; padding: 12px 14px; }

  /* 2×2 grid on mobile */
  .disc-cells { grid-template-columns: 1fr 1fr !important; }

  .disc-cell {
    padding: 12px 10px;
    border-left: 1px solid var(--line) !important; /* restore all borders in 2-col */
  }
  .disc-cells .disc-cell:nth-child(odd) { border-left: 0 !important; }

  .disc-word { font-size: 13.5px; }
  .disc-word .th { font-size: 11.5px; }

  /* Full-width dropdown, easy to tap */
  .disc-cell select {
    width: 100%;
    font-size: 18px;
    padding: 10px 8px;
    min-height: 48px;
    margin-top: 8px;
    border-radius: 10px;
    border-width: 2px;
  }

  /* Live totals bar — compact */
  .disc-live {
    gap: 6px;
    padding: 10px 10px;
    font-size: 13px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .disc-live .chip { padding: 4px 10px; }
  .disc-live b { font-size: 15px; }

  /* Submit / back buttons full width */
  #submitAll, #backStep1 { width: 100%; padding: 15px; font-size: 16px; }

  /* --- Admin search bar --- */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input[type=search] { min-width: unset; width: 100%; }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .n { font-size: 22px; }

  /* Login form */
  .login-wrap { margin: 4vh auto; }
}
