/* ================================================================
   MezBOX Sensor – Modern Design (iOS / Material Design 3)
   ================================================================ */

/* ---- Design Tokens -------------------------------------------- */
:root {
  --bg:            #F4F4F5;   /* zinc-100  */
  --surface:       #FFFFFF;
  --surface2:      #E4E4E7;   /* zinc-200  */
  --primary:       #6366F1;   /* indigo-500 */
  --primary-bg:    rgba(99,102,241,0.10);
  --label:         #18181B;   /* zinc-900  */
  --label2:        #3F3F46;   /* zinc-700  */
  --label3:        #71717A;   /* zinc-500  */
  --label4:        #A1A1AA;   /* zinc-400  */
  --sep:           rgba(63,63,70,0.10);
  --danger:        #EF4444;   /* red-500   */
  --warning:       #F59E0B;   /* amber-500 */
  --success:       #22C55E;   /* green-500 */
  --teal:          #06B6D4;   /* cyan-500  */
  --indigo:        #6366F1;   /* indigo-500 */
  --orange:        #F97316;   /* orange-500 */
  --yellow:        #EAB308;   /* yellow-500 */
  --radius:        14px;
  --radius-sm:     10px;
  --shadow:        0 2px 12px rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.04);
  --transition:    0.18s ease;
  --font:          'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}

/* Dark theme (triggered by JS via applyTheme()) */
.layout-dark {
  --bg:       #09090B;   /* zinc-950 */
  --surface:  #18181B;   /* zinc-900 */
  --surface2: #27272A;   /* zinc-800 */
  --label:    #FAFAFA;   /* zinc-50  */
  --label2:   #E4E4E7;   /* zinc-200 */
  --label3:   #A1A1AA;   /* zinc-400 */
  --label4:   #71717A;   /* zinc-500 */
  --sep:      rgba(250,250,250,0.08);
  --shadow:   0 2px 14px rgba(0,0,0,0.55);
}

/* ---- Base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  background-color: var(--bg) !important;
  color: var(--label) !important;
  font-family: var(--font) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Framework7 page / view backgrounds ----------------------- */
.views, .view, .pages, .page, .page-content {
  background-color: var(--bg) !important;
}
.page-content {
  padding-bottom: 28px !important;
}

/* ---- Navbar --------------------------------------------------- */
.navbar {
  background: rgba(244,244,245,0.88) !important;
  backdrop-filter: saturate(180%) blur(20px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(20px) !important;
  border-bottom: 1px solid var(--sep) !important;
  box-shadow: none !important;
}
.layout-dark .navbar {
  background: rgba(24,24,27,0.88) !important;
}
.navbar-inner {
  box-shadow: none !important;
}
.navbar .center,
.navbar-inner .center {
  font-family: var(--font) !important;
  font-weight: 600 !important;
  font-size: 17px !important;
  letter-spacing: -0.3px;
  color: var(--label) !important;
}
.navbar .link,
.navbar .back .icon,
.navbar .icon.icon-back {
  color: var(--primary) !important;
}
/* Override the hardcoded white SVG background-image with primary indigo */
.navbar .icon.icon-back {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20width%3D'24'%20height%3D'24'%20viewBox%3D'0%200%2024%2024'%3E%3Cpath%20d%3D'M20%2011H7.83l5.59-5.59L12%204l-8%208%208%208%201.41-1.41L7.83%2013H20v-2z'%20fill%3D'%236366F1'%2F%3E%3C%2Fsvg%3E") !important;
}
.layout-dark .navbar .icon.icon-back {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20width%3D'24'%20height%3D'24'%20viewBox%3D'0%200%2024%2024'%3E%3Cpath%20d%3D'M20%2011H7.83l5.59-5.59L12%204l-8%208%208%208%201.41-1.41L7.83%2013H20v-2z'%20fill%3D'%23818CF8'%2F%3E%3C%2Fsvg%3E") !important;
}
/* Sensor name dropdown in navbar */
.navTitle {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
/* li.dropIndex/dropTitle are position:fixed in my-app.css — pin them to the full
   navbar height (56px) and use flex to vertically centre the sensor name */
li.dropIndex,
li.dropTitle {
  top: 0 !important;
  height: 56px !important;
  display: flex !important;
  align-items: center !important;
  padding: 0 8px !important;
  line-height: 1 !important;
}
.navTitle > li {
  color: var(--primary) !important;
  font-weight: 600 !important;
  font-size: 18px !important;
  cursor: pointer;
  gap: 4px;
}
li.dropIndex::after,
li.dropTitle::after {
  font-family: var(--font) !important;
  content: "" !important;   /* cleared – JS adds the chevron via HTML */
}
/* Dropdown menus */
.dropIndex ul,
.dropTitle ul {
  position: absolute !important;
  background: var(--surface) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.14), 0 0 0 0.5px rgba(0,0,0,0.06) !important;
  overflow: hidden;
  min-width: 190px;
  z-index: 999;
  left: 0 !important;
  top: 0.2em !important;
}
.dropIndex ul li a,
.dropTitle ul li a {
  background: var(--surface) !important;
  color: var(--label) !important;
  font-family: var(--font) !important;
  font-size: 15px !important;
  padding: 13px 18px !important;
  border-bottom: 1px solid var(--sep);
  display: block;
  white-space: nowrap;
}
.dropIndex ul li:last-child a,
.dropTitle ul li:last-child a { border-bottom: none; }
.dropIndex ul li a:active,
.dropTitle ul li a:active { background: var(--surface2) !important; }

/* ---- Panel (slide-out sidebar) -------------------------------- */
.panel { background-color: var(--surface) !important; }
.panel .list-block { margin: 0 !important; }
.panel .list-block ul {
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.panel .item-link { color: var(--label) !important; }
.panel .item-media { color: var(--primary) !important; }
.panel .item-content { border-bottom: 1px solid var(--sep) !important; }
.panel .item-content::after { display: none !important; }
.panel .item-title { font-weight: 500 !important; }
.panel .item-media .icon-svg {
  width: 22px; height: 22px;
}

/* ---- Sensor Value Cards (scard) ------------------------------- */
.scard {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 10px 16px;
  padding: 16px 18px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--transition), box-shadow var(--transition);
}
.scard:active { transform: scale(0.985); }

.scard-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.scard-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
}
.scard-icon .icon-svg { width: 18px; height: 18px; }

/* icon colour variants */
.scard-icon--blue   { background: rgba(99,102,241,0.12);   color: #6366F1; }
.scard-icon--cyan   { background: rgba(6,182,212,0.12);    color: #06B6D4; }
.scard-icon--teal   { background: rgba(34,197,94,0.10);    color: #22C55E; }
.scard-icon--green  { background: rgba(34,197,94,0.12);    color: #16A34A; }
.scard-icon--orange { background: rgba(249,115,22,0.12);   color: #F97316; }
.scard-icon--red    { background: rgba(239,68,68,0.12);    color: #EF4444; }
.scard-icon--purple { background: rgba(139,92,246,0.12);   color: #8B5CF6; }
.scard-icon--yellow { background: rgba(245,158,11,0.12);   color: #B45309; }
.scard-icon--indigo { background: rgba(99,102,241,0.12);   color: #6366F1; }

.scard-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--label3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  flex: 1;
}
.scard-value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex-wrap: wrap;
}
.scard-main {
  font-size: 52px;
  font-weight: 200;
  color: var(--label);
  line-height: 1;
  letter-spacing: -3px;
}
.scard-unit {
  font-size: 22px;
  font-weight: 300;
  color: var(--label3);
  letter-spacing: -0.5px;
  align-self: flex-end;
  padding-bottom: 6px;
}
.scard-trend {
  font-size: 18px;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  align-self: flex-end;
  padding-bottom: 8px;
}
/* Two-value side-by-side layout */
.scard-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.scard-row .scard-value:last-child { justify-content: flex-end; }
/* Divider inside card */
.scard-sub {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--sep);
}
.scard-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
.scard-sub-label {
  font-size: 13px;
  color: var(--label3);
  font-weight: 500;
}
.scard-sub-value {
  font-size: 18px;
  font-weight: 500;
  color: var(--label);
}
.scard-sub-unit {
  font-size: 12px;
  color: var(--label4);
  font-weight: 400;
  margin-left: 2px;
}

/* ---- Trend Arrows --------------------------------------------- */
.trend-arrow {
  display: inline-flex;
  align-items: center;
}
.trend-arrow .icon-svg { width: 17px; height: 17px; }
.trend-up     { color: var(--danger); }
.trend-down   { color: var(--teal); }
.trend-steady { color: var(--label4); }

/* ---- DateTime label ------------------------------------------- */
.datetime-label {
  font-size: 12px;
  color: var(--label4);
  text-align: center;
  padding: 2px 16px 10px;
  font-weight: 400;
}

/* ---- Navigation Cards (chart links on index) ------------------ */
.nav-section { margin: 16px 16px 6px; }
.nav-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--label3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 4px 8px;
}
.nav-cards {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.nav-item {
  display: flex;
  align-items: center;
  padding: 13px 14px;
  color: var(--label) !important;
  text-decoration: none !important;
  border-bottom: 1px solid var(--sep);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.nav-item:last-child { border-bottom: none; }
.nav-item:active { background: var(--surface2); }
.nav-item-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
  background: var(--primary-bg);
  color: var(--primary);
}
.nav-item-icon .icon-svg { width: 17px; height: 17px; }
.nav-item-title {
  flex: 1;
  font-size: 16px;
  font-weight: 500;
  color: var(--label);
}
.nav-item-arrow { color: var(--label4); display: flex; align-items: center; }
.nav-item-arrow .icon-svg { width: 15px; height: 15px; }

/* ---- Framework7 List Blocks (chart min/max tables) ------------ */
.list-block {
  margin: 10px 16px !important;
}
.list-block ul {
  background: var(--surface) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden !important;
}
.list-block ul::before,
.list-block ul::after { display: none !important; }
.list-block .item-content {
  border-bottom: 1px solid var(--sep) !important;
  padding: 0 16px !important;
  min-height: 50px !important;
}
.list-block li:last-child > .item-content { border-bottom: none !important; }
.list-block .item-inner {
  padding: 13px 0 !important;
  min-height: auto !important;
}
.list-block .item-inner::after { display: none !important; }
.list-block .item-title {
  font-size: 15px !important;
  font-weight: 500 !important;
  color: var(--label) !important;
}
.list-block .item-after {
  font-size: 15px !important;
  color: var(--label3) !important;
  font-weight: 500 !important;
}
.list-block .item-divider {
  background: var(--surface) !important;
  color: var(--label3) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  padding: 7px 16px !important;
  min-height: auto !important;
  display: flex !important;
  align-items: center !important;
  gap: 7px;
  border-bottom: 1px solid var(--sep) !important;
}
.list-block .item-divider .icon-svg { width: 14px; height: 14px; flex-shrink: 0; }
/* settings form specific */
.list-block.store-data .item-title.label {
  color: var(--label) !important;
  font-weight: 500 !important;
}
.list-block select {
  color: var(--primary) !important;
  font-family: var(--font) !important;
  font-size: 15px !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  max-width: 200px;
}
.list-block input[type="text"] {
  color: var(--primary) !important;
  font-family: var(--font) !important;
  font-size: 15px !important;
  text-align: right !important;
}
/* toggle switch */
.label-switch .checkbox { background-color: var(--surface2) !important; }
input:checked + .checkbox { background-color: var(--success) !important; }
/* range slider */
input[type="range"]::-webkit-slider-thumb { background: var(--primary) !important; }
input[type="range"]::-webkit-slider-runnable-track { background: var(--surface2) !important; }

/* ---- Min/Max section (chart pages) ---------------------------- */
/* Dynamic sections hidden until JS populates them for the active sensor */
.minmax-dyn { display: none; }

/* ---- Google Chart containers (chart pages) -------------------- */
#tempChart, #humChart, #pressChart, #iaqChart,
#chart1, #chart2, #chart3,
#windChart, #rainChart, #solarChart,
#pvGenerationChart, #pvChargingChart, #pvConsumptionChart,
#pwrChart, #pwrConsumptionChart, #pwrConsumptionJ3Chart,
#pwrGenerationSumChart, #pwrGenerationChart {
  display: none; /* hidden until JS draws data into the container */
  width: auto !important; /* overrides inline width:100%; margins are outside the box */
  margin: 8px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 8px 0 4px;
}

/* ---- Overview page cards -------------------------------------- */
.overview-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}
.overview-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}
.overview-card:active { background: var(--surface2); }
.overview-room {
  font-size: 15px;
  font-weight: 600;
  color: var(--label);
  display: flex;
  align-items: center;
  gap: 10px;
}
.overview-room .icon-svg { width: 18px; height: 18px; color: var(--orange); }
.overview-temp {
  font-size: 36px;
  font-weight: 200;
  color: var(--label);
  letter-spacing: -2px;
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.overview-unit {
  font-size: 16px;
  font-weight: 300;
  color: var(--label3);
}

/* ---- Utility: small date text in min/max ---------------------- */
.date-tag {
  font-size: 11px;
  color: var(--label4);
  font-weight: 400;
  margin-left: 6px;
}

/* ---- Pull to refresh ------------------------------------------ */
.pull-to-refresh-layer .preloader { color: var(--primary) !important; }

/* ---- About info ----------------------------------------------- */
.about-sub {
  font-size: 11px;
  color: var(--label4);
  font-weight: 400;
  margin-left: 6px;
}

/* ---- Legacy class overrides (keep but neutralise) -------------- */
/* .xxl values are now replaced by .scard-main; keep fallback */
.xxl {
  font-size: 4em;
  font-weight: 200;
  letter-spacing: -2px;
  margin: 0 16px;
  line-height: 1;
}
.unity {
  font-size: 0.45em;
  vertical-align: super;
  font-weight: 300;
}
.trend {
  font-size: 0.3em;
  vertical-align: text-top;
  font-weight: lighter;
}
.margin { margin: 0 16px; }
.small  { font-size: 0.5em; }

/* ---- Weather SVG icons ---------------------------------------- */
.weather-svg {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

/* ---- Panel overlay -------------------------------------------- */
.panel-overlay { background: rgba(0,0,0,0.25) !important; }

/* ---- Sensor picker bottom sheet ------------------------------- */
.sensor-picker-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sensor-picker-backdrop.is-visible { opacity: 1; }

.sensor-picker-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9001;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px; /* safe-area fallback */
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.sensor-picker-sheet.is-visible { transform: translateY(0); }

.sensor-picker-handle {
  width: 36px; height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  margin: 10px auto 4px;
}
.sensor-picker-title {
  font-size: 12px; font-weight: 600;
  color: var(--label3);
  text-align: center;
  padding: 6px 20px 14px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.sensor-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  font-size: 17px;
  font-family: var(--font);
  color: var(--label);
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--sep);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.sensor-picker-item:active { background: var(--surface2); }
.sensor-picker-item.is-active {
  color: var(--primary);
  font-weight: 600;
}
.sensor-picker-item.is-active::after {
  content: "✓";
  font-size: 18px;
  color: var(--primary);
}
.sensor-picker-loading {
  padding: 28px 20px;
  text-align: center;
  color: var(--label3);
  font-size: 15px;
}
.sensor-picker-cancel {
  display: block;
  width: 100%;
  padding: 16px;
  margin-top: 8px;
  font-size: 17px; font-weight: 600;
  font-family: var(--font);
  color: var(--danger);
  background: var(--surface);
  border: none;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.sensor-picker-cancel:active { background: var(--surface2); }

/* ── Overview card – 2-hour chart overlay ────────────────────── */
.ov-chart-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.ov-chart-backdrop.is-visible { opacity: 1; }

.ov-chart-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9001;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.ov-chart-sheet.is-visible { transform: translateY(0); }

.ov-chart-handle {
  width: 36px; height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  margin: 10px auto 0;
}
.ov-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 20px 0;
}
.ov-chart-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--label);
}
.ov-chart-subtitle {
  font-size: 12px;
  color: var(--label3);
  margin-top: 2px;
}
.ov-chart-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--label3);
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
  -webkit-tap-highlight-color: transparent;
}
.ov-chart-close:active { opacity: 0.6; }
.ov-chart-body { padding: 4px 4px 0; }

/* ── Energy Flow Diagram ─────────────────────────────────────── */
.ef-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 10px 16px;
  padding: 0;
  overflow: hidden;
  /*max-width: 580px;*/
}
.ef-svg {
  width: 100%;
  max-width: 520px;
  height: auto;
  display: block;
  margin: 0 auto;
}


/* ---- PWA Install iOS Instructions ----------------------------- */
.install-ios-body {
  padding: 8px 20px 4px;
}
.install-ios-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  font-size: 16px;
  color: var(--label);
  border-bottom: 1px solid var(--sep);
}
.install-ios-step:last-child {
  border-bottom: none;
}
.install-ios-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}