/* =========================================================
   CRC-Cambodia Advocacy Mentorship Portal — shared styles
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Battambang:wght@400;700&family=Noto+Sans+Khmer:wght@400;500;600;700&display=swap');

:root {
  --brand: #005aab;          /* CRC-Cambodia blue */
  --brand-dark: #044a86;
  --brand-light: #e7f1fa;
  --accent: #f0a92e;         /* warm gold */
  --ink: #1d2733;
  --muted: #5d6b7a;
  --line: #d9e2ec;
  --bg: #f4f7fa;
  --card: #ffffff;
  --danger: #b03a2e;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0,90,171,.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', 'Khmer OS Battambang', 'Battambang', 'Noto Sans Khmer', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
:lang(km), [data-km] { font-family: 'Khmer OS Battambang', 'Battambang', 'Noto Sans Khmer', 'Inter', sans-serif; line-height: 1.8; }

h1,h2,h3,h4 { line-height: 1.3; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---- Login ---- */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 60%), var(--brand); }
.login-card { background: var(--card); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
  padding: 36px; width: 100%; max-width: 460px; position: relative; }
.brand { text-align: center; margin-bottom: 18px; }
.brand h1 { font-size: 1.3rem; margin: 12px 0 4px; }
.brand-badge { width: 72px; height: 72px; border-radius: 50%;
  background: #fff url('logo-crc.png') center / 92% no-repeat;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  color: transparent; font-size: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; }
.brand-badge.sm { width: 42px; height: 42px; flex: none; }
/* consultant credit line on the login card */
.login-card::after { content: 'Coached by Smiljana Frick & Sea Sokhon · Powered by AvatarKH';
  display: block; text-align: center; margin-top: 18px; font-size: .74rem; color: var(--muted); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 6px; margin: 18px 0 14px; background: var(--bg); padding: 5px; border-radius: 10px; }
.tab { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted); }
.tab.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

/* ---- Forms ---- */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input, textarea, select {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
textarea { min-height: 110px; resize: vertical; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1.5px solid transparent; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; transition: .15s; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.gold { background: var(--accent); color: #3d2c08; }
.btn.gold:hover { filter: brightness(.95); }
.btn.block { width: 100%; margin-top: 18px; }
.btn.sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: wait; }

.alert { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0;
  padding: 10px 14px; border-radius: 10px; margin: 10px 0; }
.notice { background: var(--brand-light); color: var(--brand-dark); border: 1px solid #bcd7ef;
  padding: 10px 14px; border-radius: 10px; margin: 10px 0; }

/* ---- Language switch ---- */
.lang-switch { display: inline-flex; gap: 2px; background: var(--bg); border-radius: 8px; padding: 3px; }
.login-card .lang-switch { position: absolute; top: 16px; right: 16px; }
.lang-switch button { border: 0; background: transparent; padding: 5px 10px; border-radius: 6px;
  cursor: pointer; font: inherit; font-size: .82rem; font-weight: 600; color: var(--muted); }
.lang-switch button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

/* ---- Layout ---- */
.topbar { display: flex; align-items: center; gap: 14px; background: #fff; border-bottom: 1px solid var(--line);
  padding: 12px 22px; position: sticky; top: 0; z-index: 50; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 80px; }

/* ---- Dashboard tool cards ---- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; margin-top: 20px; }
.tool-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.tool-card.locked { opacity: .62; }
.tool-card h3 { margin: 0; font-size: 1.02rem; }
.tool-card .btn { margin-top: auto; align-self: flex-start; }
.tool-status { font-size: .8rem; font-weight: 700; }
.tool-status.submitted { color: var(--brand); }
.tool-status.draft { color: var(--accent); }

.help-box { margin-top: 34px; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Tool page ---- */
.tool-header { margin-bottom: 8px; }
.progress-steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.step-pill { border: 1.5px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.step-pill.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.step-pill.done { border-color: var(--brand); color: var(--brand); }

.section-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; margin-bottom: 20px; }
.section-card h3 { margin-top: 0; color: var(--brand-dark); }
.q-block { margin: 20px 0; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.q-block:last-child { border-bottom: 0; }
.q-label { font-weight: 600; margin-bottom: 4px; }
.q-hint { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }

/* language tabs per field */
.fieldlang { display: inline-flex; gap: 2px; background: var(--bg); border-radius: 7px; padding: 2px; margin-bottom: 6px; }
.fieldlang button { border: 0; background: transparent; font: inherit; font-size: .75rem; font-weight: 700;
  padding: 4px 10px; border-radius: 5px; cursor: pointer; color: var(--muted); }
.fieldlang button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

/* AI toolbar */
.ai-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.ai-note { font-size: .78rem; color: var(--muted); }
.ai-spin { display: none; font-size: .85rem; color: var(--brand); font-weight: 600; }
.ai-spin.on { display: inline-flex; align-items: center; gap: 6px; }
.ai-spin::before { content: ''; width: 14px; height: 14px; border: 2px solid var(--brand-light);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* rating grid */
.rate-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.rate-table th, .rate-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.rate-table td:first-child, .rate-table th:first-child { text-align: left; }
.rate-table input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.rate-scale { font-size: .8rem; color: var(--muted); margin-bottom: 10px; }

/* checkbox list */
.check-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: 0; }
.check-item input { width: 20px; height: 20px; accent-color: var(--brand); margin-top: 2px; flex: none; }

/* sticky action bar */
.actionbar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 12px 20px; display: flex; gap: 10px; align-items: center; z-index: 40; }
.save-state { font-size: .82rem; color: var(--muted); margin-right: auto; }

/* results */
.result-score { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.result-bar { flex: 1; height: 12px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.result-bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.result-val { font-weight: 700; min-width: 44px; text-align: right; }
.answer-view { background: var(--bg); border-radius: 10px; padding: 12px 14px; margin: 6px 0; white-space: pre-wrap; }
.answer-view .km, .answer-view.km { color: var(--brand-dark); }

/* admin */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); }
.table th { background: var(--brand); color: #fff; text-align: left; padding: 12px 14px; font-size: .88rem; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.submitted { background: var(--brand-light); color: var(--brand-dark); }
.badge.draft { background: #fdf3e0; color: #8a6210; }
.badge.new { background: var(--bg); color: var(--muted); }

@media (max-width: 640px) {
  .section-card { padding: 18px; }
  .topbar { padding: 10px 12px; }
  .rate-table { font-size: .82rem; }
}
@media print {
  .topbar, .actionbar, .ai-bar, .lang-switch, .progress-steps, .btn, select { display: none !important; }
  body { background: #fff; }
  .section-card { box-shadow: none; border: 1px solid #ccc; }
}
