/* ============================================================
   GUARDIAN MONITOR — RESPONSIVE.CSS
   Responsabilidade:
   - adaptação para notebook
   - tablet
   - celular
   Sem alterar os módulos individuais.
   ============================================================ */


/* ============================================================
   NAVEGAÇÃO MOBILE — NÃO OCUPAR ESPAÇO NO DESKTOP
   ============================================================ */
#guardian-nav-mobile,
#guardian-history-mobile,
#guardian-usuario-mobile {
  display: contents;
}

/* ============================================================
   DESKTOP MENOR / NOTEBOOK
   ============================================================ */
@media (max-width: 1280px) {
  :root {
    --sidebar-width: 196px;
    --page-gap: 12px;
    --page-padding-x: 12px;
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: minmax(0, 2.35fr) minmax(270px, 0.85fr);
  }
}


/* ============================================================
   TABLET / TELA INTERMEDIÁRIA
   ============================================================ */
@media (max-width: 980px) {
  :root {
    --sidebar-width: 82px;
  }

  .sidebar {
    grid-template-rows: 78px 1fr 120px;
  }

  .page-content {
    grid-template-rows: auto auto;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-card {
    min-height: 104px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: 520px;
  }

  .right-column {
    min-height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 300px;
  }
}


/* ============================================================
   CELULAR
   O menu deixa de ocupar uma coluna fixa e passa para o topo.
   Os blocos ficam empilhados.
   ============================================================ */
@media (max-width: 680px) {
  :root {
    --topbar-height: 56px;
    --footer-height: 34px;
    --page-padding-x: 10px;
    --page-padding-y: 10px;
    --page-gap: 10px;
  }

  .app-shell {
    display: block;
  }

  /* BLOCO 01 — menu vira uma faixa superior */
    .sidebar {
    position: relative;
    inset: auto;

    width: 100%;
    height: 88px;

    display: block;

    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }
  
  .sidebar-top {
    display: flex;
  }

  .sidebar-nav,
  .sidebar-bottom {
    display: none;
  }

  #guardian-usuario-mobile .sidebar-bottom {
    display: block;
    position: relative;
    width: 100%;
  }

  #guardian-usuario-mobile .guardian-usuario-painel {
    height: auto;
  }

  #guardian-usuario-mobile .guardian-usuario-sair {
    margin-top: 0;
  }

  /* BLOCO 02 — conteúdo ocupa toda a largura */
  .main-area {
    width: 100%;
    min-height: calc(100vh - 64px);
    margin-left: 0;

    grid-template-rows: var(--topbar-height) auto var(--footer-height);
  }

  .page-content {
    display: block;
    padding:
      var(--page-padding-y)
      var(--page-padding-x);
  }

    /* HISTÓRICO GUARDIAN — LARGURA NO CELULAR */
  .right-top-chip {
    width: 100%;
    height: 95px;
    margin-bottom: 10px;
  }

  /* HISTÓRICO GUARDIAN — EXPANSÃO PARA CIMA NO CELULAR */
  .right-top-chip.guardian-history-open {
    top: auto;
    bottom: 12px;
    height: calc(100dvh - 66px);
  }

  .page-content {
    display: flex;
    flex-direction: column;
  }

  .summary-grid {
    order: 1;
  }

  .dashboard-grid {
    order: 2;
  }

  .right-top-chip {
    order: 3;
  }

  /* BLOCO 03 — cards empilhados em duas colunas */
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 10px;
  }

  .summary-card {
    min-height: 88px;
    border-radius: var(--radius-md);
  }

  /* BLOCO 04 — uma única coluna */
  .dashboard-grid {
    display: block;
  }

  .map-panel {
    min-height: 360px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
  }

  /* NAVEGAÇÃO DAS TVs — DEPOIS DO MAPA NO CELULAR */
.sidebar-nav {
  display: block;
  position: relative;
  width: 100%;
}

.sidebar-nav #menu-mapa {
  transform: translateY(-10px);
}

  

  .right-column {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 230px;
    gap: 10px;
  }

    .right-panel {
    border-radius: var(--radius-md);
  }


/* ============================================================
   LEGENDA DO MAPA — SOMENTE CELULAR
   ============================================================ */  
  .guardian-map-legenda {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 500;

    display: flex;
    flex-direction: column;
    gap: 0px;

    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);

    color: #1f2937;
    font-size: 11px;
    pointer-events: none;
  }

  .guardian-map-legenda-titulo {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 2px;
  }

  .guardian-map-legenda-item {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .guardian-map-legenda-online,
  .guardian-map-legenda-offline {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
  }

  .guardian-map-legenda-online {
    background: #22c55e;
  }

  .guardian-map-legenda-offline {
    background: #ef4444;
  }

}

/* ============================================================
   CELULAR PEQUENO
   ============================================================ */
@media (max-width: 420px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-card {
    min-height: 78px;
  }

  .map-panel {
    min-height: 320px;
  }
}
