/* ResQVoice — field-first UI: light, high contrast, huge targets.
   Own palette on purpose — this is not an IA or Argos product. */

:root {
  --bg: #f7f9fb;
  --ink: #16232f;
  --muted: #5b6b7a;
  --card: #ffffff;
  --line: #dbe3ea;
  --blue: #1663c7;
  --blue-dark: #0f4c9d;
  --green: #1c9e5a;
  --green-dark: #157a45;
  --red: #d92d2d;
  --red-dark: #ad1f1f;
  --warn-bg: #fff3cd;
  --warn-ink: #7a5b00;
}

* { box-sizing: border-box; }

/* The [hidden] attribute has the same CSS specificity as a single class
   selector, so any element whose own class sets `display` (.big buttons,
   .tabBadge, etc.) silently wins and stays visible even when JS sets
   .hidden = true. Force it to always win — this is what `hidden` is for. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

#demoBanner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-bottom: 1px solid #e6cf86;
  text-align: center;
  font-weight: 700;
  padding: 8px 12px calc(8px + env(safe-area-inset-top));
  letter-spacing: 0.02em;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 640px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 0;
}
.brandMark { flex: none; border-radius: 7px; }
.brandName {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

#accountBar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}
#accountEmail { color: var(--muted); }

.linkBtn {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.linkBtn:active { background: var(--line); }
.linkBtn.danger { color: var(--red); border-color: #f2c9c9; }
.linkBtn.danger:active { background: #fdeaea; }

h1 {
  font-size: 2rem;
  margin: 24px 0 4px;
}

.sub { color: var(--muted); margin: 0 0 20px; font-size: 1.1rem; }

.field {
  display: block;
  margin: 0 0 16px;
}
.field span {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
select {
  width: 100%;
  font-size: 1.15rem;
  padding: 14px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  appearance: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 14px;
}

.big {
  display: block;
  width: 100%;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 18px 16px;
  color: #fff;
  margin: 10px 0;
  min-height: 60px;
}
.big:disabled { opacity: 0.4; cursor: default; }

.primary { background: var(--blue); }
.primary:active { background: var(--blue-dark); }
.green { background: var(--green); }
.green:active { background: var(--green-dark); }
.blue { background: var(--blue); }
.blue:active { background: var(--blue-dark); }
.red { background: var(--red); }
.red:active { background: var(--red-dark); }

.rec.active {
  animation: pulse 1.2s ease-in-out infinite;
  outline: 4px solid rgba(217, 45, 45, 0.35);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.985); }
}

.mic { margin-right: 6px; vertical-align: -5px; }

.error {
  color: var(--red);
  font-weight: 600;
}

.fine {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
  margin-top: 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0;
}

#langBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}
#langPair { font-weight: 700; font-size: 1.1rem; }
#endBtn {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.95rem;
}

#sessionTabs {
  display: flex;
  gap: 4px;
  background: var(--line);
  border-radius: 12px;
  padding: 3px;
  margin: 0 0 14px;
}
.sessionTab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 0.95rem;
  font-weight: 700;
}
.sessionTab.active { background: var(--card); color: var(--ink); }
.tabBadge {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

#noticeCard { background: #eef4fb; border-color: #c9dcf2; }
#noticeCard p { margin: 4px 0; font-size: 0.92rem; color: #27415c; }

#log {
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.entry {
  border-left: 4px solid var(--line);
  padding: 4px 10px;
}
.entry.ems { border-left-color: var(--blue); }
.entry.patient { border-left-color: var(--red); }
.entry p { margin: 2px 0; }
.entry .tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.entry .replayBtn { margin-top: 4px; }

.who { color: var(--muted); font-size: 0.85rem; margin: 0 0 6px; }
#srcText { font-size: 1.05rem; margin: 4px 0; }
.translated { font-size: 1.25rem; font-weight: 600; margin: 6px 0; }

#status { min-height: 1.4em; color: var(--muted); font-weight: 600; }

.controls { margin-top: 8px; }

#player { display: none; }

/* ---------------- login / MFA ---------------- */

#loginView .card { margin-top: 24px; }
#loginView h1 { margin-top: 0; }

input[type="email"],
input[type="password"],
input[type="tel"],
input[type="text"] {
  width: 100%;
  font-size: 1.1rem;
  padding: 13px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
}

#mfaQr {
  display: block;
  margin: 12px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
#mfaSecret {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  word-break: break-all;
}
#mfaCode {
  letter-spacing: 0.3em;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
}

/* ---------------- admin: user management ---------------- */

.userCard { padding: 12px 14px; }
.userHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.userHead strong { font-size: 1rem; }
.userHead .tag {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 600;
}
.userActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* ---------------- signup + MFA method choice ---------------- */

.notice {
  background: #eef4fb;
  border: 1px solid #c9dcf2;
  color: #27415c;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 16px 0 0;
  font-weight: 600;
}
.notice.bad {
  background: #fdeaea;
  border-color: #f2c9c9;
  color: #8d1f1f;
}
.notice.good {
  background: #e8f6ee;
  border-color: #b8e0c9;
  color: #145c34;
}

/* Two-up on anything wider than a small phone, stacked below. */
.nameRow { display: flex; gap: 12px; }
.nameRow .field { flex: 1; }

/* Each available second factor is a full-width target — this is the same
   gloved-hand sizing rule the recording buttons follow. */
.mfaMethodBtn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  min-height: 60px;
}
.mfaMethodBtn:active { background: var(--bg); }
.mfaMethodBtn .methodHint {
  display: block;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
  margin-top: 2px;
}

.signupCard { padding: 12px 14px; }
.signupCard .userHead { align-items: flex-start; }
.signupRow {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}
.signupRow strong { color: var(--ink); font-weight: 600; }
.warnTag {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid #e6cf86;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

@media (max-width: 460px) {
  .nameRow { flex-direction: column; gap: 0; }
}

/* ---------------- admin: usage reporting ---------------- */

#adminTabs {
  display: flex;
  gap: 4px;
  background: var(--line);
  border-radius: 12px;
  padding: 3px;
  margin: 0 0 14px;
}

a.linkBtn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.usageRange {
  display: flex;
  gap: 12px;
}
.usageRange .field { flex: 1; margin-bottom: 12px; }
input[type="date"] {
  width: 100%;
  font-size: 1rem;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
}

.usageActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.statRow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
}
.statValue { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.statLabel {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 2px;
}

/* Usage tables can be wider than a phone. They scroll inside their own
   container so the page itself never scrolls sideways. */
.tableWrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dataTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.dataTable th,
.dataTable td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.dataTable th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dataTable td.num,
.dataTable th.num { text-align: right; }
.dataTable tbody tr:last-child td { border-bottom: none; }

@media (max-width: 460px) {
  .statRow { grid-template-columns: repeat(2, 1fr); }
  .usageRange { flex-direction: column; gap: 0; }
}
