/* ============================================================
   PODER HR — ศูนย์ประเมินพนักงาน
   Styles ผสานจากไฟล์ต้นฉบับทั้ง 3 ชุด (ฟอนต์ Sarabun, โทน indigo, dark mode)
   ============================================================ */

:root {
  --ink-900: #0b1220;
  --ink-800: #111c34;
  --ink-700: #1c2b4a;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca; /* ปุ่ม primary ตอน hover */
  --aqua-500: #06b6d4;
  --aqua-600: #0891b2;
  --aqua-700: #0e7490; /* ปุ่ม aqua — คอนทราสต์ขาว/ฟ้าชัดเจน */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Sarabun', sans-serif;
  min-height: 100vh;
}

.font-mono, code, pre { font-family: 'JetBrains Mono', monospace; }

/* ---------- Layout helpers ---------- */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 1rem; }

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  box-shadow: 0 10px 30px -12px rgba(15, 23, 42, .12);
}

.card-dark {
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  color: #e2e8f0;
  border-radius: 1.25rem;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .6);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #0f172a;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: .75rem;
  padding: .65rem 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, opacity .15s ease;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 3px solid rgba(99,102,241,.45); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; filter: grayscale(.15); }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 8px 18px -8px rgba(79,70,229,.7); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-aqua { background: var(--aqua-700); color: #fff; box-shadow: 0 8px 18px -8px rgba(8,145,178,.7); }
.btn-aqua:hover:not(:disabled) { background: #155e75; }
.btn-ghost { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.btn-ghost:hover:not(:disabled) { background: #e2e8f0; color: #0f172a; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: .4rem .7rem; font-size: .8rem; border-radius: .55rem; }

/* ---------- Inputs ---------- */
.field { width: 100%; border: 1px solid #cbd5e1; border-radius: .75rem; padding: .7rem .9rem; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.field:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.field-dark { background: var(--ink-900); border-color: var(--ink-700); color: #f8fafc; }
.field-dark:focus { border-color: var(--aqua-500); box-shadow: 0 0 0 3px rgba(6,182,212,.18); }

label.lbl { display: block; font-size: .85rem; font-weight: 700; color: #475569; margin-bottom: .35rem; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; font-size: .75rem; font-weight: 800; padding: .2rem .6rem; }
.badge-pass { background: #dcfce7; color: #166534; }
.badge-fail { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0e7ff; color: #3730a3; }
.badge-warn { background: #fef3c7; color: #92400e; }

/* ---------- Table ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: .7rem .8rem; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
.tbl td { padding: .7rem .8rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tbody tr:hover { background: #f8fafc; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #0b1220 0%, #1c2b4a 55%, #3730a3 100%);
  border-radius: 1.5rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute; right: -80px; top: -100px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34,211,238,.35), transparent 70%);
  pointer-events: none;
}

/* ---------- Test cards ---------- */
.test-card { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.test-card:hover { transform: translateY(-4px); box-shadow: 0 20px 35px -18px rgba(15,23,42,.3); border-color: #c7d2fe; }

/* ---------- Quiz ---------- */
.quiz-choice {
  width: 46px; height: 46px; border-radius: 999px; border: 2px solid #cbd5e1;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem;
  background: #fff; color: #334155; transition: all .15s ease; cursor: pointer;
}
.quiz-choice:hover { border-color: var(--brand-500); background: #eef2ff; transform: translateY(-2px); }
.quiz-choice:disabled { cursor: default; opacity: .75; transform: none; }
.quiz-choice.sel { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }

.strength-card { border-bottom: 1px solid #e2e8f0; padding: .9rem 0; cursor: pointer; }
.strength-card .details { max-height: 0; opacity: 0; overflow: hidden; transition: all .4s ease; }
.strength-card.expanded .details { max-height: 500px; opacity: 1; padding-top: .75rem; }

/* ---------- Typing ---------- */
.typing-target span { transition: color .08s linear, background-color .08s linear; }
.typing-caret { background: var(--aqua-500); color: #082f49; border-radius: 2px; }
.typing-ok { color: #34d399; background: rgba(52,211,153,.12); }
.typing-bad { color: #f87171; background: rgba(248,113,113,.14); }
.typing-idle { color: #64748b; }

/* ---------- Spreadsheet ---------- */
.sheet-grid { border-collapse: collapse; width: 100%; font-family: 'JetBrains Mono', monospace; }
.sheet-grid th, .sheet-grid td { border: 1px solid #cbd5e1; padding: .55rem .7rem; text-align: center; }
.sheet-grid th { background: #e2e8f0; color: #334155; font-weight: 700; }
.sheet-grid td.label { text-align: left; font-family: 'Sarabun', sans-serif; font-weight: 600; }
.sheet-grid td.given { background: #f8fafc; color: #475569; }
.sheet-grid td.editable { background: #fef9c3; padding: 0; }
.sheet-grid td.editable input { width: 100%; border: 0; background: transparent; padding: .55rem .7rem; text-align: center; outline: none; font-family: 'JetBrains Mono', monospace; color: #854d0e; font-weight: 700; }
.sheet-grid td.editable input:focus { background: #fef08a; box-shadow: inset 0 0 0 2px #eab308; }
.sheet-grid tr.total td { font-weight: 700; background: #f1f5f9; }
.sheet-grid tr.total td.editable { background: #fef9c3; }
.cell-ok { background: #dcfce7 !important; color: #166534 !important; }
.cell-bad { background: #fee2e2 !important; color: #991b1b !important; }

/* ---------- Excel-like grid ---------- */
.xl-wrap { background: #fff; }
.xl-tabs {
  display: flex; gap: 2px; overflow-x: auto; background: #f8fafc;
  border-bottom: 1px solid #cbd5e1; padding: 6px 8px 0; white-space: nowrap;
}
.xl-tabs span { font-size: .78rem; font-weight: 600; color: #475569; padding: 5px 10px; border-radius: 6px 6px 0 0; }
.xl-tabs span.active { background: #fff; color: var(--brand-700); border: 1px solid #cbd5e1; border-bottom-color: #fff; }
.xl-ribbon {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  background: #fff; border-bottom: 1px solid #e2e8f0; padding: 6px 10px; font-size: .8rem; color: #475569;
}
.xl-ribbon .rb { padding: 4px 7px; border-radius: 5px; }
.xl-ribbon .rb-btn { padding: 4px 9px; border-radius: 6px; border: 1px solid #cbd5e1; background: #f8fafc; font-weight: 700; cursor: pointer; color: var(--brand-700); }
.xl-ribbon .rb-btn:hover { background: #eef2ff; }
.xl-ribbon .rb-sep { width: 1px; height: 20px; background: #e2e8f0; margin: 0 4px; }
.fx-bar { display: flex; align-items: center; gap: 8px; background: #f1f5f9; border-bottom: 1px solid #cbd5e1; padding: 4px 8px; }
.fx-name { min-width: 52px; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: .78rem; font-weight: 700; color: #334155; border-right: 1px solid #cbd5e1; padding-right: 6px; }
.fx-fx { font-style: italic; font-weight: 800; color: #64748b; font-family: Georgia, serif; }
.fx-input { flex: 1; border: 0; outline: 0; background: transparent; font-family: 'JetBrains Mono', monospace; font-size: .85rem; color: #1e293b; padding: 4px; }
.fx-input:focus { background: #fff; box-shadow: inset 0 0 0 1px var(--brand-500); }
.xl-scroll { overflow: auto; max-height: 460px; }
.xl-grid { border-collapse: collapse; table-layout: fixed; font-family: 'JetBrains Mono', monospace; font-size: .78rem; }
.xl-grid th { position: sticky; top: 0; z-index: 2; background: #e2e8f0; color: #475569; font-weight: 700; border: 1px solid #cbd5e1; width: 32px; height: 24px; text-align: center; font-size: .7rem; }
.xl-grid th.corner { left: 0; z-index: 3; width: 38px; }
.xl-grid thead th:not(.corner) { width: 92px; }
.xl-grid tbody th { position: sticky; left: 0; z-index: 1; background: #e2e8f0; }
.xl-grid td { border: 1px solid #d7dee8; padding: 0; height: 28px; width: 92px; }
.xl-cell { display: block; width: 100%; height: 28px; border: 0; outline: 0; background: #fff; padding: 4px 6px; font-family: 'JetBrains Mono', monospace; font-size: .78rem; color: #1e293b; white-space: nowrap; overflow: hidden; }
.xl-cell.given { background: #f1f5f9; color: #475569; cursor: default; }
.xl-cell.answer { background: #fef9c3; color: #854d0e; font-weight: 700; }
.xl-cell.selected { box-shadow: inset 0 0 0 2px var(--brand-500); background: #eef2ff; }
.xl-cell.answer.selected { background: #fde68a; }
.xl-cell.editing { box-shadow: inset 0 0 0 2px var(--brand-600); background: #fff; padding: 0; }
.xl-cell.editing.xl-edit { padding: 4px 6px; }
.xl-cell:not(.given) { cursor: cell; }
.xl-cell.given { cursor: default; }

/* ---------- Spinner / toast ---------- */
.spinner { width: 2.5rem; height: 2.5rem; border: 3px solid rgba(99,102,241,.2); border-top-color: var(--brand-600); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp .35s ease both; }
@keyframes pulseRing { 0%,100% { box-shadow: 0 0 0 0 rgba(6,182,212,.5); } 50% { box-shadow: 0 0 0 10px rgba(6,182,212,0); } }
.pulse-ring { animation: pulseRing 1.8s infinite; }

.toast {
  background: var(--ink-800); color: #f8fafc; border: 1px solid var(--ink-700);
  border-radius: .75rem; padding: .7rem 1rem; font-size: .875rem; font-weight: 600;
  box-shadow: 0 12px 28px -12px rgba(0,0,0,.5); animation: fadeUp .25s ease both;
  max-width: 360px;
}
.toast.ok { border-color: #16a34a; }
.toast.err { border-color: #dc2626; }

/* ---------- Print ---------- */
@media print {
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .card, .card-dark { box-shadow: none !important; border: 1px solid #ddd !important; background: #fff !important; color: #000 !important; }
  .printable-area { padding: 0 !important; margin: 0 !important; }
  .strength-card .details { max-height: none !important; opacity: 1 !important; }
}
