/* Clim — interface de pilotage Airzone (mobile d'abord), thème clair et sombre. */

:root {
  color-scheme: light;
  --bg: #eef1f6;
  --bg-glow: rgba(255, 255, 255, 0.9);
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --line: rgba(16, 24, 40, 0.09);
  --line-strong: rgba(16, 24, 40, 0.14);
  --text: #101828;
  --muted: #667085;
  --accent: #1f6fdb;
  --accent-soft: rgba(31, 111, 219, 0.12);
  --tab-bg: rgba(255, 255, 255, 0.88);
  --shadow: 0 12px 28px -18px rgba(16, 24, 40, 0.45);
  --shadow-tab: 0 14px 34px -14px rgba(16, 24, 40, 0.35);
  --radius: 26px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d12;
  --bg-glow: rgba(32, 52, 78, 0.55);
  --surface: #141a22;
  --surface-2: #1b222c;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f6fa;
  --muted: #93a0b1;
  --accent: #4da3ff;
  --accent-soft: rgba(77, 163, 255, 0.16);
  --tab-bg: rgba(20, 26, 34, 0.9);
  --shadow: 0 12px 28px -18px rgba(0, 0, 0, 0.9);
  --shadow-tab: 0 16px 36px -14px rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(115% 52% at 50% -14%, var(--bg-glow) 0%, transparent 62%);
  background-repeat: no-repeat;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding: max(16px, env(safe-area-inset-top)) 14px calc(104px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button { font-family: inherit; }

/* ------------------------------------------------------------------- en-tête */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-mark {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #2b7fc4, #17577f);
  color: #eaf7ff;
  box-shadow: 0 8px 20px -8px rgba(23, 87, 127, 0.9);
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text h1 { margin: 0; font-size: 19px; font-weight: 680; letter-spacing: -0.3px; }
.brand-text p { margin: 1px 0 0; font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------- choix du thème */
.theme-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  flex: none;
}
.theme-switch button {
  width: 34px; height: 32px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.theme-switch button svg { width: 16px; height: 16px; }
.theme-switch button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.theme-switch button:active { transform: scale(0.94); }

.theme-switch.wide { width: 100%; gap: 6px; padding: 5px; border-radius: 18px; }
.theme-switch.wide button {
  flex: 1;
  width: auto; height: 46px;
  flex-direction: row;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 14px;
}

/* ------------------------------------------------------ bandeau du mode global */
.mode-banner {
  --m1: #6b7280;
  --m2: #4c5360;
  --m-shadow: rgba(16, 24, 40, 0.55);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px 16px;
  margin: 0 0 18px;
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(142deg, var(--m1) 0%, var(--m2) 100%);
  box-shadow: 0 20px 34px -24px var(--m-shadow);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.mode-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 8% -30%, rgba(255, 255, 255, 0.3), transparent 58%),
    radial-gradient(80% 80% at 108% 120%, rgba(0, 0, 0, 0.18), transparent 62%);
  pointer-events: none;
}
.mode-banner > * { position: relative; z-index: 1; }

.mode-banner[data-mode="heat"] { --m1: #d53a26; --m2: #a72a16; --m-shadow: rgba(167, 42, 22, 0.75); }
.mode-banner[data-mode="cool"] { --m1: #1f6fdb; --m2: #15489b; --m-shadow: rgba(21, 72, 155, 0.75); }
.mode-banner[data-mode="fan_only"] { --m1: #0f8b8d; --m2: #0a6a6c; --m-shadow: rgba(10, 106, 108, 0.7); }
.mode-banner[data-mode="dry"] { --m1: #1c7f95; --m2: #135d70; --m-shadow: rgba(19, 93, 112, 0.7); }
.mode-banner[data-mode="auto"],
.mode-banner[data-mode="heat_cool"] { --m1: #6a5acd; --m2: #453a92; --m-shadow: rgba(69, 58, 146, 0.7); }
.mode-banner[data-mode="mixed"] { --m1: #7867c9; --m2: #4d3f8f; --m-shadow: rgba(77, 63, 143, 0.7); }
.mode-banner[data-mode="off"] { --m1: #6b7280; --m2: #4c5360; --m-shadow: rgba(16, 24, 40, 0.55); }
.mode-banner[data-mode="unknown"] { --m1: #7c8493; --m2: #565d6a; --m-shadow: rgba(16, 24, 40, 0.45); }

.mb-icon {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.19);
  border: 1px solid rgba(255, 255, 255, 0.24);
}
.mb-icon svg { width: 25px; height: 25px; }

.mb-text { display: flex; flex-direction: column; min-width: 0; }
.mb-kicker {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.8;
}
.mb-label {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.7px;
  line-height: 1.15;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mb-detail {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0.88;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

:root[data-theme="dark"] .mode-banner { box-shadow: 0 22px 40px -26px rgba(0, 0, 0, 0.95); }

/* --------------------------------------------------------- bandeau d'erreur */
.banner {
  display: none;
  background: rgba(214, 59, 42, 0.1);
  border: 1px solid rgba(214, 59, 42, 0.35);
  color: #b3261e;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 14px;
}
:root[data-theme="dark"] .banner { color: #ffb4a9; border-color: rgba(255, 120, 100, 0.32); }
.banner.show { display: block; }

/* ------------------------------------------------------- en-tête de section */
.section-head { margin: 0 2px 14px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.section-title h2 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.4px; }
.section-title span { font-size: 11.5px; color: var(--muted); font-weight: 500; }

.view-switch {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.view-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 6px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.18s ease, color 0.18s ease;
}
.view-switch button.on { background: var(--accent-soft); color: var(--accent); }
.view-switch button:disabled { opacity: 0.42; cursor: default; }

/* ------------------------------------------------------------- cartes pièce */
.zones { display: grid; gap: 12px; }

.zone {
  --c1: #6b7280;
  --c2: #565e6b;
  --sh: 0 16px 30px -20px rgba(16, 24, 40, 0.7);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 17px 19px 16px;
  color: #fff;
  background: linear-gradient(152deg, var(--c1) 0%, var(--c2) 100%);
  box-shadow: var(--sh);
  transition: background 0.28s ease, box-shadow 0.28s ease, opacity 0.2s ease, transform 0.12s ease;
}
.zone::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(115% 70% at 12% -25%, rgba(255, 255, 255, 0.26), transparent 58%),
    radial-gradient(90% 60% at 105% 110%, rgba(0, 0, 0, 0.16), transparent 60%);
  pointer-events: none;
}
.zone > * { position: relative; z-index: 1; }

.zone[data-state="heat"] {
  --c1: #d53a26; --c2: #ab2a17;
  --sh: 0 18px 32px -20px rgba(171, 42, 23, 0.85);
}
.zone[data-state="cool"] {
  --c1: #1f6fdb; --c2: #14499e;
  --sh: 0 18px 32px -20px rgba(20, 73, 158, 0.85);
}
.zone[data-state="idle"] {
  --c1: #12855a; --c2: #0a6242;
  --sh: 0 18px 32px -20px rgba(10, 98, 66, 0.85);
}
.zone[data-state="off"] {
  --c1: #6b7280; --c2: #545c69;
  --sh: 0 14px 26px -22px rgba(16, 24, 40, 0.7);
}

.zone-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.zone-name {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zone-state {
  margin: 5px 0 0;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.8);
}

.hum {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  margin-bottom: 4px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.17);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hum svg { width: 13px; height: 13px; opacity: 0.92; }

.measure {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 15px;
}

.temp {
  display: flex;
  align-items: flex-start;
  line-height: 0.92;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}
.temp-int { font-size: 58px; font-weight: 300; }
.temp-dec { font-size: 24px; font-weight: 400; line-height: 1; margin-top: 7px; opacity: 0.92; }
.temp-unit { font-size: 24px; font-weight: 400; line-height: 1; margin-top: 7px; margin-left: 1px; opacity: 0.75; }
.temp-none { font-size: 58px; font-weight: 300; letter-spacing: -0.02em; opacity: 0.85; }

.zone-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.setpoint {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.14);
  min-width: 0;
}
.setpoint svg { width: 19px; height: 19px; flex: none; opacity: 0.95; }
.sp-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.sp-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  opacity: 0.72;
}
.sp-value {
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.stepper {
  display: flex;
  align-items: center;
  flex: none;
  padding: 2px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}
.step-btn {
  width: 36px; height: 36px;
  border-radius: 11px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 21px;
  font-weight: 400;
  line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.step-btn + .step-btn { box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.16); }
.step-btn:active { background: rgba(255, 255, 255, 0.24); }
.step-btn:disabled { opacity: 0.4; }

.power {
  width: 50px; height: 50px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.1s ease, color 0.16s ease;
}
.power svg { width: 22px; height: 22px; }
.power:active { transform: scale(0.93); }
.power[aria-pressed="false"] {
  background: #fff;
  border-color: rgba(255, 255, 255, 0.75);
  color: #4b5361;
}

.zone.busy { opacity: 0.62; }
.zone.busy button { pointer-events: none; }

/* ------------------------------------------------------- toute la maison */
.global {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 15px;
  box-shadow: var(--shadow);
}
.global-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 12px;
}
.global-head h2 { margin: 0; font-size: 14px; font-weight: 680; letter-spacing: -0.1px; }
.global-head span { font-size: 11px; color: var(--muted); }

.global-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.global-actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 4px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.1s ease;
}
.global-actions button svg { width: 20px; height: 20px; }
.global-actions button:active { transform: scale(0.97); }
.global-actions button[data-mode="heat"] svg { color: #d53a26; }
.global-actions button[data-mode="cool"] svg { color: #1f6fdb; }
.global-actions button[data-mode="off"] svg { color: var(--muted); }
.global-actions button.on { border-color: rgba(213, 58, 38, 0); }
.global-actions button[data-mode="heat"].on { background: rgba(213, 58, 38, 0.12); border-color: rgba(213, 58, 38, 0.4); }
.global-actions button[data-mode="cool"].on { background: rgba(31, 111, 219, 0.12); border-color: rgba(31, 111, 219, 0.4); }
.global-actions button[data-mode="off"].on { background: var(--surface-2); border-color: var(--line-strong); }
.global-actions button:disabled { opacity: 0.5; }

/* ---------------------------------------------------------------- statut */
.status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 16px 4px 0;
  font-size: 11.5px;
  color: var(--muted);
}
.status .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #12a15f;
  flex: none;
}
.status.err .dot { background: #d63b2a; }
.status.err #status-text { color: #b3261e; }
:root[data-theme="dark"] .status.err #status-text { color: #ffb4a9; }
.status .link-btn {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
}

/* --------------------------------------------------------- vue configuration */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 17px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.panel h3 { margin: 0 0 4px; font-size: 14px; font-weight: 680; }
.panel-note { margin: 0 0 13px; font-size: 12px; color: var(--muted); line-height: 1.45; }

.facts { margin: 8px 0 0; }
.facts div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.facts div:first-child { border-top: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 0; font-size: 13px; font-weight: 600; text-align: right; }

.ghost-btn {
  width: 100%;
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.ghost-btn:active { transform: scale(0.99); }

.version { text-align: center; font-size: 11px; color: var(--muted); margin: 18px 0 0; }

/* --------------------------------------------------------------- barre d'onglets */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(532px, calc(100vw - 20px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 6px;
  border-radius: 22px;
  background: var(--tab-bg);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-tab);
  z-index: 30;
}
.tabbar button {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 2px 6px;
  border-radius: 15px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: -0.05px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease;
}
.tabbar button svg { width: 20px; height: 20px; }
.tabbar button.on { color: var(--accent); background: var(--accent-soft); }
.tabbar button:disabled { opacity: 0.38; cursor: default; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  padding: 11px 15px;
  border-radius: 14px;
  box-shadow: var(--shadow-tab);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(214, 59, 42, 0.5); color: #b3261e; }
:root[data-theme="dark"] .toast.err { color: #ffb4a9; }

/* ---------------------------------------------------------------- squelettes */
.skeleton {
  height: 180px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--surface-2) 48%, transparent 76%);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* --------------------------------------------------------------- adaptation */
@media (min-width: 620px) {
  .zones { grid-template-columns: 1fr 1fr; }
  .temp-int { font-size: 54px; }
  .zone-foot { gap: 6px; }
  .step-btn { width: 34px; height: 34px; }
  .power { width: 46px; height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
