/* project1039 — admin + public form styles */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #1f2733;
  --muted: #64707f;
  --primary: #1f7a3d;
  --primary-dark: #165c2d;
  --primary-soft: #e7f3ec;
  --danger: #c0392b;
  --danger-soft: #fbeae8;
  --warning: #b9770e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --font: "Inter", "Noto Sans", "Noto Sans Sinhala", "Noto Sans Tamil",
          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #12261a; color: #cfe6d7; flex-shrink: 0;
  padding: 20px 0; display: flex; flex-direction: column;
}
.sidebar .brand { font-weight: 700; color: #fff; padding: 6px 20px 18px; font-size: 16px; letter-spacing: .2px; }
.sidebar nav a {
  display: block; padding: 10px 20px; color: #cfe6d7; font-size: 14px; border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.1); border-left-color: var(--primary); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { padding: 12px 20px; font-size: 12px; color: #8fb39c; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.topbar .who { color: var(--muted); font-size: 13px; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: #fff; }
.lang-switch a { padding: 4px 12px; font-size: 12px; color: var(--muted); border-right: 1px solid var(--border); }
.lang-switch a:last-child { border-right: none; }
.lang-switch a:hover { background: #f4f6f9; text-decoration: none; }
.lang-switch a.active { background: var(--primary); color: #fff; }
.content { padding: 24px; max-width: 1080px; width: 100%; min-width: 0; }

/* ---- typography ---- */
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 24px 0 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.subtle { color: var(--muted); font-size: 13px; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; min-width: 0; overflow-wrap: anywhere; }
.card > h2:first-child { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > * { min-width: 0; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } .sidebar { display: none; } }

/* horizontal-scroll wrapper for anything genuinely wide (tables, diagrams) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.table-scroll > table { min-width: 560px; }

/* ---- forms ---- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field { margin-bottom: 16px; min-width: 0; }
input, select, textarea { min-width: 0; max-width: 100%; box-sizing: border-box; }

/* text-like fields — includes <input> with NO type attribute (React renders these) */
input:not([type]),
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=url], input[type=tel], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], input[type=month], input[type=week],
select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; color: var(--text); background: #fff; line-height: 1.4;
}
input[type=file] {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
  font: inherit; max-width: 100%;
}

/* trilingual input group — wraps instead of overflowing */
.i18n-triple { display: flex; flex-wrap: wrap; gap: 6px; }
.i18n-triple > input, .i18n-triple > textarea { flex: 1 1 150px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { min-height: 84px; resize: vertical; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.lang-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.lang-tabs button { border: 1px solid var(--border); background: #fff; padding: 3px 10px; border-radius: 999px; font-size: 12px; cursor: pointer; }
.lang-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.lang-pane { display: none; }
.lang-pane.active { display: block; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid transparent; background: var(--primary); color: #fff; font: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: #f7f8fa; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---- tables ---- */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.data tr:hover td { background: #fafbfc; }

/* ---- pills / alerts ---- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.draft { background: #eef1f4; color: #5b6675; }
.pill.published { background: var(--primary-soft); color: var(--primary-dark); }
.pill.closed { background: #fdf0e3; color: var(--warning); }
.pill.archived { background: #eee; color: #888; }
.pill.blocked { background: var(--danger-soft); color: var(--danger); }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.success { background: var(--primary-soft); color: var(--primary-dark); }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---- repeatable rows ---- */
.repeat-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: start; margin-bottom: 10px; }
.repeat-row .btn.small { margin-top: 2px; }
@media (max-width: 640px) {
  .repeat-row { grid-template-columns: 1fr !important; }
}

/* ---- toggle switch ---- */
.switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: #ccc; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ---- react form builder ---- */
.builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 20px; align-items: start; }
.builder-grid > div { min-width: 0; }
.builder-preview { position: sticky; top: 16px; }
@media (max-width: 1180px) {
  .builder-grid { grid-template-columns: 1fr; }
  .builder-preview { position: static; }
}
.builder-grid input, .builder-grid select, .builder-grid textarea { font-size: 13px; }

/* common-field editor rows — flex-wrap, never overflow the card */
.cf-head, .cf-row {
  display: grid;
  grid-template-columns: 44px 130px minmax(0, 1fr) 62px 56px;
  gap: 10px; align-items: start;
}
.cf-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.cf-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.cf-row .cf-reorder { display: flex; flex-direction: column; gap: 3px; }
.cf-row .cf-reorder .btn { padding: 2px 6px; }
.cf-row code { font-size: 12px; }
.cf-row .cf-toggle { text-align: center; }
@media (max-width: 640px) {
  .cf-head { display: none; }
  .cf-row { grid-template-columns: 44px 1fr; gap: 8px 10px; }
  .cf-row .cf-label { grid-column: 1 / -1; }
  .cf-row .cf-toggle { text-align: left; }
  .cf-row .cf-toggle::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
}

/* ---- voice-to-text (dictation) ---- */
.voice-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  background: var(--primary-soft); border: 1px solid var(--primary);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 18px;
  font-size: 13px; color: var(--primary-dark);
}
.voice-bar .pill { cursor: pointer; }
.mic-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: 6px; padding: 0;
  border: 1px solid var(--primary); border-radius: 50%; background: #fff;
  font-size: 16px; line-height: 1; cursor: pointer; vertical-align: middle;
  flex: 0 0 auto;
}
.mic-btn:hover { background: var(--primary-soft); }
.mic-btn:active { transform: scale(0.92); }
.mic-btn.recording {
  background: var(--danger); border-color: var(--danger); color: #fff;
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,.5); } 50% { box-shadow: 0 0 0 6px rgba(192,57,43,0); } }

/* ---- public form ---- */
.pub-wrap { max-width: 680px; margin: 0 auto; padding: 24px 16px 64px; }
.pub-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; }
.pub-title { text-align: center; color: var(--primary-dark); font-size: 20px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 6px; }
.pub-lang { display: flex; justify-content: center; gap: 8px; margin: 14px 0 22px; }
/* checkboxes & radios on the participant form — big enough to see and tap */
.pub-card input[type=checkbox],
.pub-card input[type=radio] {
  width: 22px; height: 22px; min-width: 22px; margin: 0;
  accent-color: var(--primary); cursor: pointer; flex: 0 0 auto;
}
.pub-card label > input[type=checkbox],
.pub-card label > input[type=radio] { margin-right: 8px; vertical-align: -4px; }

.consent-box {
  border: 2px solid var(--primary); background: var(--primary-soft);
  border-radius: 10px; padding: 16px; display: flex; gap: 14px; align-items: flex-start;
  font-size: 14px; color: var(--text); line-height: 1.6; margin: 20px 0;
}
.consent-box input[type=checkbox] { width: 28px; height: 28px; min-width: 28px; margin-top: 2px; }
.consent-box label { cursor: pointer; }
