/* ═══════════════════════════════════════════════════════════════════
   ACQUA SUD CORSE — design system v2 « clair / épuré, façon Apple »
   Fond #F5F5F7, cartes blanches, un seul accent aqua, ombres douces,
   polices système, animations discrètes (200-300 ms ease-out).
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg:          #F5F5F7;
  --card:        #FFFFFF;
  --ink:         #1D1D1F;
  --ink-soft:    #6E6E73;
  --ink-faint:   #AEAEB2;
  --line:        rgba(0, 0, 0, .08);   /* hairline appuyée (bords) */
  --hairline:    rgba(0, 0, 0, .06);   /* hairline séparateurs */
  --accent:      #0A84C1;              /* bleu aqua piscine */
  --accent-dark: #086FA3;
  --accent-tint: rgba(10, 132, 193, .10);
  --ok:      #248A3D; --ok-bg:   rgba(52, 199, 89, .14);
  --warn:    #B25000; --warn-bg: rgba(255, 149, 0, .14);
  --bad:     #D70015; --bad-bg:  rgba(255, 59, 48, .10);
  --info:    #086FA3; --info-bg: rgba(10, 132, 193, .10);
  --violet:  #5E5CE6; --violet-bg: rgba(94, 92, 230, .10);
  --green:  #34C759; --orange: #FF9500; --red: #FF3B30;
  --radius: 16px;
  --shadow:      0 1px 3px rgba(0, 0, 0, .06);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .05), 0 12px 28px rgba(0, 0, 0, .10);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { overflow-x: clip; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  /* très léger voile aqua en haut de page → identité piscine, subtile */
  background:
    linear-gradient(180deg, rgba(10, 163, 214, .06) 0, rgba(10, 163, 214, 0) 340px),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; }
a { color: var(--accent); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
::selection { background: rgba(10, 132, 193, .18); }
code {
  background: rgba(0, 0, 0, .05); color: var(--ink);
  padding: 1px 6px; border-radius: 6px; font-size: .85em;
  word-break: break-all;
}

h2 {
  font-size: 32px; font-weight: 600; letter-spacing: -.02em;
  color: var(--ink); line-height: 1.15; margin-bottom: 22px;
}
h3 {
  font-size: 17px; font-weight: 600; letter-spacing: -.01em;
  color: var(--ink); margin-bottom: 14px;
}
@media (max-width: 720px) {
  h2 { font-size: 26px; }
}

/* ─── Topbar : claire, translucide, sticky ──────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #ffffff;                       /* fallback opaque */
  border-bottom: 1px solid var(--line);
}
@supports ((backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px))) {
  .topbar {
    background: rgba(255, 255, 255, .72);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
  }
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  padding: 10px 20px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); font-size: 17px; font-weight: 600;
  letter-spacing: -.01em; white-space: nowrap;
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand small {
  font-size: 10px; font-weight: 600; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--ink-soft);
  align-self: flex-end; padding-bottom: 3px;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #3ABBDD 0%, var(--accent) 100%);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 17px; height: 17px; }

/* Navigation : inline en desktop, panneau plein pouce en mobile */
.nav-toggle { display: none; }
.burger {
  display: none; margin-left: auto; cursor: pointer;
  width: 46px; height: 44px; border-radius: 10px;
  align-items: center; justify-content: center;
  transition: background .2s ease;
}
.burger:hover { background: rgba(0, 0, 0, .04); }
.burger span, .burger span::before, .burger span::after {
  content: ""; display: block; width: 18px; height: 1.8px;
  background: var(--ink); border-radius: 2px; position: relative;
  transition: transform .25s ease, opacity .25s ease;
}
.burger span::before { position: absolute; top: -6px; }
.burger span::after  { position: absolute; top: 6px; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  color: #424245; font-size: 14px; font-weight: 500;
  padding: 9px 13px; border-radius: 10px;
  min-height: 44px; display: inline-flex; align-items: center;
  transition: background .2s ease, color .2s ease;
}
.nav a:hover { background: rgba(0, 0, 0, .045); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.nav .logout-form { margin-left: 8px; }
.nav .logout-form button {
  background: transparent; border: 1px solid var(--line); color: var(--ink-soft);
  min-height: 38px; padding: 5px 14px; font-size: 13px; box-shadow: none;
}
.nav .logout-form button:hover { background: rgba(0, 0, 0, .04); color: var(--ink); box-shadow: none; }

@media (max-width: 900px) {
  .burger { display: inline-flex; }
  .nav {
    display: none; width: 100%; flex-direction: column; align-items: stretch;
    padding: 6px 0 12px; margin: 0;
  }
  .nav a { font-size: 16px; padding: 12px 14px; }
  .nav .logout-form { margin: 8px 0 0; }
  .nav .logout-form button { width: 100%; min-height: 44px; }
  .nav-toggle:checked ~ .nav { display: flex; }
  .nav-toggle:checked ~ .burger span { transform: rotate(45deg); }
  .nav-toggle:checked ~ .burger span::before { transform: rotate(-90deg) translate(-6px, 0); top: 0; }
  .nav-toggle:checked ~ .burger span::after { opacity: 0; }
}

/* ─── Page ──────────────────────────────────────────────────────────── */

.page {
  max-width: 1180px; margin: 0 auto;
  padding: 34px 20px 72px;
  animation: page-in .35s ease-out both;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Cartes & stats ────────────────────────────────────────────────── */

.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px; margin-bottom: 30px;
}
.card {
  background: var(--card);
  border: 1px solid rgba(0, 0, 0, .04);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .25s ease-out, box-shadow .25s ease-out;
}
a.card { color: inherit; display: block; }
a.card:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px); text-decoration: none;
}
.card .label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.card .value {
  font-size: 32px; font-weight: 600; letter-spacing: -.02em;
  margin-top: 2px; color: var(--ink); font-variant-numeric: tabular-nums;
}
.card .value.blue   { color: var(--accent); }
.card .value.green  { color: var(--ok); }
.card .value.orange { color: var(--warn); }
.card .value.red    { color: var(--bad); }

.section {
  background: var(--card);
  border: 1px solid rgba(0, 0, 0, .04);
  border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.section > h3 { margin-bottom: 16px; }

/* ─── Flashs / messages ─────────────────────────────────────────────── */

.flash {
  border-radius: 12px; padding: 13px 16px; margin-bottom: 20px;
  font-size: 14.5px;
  animation: page-in .35s ease-out both;
}
.flash.ok   { background: var(--ok-bg);   color: var(--ok); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.bad  { background: var(--bad-bg);  color: var(--bad); }
.flash.info { background: var(--info-bg); color: var(--info); }

/* Bandeau code d'accès (affiché une seule fois) */
.code-banner {
  background: linear-gradient(135deg, rgba(10, 132, 193, .08), rgba(58, 187, 221, .05));
  border: 1px solid rgba(10, 132, 193, .22);
  color: var(--ink); border-radius: var(--radius); padding: 22px;
  margin-bottom: 22px;
}
.code-banner .big-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 32px; letter-spacing: 7px; font-weight: 700;
  color: var(--accent); margin: 8px 0 10px; word-break: break-all;
}
.code-banner small { color: var(--ink-soft); display: block; line-height: 1.6; }

/* ─── Badges ────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge.ok    { background: var(--ok-bg);    color: var(--ok); }
.badge.wait  { background: var(--warn-bg);  color: var(--warn); }
.badge.no    { background: var(--bad-bg);   color: var(--bad); }
.badge.info  { background: var(--info-bg);  color: var(--info); }
.badge.odoo  { background: var(--violet-bg); color: var(--violet); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ─── Formulaires ───────────────────────────────────────────────────── */

input, select, textarea {
  background: #fff; border: 1px solid rgba(0, 0, 0, .14); color: var(--ink);
  padding: 10px 14px; border-radius: 10px; font-size: 16px;
  width: 100%; font-family: inherit; min-height: 44px;
  transition: border-color .2s ease, box-shadow .2s ease;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236E6E73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 34px;
}
input[type="checkbox"] {
  width: 20px; height: 20px; min-height: 0; accent-color: var(--accent);
  -webkit-appearance: auto; appearance: auto;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(10, 132, 193, .14);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; color: var(--ink-soft);
  margin-bottom: 6px; font-weight: 600;
}

/* ─── Boutons ───────────────────────────────────────────────────────── */

button, .btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 20px; border-radius: 12px; cursor: pointer;
  font-size: 15px; font-family: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; text-decoration: none;
  transition: background .2s ease, transform .15s ease-out, box-shadow .2s ease;
}
button:hover, .btn:hover {
  background: var(--accent-dark); color: #fff; text-decoration: none;
}
button:active, .btn:active { transform: scale(.98); }
button:focus-visible, .btn:focus-visible {
  outline: none; box-shadow: 0 0 0 4px rgba(10, 132, 193, .30);
}
.btn-danger  { background: var(--red); }
.btn-danger:hover { background: #E0321F; }
.btn-success { background: var(--green); }
.btn-success:hover { background: #2EAD4F; }
/* ancien « sable » → action secondaire neutre, gris teinté */
.btn-sand    { background: rgba(0, 0, 0, .05); color: var(--ink); }
.btn-sand:hover { background: rgba(0, 0, 0, .09); color: var(--ink); }
.btn-ghost {
  background: transparent; color: var(--accent);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--accent-tint); color: var(--accent-dark); }
.btn-sm { padding: 6px 13px; font-size: 13px; min-height: 36px; border-radius: 10px; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* Chips de filtre */
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.chip {
  padding: 8px 15px; border-radius: 20px; font-size: 13.5px; font-weight: 500;
  background: #fff; border: 1px solid var(--line); color: var(--ink-soft);
  min-height: 40px; display: inline-flex; align-items: center;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.chip:hover { color: var(--ink); border-color: rgba(0, 0, 0, .18); text-decoration: none; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }

/* ─── Tableaux responsive ───────────────────────────────────────────── */

.tbl-wrap { border-radius: var(--radius); }
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table.tbl {
  width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .04); box-shadow: var(--shadow);
}
.tbl th {
  background: var(--card); padding: 13px 16px; text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft); font-weight: 600; white-space: nowrap;
}
.tbl td {
  padding: 13px 16px; border-top: 1px solid var(--hairline);
  font-size: 15px; vertical-align: middle;
}
.tbl tbody tr { transition: background .15s ease; }
.tbl tbody tr:hover { background: rgba(0, 0, 0, .02); }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.td-actions form { margin: 0; }
.muted { color: var(--ink-faint); font-size: 13px; }

/* Empilement en cartes sur mobile (tables marquées .stack) */
@media (max-width: 720px) {
  table.tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack { background: transparent; border: none; box-shadow: none; overflow: visible; }
  .tbl.stack thead { display: none; }
  .tbl.stack tbody tr {
    background: var(--card); border: 1px solid rgba(0, 0, 0, .04);
    border-radius: 14px; margin-bottom: 12px; padding: 6px 16px;
    box-shadow: var(--shadow);
  }
  .tbl.stack td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 14px; border: none; border-bottom: 1px solid var(--hairline);
    padding: 10px 0; text-align: right;
  }
  .tbl.stack td:last-child { border-bottom: none; }
  .tbl.stack td::before {
    content: attr(data-l); flex: none;
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-faint); font-weight: 600; text-align: left;
  }
  .tbl.stack td:not([data-l]) { justify-content: flex-end; }
  .tbl.stack td:not([data-l])::before { content: none; }
  .tbl.stack .td-actions { justify-content: flex-end; }
}

/* ─── Jauges en anneau (conic-gradient animé à l'affichage) ─────────── */

@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }
.ring {
  --p: 0; --ring-c: var(--accent);
  position: relative; width: 84px; height: 84px; flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--ring-c) calc(var(--p) * 1%), #E9E9EE 0);
  display: grid; place-items: center;
  animation: ring-in 1.1s cubic-bezier(.25, .8, .3, 1) .1s both;
}
@keyframes ring-in { from { --p: 0; } }
.ring-in {
  width: calc(100% - 14px); height: calc(100% - 14px);
  background: var(--card); border-radius: 50%;
  display: grid; place-items: center; text-align: center; line-height: 1.1;
}
.ring-in b { font-size: 18px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); display: block; }
.ring-in small { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
.ring.lv-ok   { --ring-c: var(--green); }
.ring.lv-warn { --ring-c: var(--orange); }
.ring.lv-bad  { --ring-c: var(--red); }
.ring.lv-na   { --ring-c: #C7C7CC; }

/* ─── Espace client ─────────────────────────────────────────────────── */

.client-topbar .topbar-inner { padding: 12px 20px 8px; }
/* Onglets façon « segmented control » iOS */
.client-tabs {
  display: flex; gap: 2px;
  width: min(680px, calc(100% - 32px));
  margin: 2px auto 12px; padding: 3px;
  background: rgba(118, 118, 128, .12);
  border-radius: 12px;
}
.client-tabs a {
  flex: 1; text-align: center; color: #3A3A3C; font-size: 14px; font-weight: 600;
  padding: 9px 6px; min-height: 44px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.client-tabs a:hover { text-decoration: none; color: var(--ink); }
.client-tabs a.active {
  background: #fff; color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .10);
}
.client-page { max-width: 760px; }

.hero { margin-bottom: 28px; }
.hero h2 { margin-bottom: 4px; }
.hero p { color: var(--ink-soft); font-size: 16px; }

/* Carte piscine */
.pool-card {
  background: var(--card);
  border: 1px solid rgba(0, 0, 0, .04);
  border-radius: 18px; padding: 22px; margin-bottom: 18px;
  box-shadow: var(--shadow);
  transition: transform .25s ease-out, box-shadow .25s ease-out;
}
a.pool-card { display: block; color: inherit; }
a.pool-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.pool-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.pool-head h3 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); margin: 0; }
.pool-addr { color: var(--ink-faint); font-size: 13px; margin-bottom: 16px; }
.pool-live { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.pool-live .ring { width: 88px; height: 88px; }
.pool-facts { flex: 1; min-width: 150px; display: grid; gap: 8px; }
.pool-facts .fact { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.pool-alert {
  margin-top: 16px; padding: 12px 15px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn); font-size: 14px;
}
.pool-quiet { color: var(--ink-faint); font-size: 14px; padding: 8px 0; }

/* Équipements (détail piscine client) */
.equip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.equip { background: #F7F7F9; border-radius: 12px; padding: 15px; }
.equip .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 600; }
.equip .v { font-size: 15px; color: var(--ink); font-weight: 600; margin-top: 3px; }

/* Historique (sparklines SVG serveur) */
.spark { margin-bottom: 20px; }
.spark h4 { font-size: 13px; color: var(--ink-soft); margin-bottom: 7px; font-weight: 600; }
.spark svg {
  display: block; width: 100%; height: auto; border-radius: 12px;
  background: #FAFAFC; border: 1px solid var(--hairline);
}
.spark polyline {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1600; stroke-dashoffset: 1600;
  animation: draw 1.4s ease-out .15s forwards;
}
.spark .ph-line { stroke: var(--orange); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.spark .legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-faint); margin-top: 5px; }

/* Connexion (admin + espace client) */
.gate-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(10, 163, 214, .08) 0, rgba(10, 163, 214, 0) 45%),
    var(--bg);
}
.gate-card {
  background: var(--card); border-radius: 20px; padding: 36px 28px;
  width: 100%; max-width: 420px;
  border: 1px solid rgba(0, 0, 0, .04);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 16px 48px rgba(0, 0, 0, .10);
  animation: page-in .4s ease-out both;
}
.gate-card .brand-mark { margin: 0 auto 14px; width: 52px; height: 52px; }
.gate-card .brand-mark svg { width: 26px; height: 26px; }
.gate-card h1 {
  font-size: 24px; font-weight: 600; letter-spacing: -.02em; color: var(--ink);
  text-align: center; margin-bottom: 4px;
}
.gate-card .sub { text-align: center; color: var(--ink-soft); font-size: 15px; margin-bottom: 24px; }
.code-input {
  text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 24px; letter-spacing: 6px; text-transform: uppercase;
  min-height: 56px;
}
.gate-help {
  margin-top: 20px; padding: 14px 16px; border-radius: 12px;
  background: var(--accent-tint); color: var(--ink-soft); font-size: 13.5px; line-height: 1.6;
}
.gate-help b, .gate-help code { color: var(--ink); }
.gate-help code { background: rgba(255, 255, 255, .7); }

/* ─── Divers ────────────────────────────────────────────────────────── */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar form { margin: 0; }
.subtle-head { color: var(--ink-faint); font-size: 13px; margin: -14px 0 22px; }
.footer-note { text-align: center; color: var(--ink-faint); font-size: 12.5px; padding: 10px 16px 32px; }

/* Accessibilité : tout s'arrête si l'utilisateur préfère moins de mouvement */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .spark polyline { stroke-dashoffset: 0; }
  .ring { animation: none; }
}
