/* Physio Session Logger — mobile-first styles */

:root {
  --teal: #0e7c66;
  --teal-dark: #0a5f4f;
  --blue: #2f6fb2;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2b28;
  --muted: #6b7d78;
  --warn: #b3541e;
  --warn-bg: #fdf0e4;
  --danger: #b3271e;
  --border: #dde5e2;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

.app-header {
  background: var(--teal);
  color: #fff;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  font-weight: 600;
  font-size: 17px;
  position: sticky;
  top: 0;
  z-index: 10;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 14px 90px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 13px 0;
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.bottom-nav a:active { background: var(--bg); }

h2 { font-size: 19px; margin: 20px 0 10px; }
h3 { font-size: 16px; margin: 16px 0 8px; }

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

.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); }
.hidden { display: none !important; }

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #ecc9a3; }

.warn-text { color: var(--warn); font-size: 13px; }
.ok-text { color: var(--teal); font-size: 13px; }

/* Buttons */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-big {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 18px;
  margin-bottom: 14px;
}
.btn-small { padding: 6px 10px; font-size: 13px; }
.btn-list {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 6px;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.field input, .field select, .field textarea,
input[type="text"], input[type="month"], input[type="url"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; min-width: 0; }

/* Home */
.patient-row, .session-row, .report-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  gap: 10px;
}
.patient-name { font-weight: 600; }
.picker-new { display: flex; gap: 8px; margin-bottom: 10px; }
.picker-new input { flex: 1; }
.picker-new .btn { white-space: nowrap; }
.back-link {
  display: inline-block;
  color: var(--teal);
  text-decoration: none;
  margin-bottom: 8px;
  font-size: 14px;
}

/* Session */
.session-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.session-patient { font-weight: 700; font-size: 18px; }
.session-date { color: var(--muted); font-size: 13px; }
.session-timer {
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 700;
  color: var(--teal);
}

.ptt-area { text-align: center; padding: 20px 14px; }
.ptt-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: var(--teal);
  color: #fff;
  font-size: 34px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(14, 124, 102, 0.35);
}
.ptt-btn.recording {
  background: var(--danger);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(179, 39, 30, 0.5); }
  70% { box-shadow: 0 0 0 18px rgba(179, 39, 30, 0); }
  100% { box-shadow: 0 0 0 0 rgba(179, 39, 30, 0); }
}
.ptt-btn:disabled { background: var(--muted); box-shadow: none; }
.ptt-status { margin-top: 10px; font-size: 14px; color: var(--muted); min-height: 20px; }
.ptt-status.live { color: var(--teal); font-weight: 600; }
.ptt-status.warn { color: var(--warn); }
.ptt-interim { margin-top: 4px; font-style: italic; color: var(--muted); min-height: 20px; }

/* Entry cards */
.entry-card { border-left: 4px solid var(--border); }
.entry-card.status-corrected { border-left-color: var(--teal); }
.entry-card.status-parsed { border-left-color: var(--blue); }
.entry-card.status-pending { border-left-color: var(--warn); }
.entry-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.entry-status { text-transform: uppercase; letter-spacing: 0.04em; }
.entry-raw { font-style: italic; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.entry-exercise { font-weight: 700; font-size: 16px; }
.entry-details { color: var(--text); margin-top: 2px; }
.entry-complaint { color: var(--warn); margin-top: 6px; font-size: 14px; }
.entry-notes { color: var(--muted); margin-top: 4px; font-size: 14px; }
.entry-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.entry-pending { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.session-actions { display: flex; gap: 10px; margin-top: 16px; }
.session-actions .btn-danger { flex: 1; }

/* Patient view */
.chart-card { overflow-x: auto; }
.chart-title { font-weight: 600; margin-bottom: 4px; }
.chart-subtitle { font-size: 13px; color: var(--muted); margin: 8px 0 2px; }
.complaint-row { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }

/* Charts */
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-label { font-size: 9px; fill: var(--muted); font-family: inherit; }
.chart-unit { font-size: 10px; fill: var(--muted); }
.chart-empty { fill: var(--muted); font-size: 14px; }

/* Report */
.report {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  margin-bottom: 16px;
}
.report-header {
  border-bottom: 2px solid var(--teal);
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.report-brand {
  color: var(--teal);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.report-header h1 { font-size: 22px; margin: 6px 0 4px; }
.report-meta { color: var(--muted); font-size: 13px; }
.report-summary {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}
.report-summary strong { color: var(--text); font-size: 18px; display: block; }
.report h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--teal);
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
  margin: 22px 0 10px;
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.report-table th, .report-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.report-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.report-chart { margin: 12px 0; page-break-inside: avoid; }
.report-narrative p { margin: 0 0 12px; }
.report-row { display: flex; justify-content: space-between; text-decoration: none; color: var(--text); padding: 8px 0; border-bottom: 1px solid var(--border); }

/* Toast */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Print: clean report, hide app chrome */
@media print {
  body { background: #fff; font-size: 12px; }
  .no-print, .app-header, .bottom-nav, #toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .report { border: none; border-radius: 0; padding: 0; }
  .report section { page-break-inside: avoid; }
  .chart { max-width: 480px; }
}
