/* =========================================================
   Suivi de tension — feuille de style
   Chaleureux, doux, lisible. Optimisé tablette / iPad.
   ========================================================= */
:root {
  /* Palette chaude et apaisante */
  --bg1: #fbf6ef;          /* crème */
  --bg2: #f3eee8;          /* sable clair */
  --card: #ffffff;
  --ink: #3a3531;          /* brun-gris doux */
  --ink-soft: #8a8079;
  --line: #ece4da;
  --line-strong: #ddd2c5;

  --primary: #2f8f7f;      /* vert d'eau chaleureux */
  --primary-dark: #277265;
  --primary-soft: #e4f1ee;
  --accent: #e8916b;       /* corail doux (touches) */

  --sys: #d36b5e;          /* systolique */
  --dia: #4f86b8;          /* diastolique */
  --pulse: #6aa06f;        /* pouls */

  --danger: #c0584d;
  --success-bg: #e3f1e6;
  --success-ink: #2c6b41;
  --error-bg: #fbe7e3;
  --error-ink: #9a3a30;
  --info-bg: #eaf2f0;
  --info-ink: #346055;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 2px 6px rgba(92, 74, 56, .06), 0 10px 28px rgba(92, 74, 56, .07);
  --shadow-soft: 0 1px 3px rgba(92, 74, 56, .05);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -200px, #fff7ee 0%, transparent 70%),
    linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- En-tête ---------- */
.topbar {
  padding: 2.4rem 1.5rem 1.2rem;
  text-align: center;
}
.topbar h1 {
  margin: 0;
  font-size: 2.3rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--primary-dark);
}
.topbar h1::before { content: "🩺 "; }
.subtitle { margin: .4rem 0 0; color: var(--ink-soft); font-size: 1.05rem; }

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.1rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

/* ---------- Cartes ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
}
h2 {
  margin: 0 0 1.2rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: .5rem;
}
h2::before { font-size: 1.3rem; }
.form-card h2::before { content: "✏️"; }
.history h2::before { content: "📋"; }
.chart-card h2::before { content: "📈"; }

/* ---------- Formulaire ---------- */
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.1rem; }
.field-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
label { font-weight: 600; color: var(--ink); font-size: 1.02rem; }

input, select, textarea {
  font: inherit;
  font-size: 1.05rem;          /* ≥16px : pas de zoom auto iOS */
  padding: .85rem 1rem;
  min-height: 52px;            /* confort tactile */
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fffdfb;
  color: var(--ink);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
::placeholder { color: #bcb2a7; }

.form-actions { display: flex; gap: .9rem; flex-wrap: wrap; margin-top: .6rem; }

/* Date + heure */
.datetime-group { display: flex; gap: .8rem; flex-wrap: wrap; align-items: stretch; }
.datetime-group .dt-date { flex: 2 1 180px; }
.datetime-group .dt-time { flex: 1 1 130px; }
.datetime-group input { font-size: 1.1rem; }
.btn-now { flex: 0 0 auto; padding: .6rem 1.2rem; white-space: nowrap; }
.datetime-group input::-webkit-calendar-picker-indicator {
  cursor: pointer; padding: .25rem; transform: scale(1.4); opacity: .55;
}
.datetime-group input::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* ---------- Boutons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  padding: .95rem 1.6rem;
  min-height: 52px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .08s ease, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 4px 12px rgba(47, 143, 127, .28);
}
.btn-primary:hover { box-shadow: 0 6px 16px rgba(47, 143, 127, .35); }
.btn-primary:disabled { opacity: .6; cursor: default; box-shadow: none; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--bg1); border-color: var(--primary); color: var(--primary-dark); }

/* ---------- Messages ---------- */
.message { border-radius: var(--radius-sm); padding: .85rem 1rem; margin-bottom: 1.1rem; font-weight: 500; }
.message:empty, .message.hidden { display: none; }
.message.success { background: var(--success-bg); color: var(--success-ink); }
.message.error { background: var(--error-bg); color: var(--error-ink); }
.message.info { background: var(--info-bg); color: var(--info-ink); }

/* ---------- Résumé ---------- */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.1rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: 1.3rem 1.4rem;
  background: linear-gradient(160deg, #ffffff 0%, var(--primary-soft) 220%);
  border-top: 4px solid var(--primary);
}
.stat:nth-child(2) { border-top-color: var(--sys); }
.stat:nth-child(3) { border-top-color: var(--dia); }
.stat:nth-child(4) { border-top-color: var(--accent); }
.stat-label { color: var(--ink-soft); font-size: 1rem; font-weight: 600; }
.stat-value { font-size: 2.1rem; font-weight: 800; color: var(--primary-dark); line-height: 1.1; }
.stat:nth-child(2) .stat-value { color: var(--sys); }
.stat:nth-child(3) .stat-value { color: var(--dia); }
.stat:nth-child(4) .stat-value { color: var(--accent); }
.stat-sub { color: var(--ink-soft); font-size: .9rem; }

/* ---------- Filtres ---------- */
.filter-presets { display: flex; gap: .7rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.chip {
  font: inherit;
  font-weight: 600;
  padding: .7rem 1.3rem;
  min-height: 48px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: all .12s;
}
.chip:hover { border-color: var(--primary); color: var(--primary-dark); }
.chip:active { transform: scale(.97); }
.chip.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(47, 143, 127, .3);
}
.filter-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: end;
}
.filter-row .field { margin-bottom: 0; }
.filter-export .btn { width: 100%; }

/* ---------- Graphiques ---------- */
.charts { display: grid; grid-template-columns: 1fr; gap: 1.4rem; }
.chart-wrap { position: relative; height: 320px; }
.chart-empty { color: var(--ink-soft); text-align: center; padding: 2.5rem 0; font-size: 1.05rem; }

/* ---------- Historique ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { padding: .85rem .8rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  background: var(--bg1); color: var(--ink-soft);
  font-size: .85rem; text-transform: uppercase; letter-spacing: .04em;
  position: sticky; top: 0;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
tbody tr:nth-child(even) { background: #fdfbf8; }
tbody tr:hover { background: var(--primary-soft); }
.actions-cell { display: flex; gap: 1rem; }
.btn-link {
  background: none; border: none; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--primary-dark);
  padding: .35rem .2rem; min-height: 40px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

.hidden { display: none !important; }

/* ---------- Responsive : iPad & téléphone ---------- */
/* iPad portrait et en dessous */
@media (max-width: 834px) {
  body { font-size: 18px; }
  .summary { grid-template-columns: 1fr 1fr; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .filter-export { grid-column: 1 / -1; }
  .topbar h1 { font-size: 2rem; }
}

/* Téléphone */
@media (max-width: 560px) {
  .layout { padding: 0 .8rem 3rem; }
  .card { padding: 1.2rem; }
  .field-row { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  .filter-row { grid-template-columns: 1fr; }
  .form-actions .btn, .datetime-group .btn-now { width: 100%; }
}

/* Appareils tactiles : neutralise les effets de survol "collants" */
@media (hover: none) {
  .chip:hover { border-color: var(--line-strong); color: var(--ink); }
  .btn-ghost:hover { background: #fff; border-color: var(--line-strong); color: var(--ink); }
  tbody tr:hover { background: inherit; }
  tbody tr:nth-child(even):hover { background: #fdfbf8; }
}
