/* =========================================================
   Hive dashboard (scoped, fullscreen/kiosk)
   Everything is scoped under .hive-page-scope to avoid impacting other pages.
   ========================================================= */

/* 1) Oxygen/CT wrapper: full width only when it contains the dashboard */
.ct-section:has(.hive-page-scope) .ct-section-inner-wrap {
  max-width: 100%;
  width: 100%;
  padding-left: 0;
  padding-right: 0;
}

/* 2) Scope + tokens */
.hive-page-scope {
  /* spacing */
  --dash-gap: 6px;
  --dash-pad: 4px;
  --dash-pad-bottom: 16px;

  /* cards */
  --card-bg: #fff;
  --card-radius: 12px;
  --card-pad: 8px;

  /* grid sizing */
  --grid-col-1: minmax(300px, 0.95fr);
  --grid-col-2: minmax(680px, 2.1fr);
  --grid-col-3: minmax(520px, 1.35fr);
  --row-1: 26fr;
  --row-2: 34fr;
  --row-3: 44fr;

  /* chart inner adjustments */
  --g1-chart-sub: 10px;
  --g2-chart-sub: 16px;

  /* temps legend */
  --temps-legend-max-h: 180px;
  --temps-legend-pullup: -5px;

  position: relative;

  /* fullscreen (scoped) */
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;

  width: 100%;
  margin: 0;   /* local reset */
  padding: 0;  /* local reset */

  /* Avoid odd clipping (charts/leaflet) */
  overflow: visible;

  /* box-sizing baseline */
  box-sizing: border-box;
}

/* inherit box-sizing inside scope */
.hive-page-scope *,
.hive-page-scope *::before,
.hive-page-scope *::after {
  box-sizing: inherit;
}

/* 3) Dashboard wrapper */
.hive-page-scope .my-hive-dashboard {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--dash-pad) var(--dash-pad) var(--dash-pad-bottom);
}

/* 4) Grid */
.hive-page-scope #hiveDashGrid {
  display: grid;
  width: 100%;
  height: 100%;
  gap: var(--dash-gap);
  align-items: stretch;

  grid-template-columns: var(--grid-col-1) var(--grid-col-2) var(--grid-col-3);
  grid-template-rows: var(--row-1) var(--row-2) var(--row-3);

  grid-template-areas:
    "logos icons temps"
    "g1    g1    temps"
    "g2    g2    map";
}

.hive-page-scope #hiveDashGrid > * {
  min-width: 0;
  min-height: 0;
}

/* 5) Areas */
.hive-page-scope .cell-logos { grid-area: logos; }
.hive-page-scope .cell-icons { grid-area: icons; }
.hive-page-scope .cell-temps { grid-area: temps; }
.hive-page-scope .cell-g1    { grid-area: g1; }
.hive-page-scope .cell-g2    { grid-area: g2; }
.hive-page-scope .cell-map   { grid-area: map; }

/* 6) Card base */
.hive-page-scope .dash-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  padding: var(--card-pad);
  overflow: visible;
}

/* 7) Base padding for dashboard cells (override where needed) */
.hive-page-scope .dash-cell {
  padding: 6px;
}

/* 8) Logos */
.hive-page-scope .cell-logos {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.hive-page-scope img.dash-logo {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 9) Icons table */
.hive-page-scope .cell-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.hive-page-scope table.dash-icons {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.hive-page-scope table.dash-icons th,
.hive-page-scope table.dash-icons td {
  border: none;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.hive-page-scope table.dash-icons img {
  display: block;
  margin: 0 auto;
  width: min(120px, 16vw);
  height: auto;
  max-height: 120px;
  object-fit: contain;
}

.hive-page-scope table.dash-icons td b {
  display: block;
  font-size: clamp(18px, 1.5vw, 26px);
  line-height: 1.1;
  white-space: nowrap;
  font-weight: 600;
}

.hive-page-scope .dash-icons-title {
  margin: 0 0 6px 0;
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  font-weight: 700;
  text-align: center;
  color: #1f2937;
  line-height: 1.2;
  width: 100%;
}

.hive-page-scope .dash-icon-caption {
  font-size: 0.9rem;
  line-height: 1.2;
  color: #374151;
  margin-top: 0;
  transform: translateY(-20px);
}

/* 10) Temps widget (SVG) */
.hive-page-scope .cell-temps {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 2px; /* override dash-cell */
}

.hive-page-scope .hive-sensors {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin: 0;
}

.hive-page-scope .hive-sensors__svg {
  width: 100%;
  height: auto;
  max-height: 100%;
  display: block;
  padding-top: 20px;
}

.hive-page-scope .hive-legend {
  width: 100%;
  flex: 0 0 auto;
  margin: var(--temps-legend-pullup) 0 0;
}

.hive-page-scope .hive-legend__svg {
  width: 100%;
  height: auto;
  max-height: var(--temps-legend-max-h);
  display: block;
}

/* 11) Charts */
.hive-page-scope .cell-g1,
.hive-page-scope .cell-g2 {
  padding: 0; /* override dash-cell */
}

.hive-page-scope .grafico {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.hive-page-scope .cell-g1 .grafico {
  height: calc(100% - var(--g1-chart-sub));
}

.hive-page-scope .cell-g2 .grafico {
  height: calc(100% - var(--g2-chart-sub));
}

/* 12) Map */
.hive-page-scope .cell-map {
  display: flex;
  flex-direction: column;
  gap: 0px;
  padding: 0px; /* override dash-cell */
}

.hive-page-scope .cell-map p {
  margin: 0 0 3px;
  line-height: 1.1;
}

.hive-page-scope .cell-map #map {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.hive-page-scope .cell-map .leaflet-container {
  width: 100%;
  height: 100%;
}

/* 13) Media / assets */
.hive-page-scope img,
.hive-page-scope svg {
  max-width: 100%;
}

/* 14) Responsive */
@media (max-width: 1200px) {
  .hive-page-scope {
    --grid-col-1: minmax(280px, 1fr);
    --grid-col-2: minmax(520px, 1.8fr);
    --grid-col-3: minmax(420px, 1.2fr);

    --row-1: 28fr;
    --row-2: 33fr;
    --row-3: 39fr;

    --dash-pad-bottom: 18px;
    --g2-chart-sub: 34px;
  }

  .hive-page-scope table.dash-icons img {
    width: min(110px, 15vw);
    max-height: 120px;
  }
}
