/* Layout e componentes no padrão Quarks / cloud.nimbussistemas */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--background);
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  padding: 0.65rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: transparent;
  padding: 0;
  line-height: 0;
}

.brand-logo {
  display: block;
  height: 1.85rem;
  width: auto;
  max-width: min(42vw, 11.5rem);
  object-fit: contain;
}

.brand-logo-dark {
  display: none;
}

.dark .brand-logo-light {
  display: none;
}

.dark .brand-logo-dark {
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.25;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(58vw, 28rem);
}

.header-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

/* Switch Quarks — sem borda externa; track transparente até checked */
.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  padding: 0;
  border: none;
  background: transparent;
}

.theme-switcher-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: color-mix(in srgb, var(--foreground) 72%, transparent);
  min-width: 3.2rem;
  text-align: right;
}

.qk-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: 2rem;
  height: 1.15rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--background-accent);
  cursor: pointer;
  outline: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.qk-switch.is-checked {
  background: var(--primary);
  border-color: transparent;
}

.qk-switch:focus-visible {
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--primary);
}

.qk-switch-thumb {
  display: block;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  background: var(--background);
  transform: translateX(0.1rem);
  transition: transform 0.2s ease, background 0.2s ease;
  pointer-events: none;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--foreground) 12%, transparent);
}

.dark .qk-switch:not(.is-checked) .qk-switch-thumb {
  background: var(--foreground);
  box-shadow: none;
}

.qk-switch.is-checked .qk-switch-thumb {
  transform: translateX(calc(100% - 0.12rem));
  background: var(--white);
  box-shadow: none;
}

.app-main {
  flex: 1;
  padding: 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.monitor-page {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.seo-lead {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted-foreground, #64748b);
  max-width: 52rem;
}

/* Abas documento */
.doc-tabs {
  display: flex;
  gap: 0.5rem;
}

.doc-tab {
  font-family: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  height: auto;
  padding: 0.55rem 1rem;
  border-radius: 0.25rem;
  cursor: pointer;
  background: var(--background);
  color: var(--primary);
  border: 1px solid var(--primary);
  transition: filter 0.2s ease, background 0.2s ease, color 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html:not(.dark) .doc-tab:not(.is-active) {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  color: var(--primary);
  background: var(--background);
}

@media (min-width: 768px) {
  .doc-tab {
    flex: 0 0 auto;
    min-width: 4.5rem;
    min-height: 2.25rem;
    height: 2.25rem;
    padding: 0 1rem;
  }
}

.doc-tab:hover {
  filter: brightness(1.08);
}

.doc-tab.is-active {
  border: none;
  color: var(--white);
  background: var(--gradient);
}

/* Mapa + lista lateral */
.monitor-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: stretch;
  min-width: 0;
}

.map-panel {
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--background-muted);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  min-width: 0;
}

.brazil-map {
  flex: 1;
  min-height: 320px;
  height: min(52vh, 440px);
  width: 100%;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

/* Zoom visual no mobile: GeoChart não tem zoom nativo por região */
@media (max-width: 767px) {
  .map-panel {
    min-height: 400px;
    padding: 0.4rem 0.35rem 0.55rem;
  }

  .brazil-map {
    min-height: 360px;
    height: min(58vh, 480px);
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* Só o wrapper do Google — não escalar o SVG à parte (descentraliza) */
  .brazil-map > div {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
    transform: scale(1.38);
    transform-origin: center center;
  }

  .brazil-map svg {
    display: block;
    margin-left: auto;
    margin-right: auto;
  }

  .map-legend {
    margin-top: 0.35rem;
  }
}

/* Host do tooltip nativo do Google → Quarks, colado ao cursor */
.google-visualization-tooltip,
.qk-map-tooltip-host {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
  z-index: 1000 !important;
}

/* Esconde rótulo padrão do Google (ex.: BR-MG / BR-GO) */
.google-visualization-tooltip-item-list,
.google-visualization-tooltip-item,
.google-visualization-tooltip-item > span {
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  white-space: normal !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
}

.google-visualization-tooltip-item:has(.qk-map-tooltip),
.google-visualization-tooltip .qk-map-tooltip {
  color: var(--white) !important;
  font-size: 0.75rem !important;
  line-height: 1.35 !important;
}

.qk-map-tooltip {
  overflow: hidden;
  border-radius: 0.375rem;
  background: var(--primary);
  padding: 0.375rem 0.75rem;
  font-family: "Poppins", sans-serif;
  font-size: 0.75rem !important;
  line-height: 1.35 !important;
  color: var(--white) !important;
  max-width: 14rem;
  box-shadow: 0 1px 2px color-mix(in srgb, #000 18%, transparent);
}

.qk-map-tooltip__nome {
  font-weight: 500;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--white);
}

.qk-map-tooltip__status {
  font-weight: 400;
  opacity: 0.92;
  margin-top: 0.1rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--white);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--foreground) 78%, transparent);
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.map-legend .swatch,
.legend-item .swatch,
.swatch {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.swatch.erro { background: var(--status-erro); }
.swatch.timeout { background: var(--status-timeout); }
.swatch.muito-lento { background: var(--status-muito-lento); }
.swatch.lento { background: var(--status-lento); }
.swatch.normal { background: var(--status-normal); }
.swatch.off { background: var(--status-off); }

/* Sidebar UFs — no mobile vira faixa horizontal */
.uf-sidebar {
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--background-muted);
  display: flex;
  flex-direction: column;
  max-height: none;
  min-height: 0;
  overflow: hidden;
}

.uf-sidebar-title {
  padding: 0.55rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
}

.uf-sidebar-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.45rem;
  overflow: visible;
}

.uf-side-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 2.75rem;
  text-align: left;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  padding: 0.4rem 0.45rem;
  cursor: pointer;
  color: #fff;
  background: #6b6b6b;
  transition: filter 0.15s ease, outline 0.15s ease, background 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.uf-side-item:hover {
  filter: brightness(1.06);
}

.uf-side-item.status-normal { background: var(--status-normal); }
.uf-side-item.status-lento { background: var(--status-lento); color: #1d1d1b; }
.uf-side-item.status-muito-lento { background: var(--status-muito-lento); }
.uf-side-item.status-timeout,
.uf-side-item.status-erro { background: var(--status-timeout); }
.uf-side-item.status-off { background: #6b6b6b; color: #f0f0f0; }

/* Tema claro: tints suaves em vez de blocos saturados */
html:not(.dark) .uf-side-item {
  color: var(--foreground);
  border-color: var(--border);
  border-left-width: 3px;
}

html:not(.dark) .uf-side-item.status-normal {
  background: color-mix(in srgb, var(--status-normal) 22%, white);
  border-left-color: var(--status-normal);
}

html:not(.dark) .uf-side-item.status-lento {
  background: color-mix(in srgb, var(--status-lento) 28%, white);
  border-left-color: var(--status-lento);
  color: var(--foreground);
}

html:not(.dark) .uf-side-item.status-muito-lento {
  background: color-mix(in srgb, var(--status-muito-lento) 24%, white);
  border-left-color: var(--status-muito-lento);
}

html:not(.dark) .uf-side-item.status-timeout,
html:not(.dark) .uf-side-item.status-erro {
  background: color-mix(in srgb, var(--status-timeout) 20%, white);
  border-left-color: var(--status-timeout);
}

html:not(.dark) .uf-side-item.status-off {
  background: color-mix(in srgb, var(--status-off) 18%, white);
  border-left-color: var(--status-off);
  color: var(--foreground);
}

.uf-side-item.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

html:not(.dark) .uf-side-item.is-selected {
  outline-color: var(--primary);
}

.uf-side-code {
  font-weight: 700;
  font-size: 0.78rem;
  min-width: 1.55rem;
}

.uf-side-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.uf-side-nome {
  font-size: 0.68rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uf-side-status {
  font-size: 0.65rem;
  opacity: 0.9;
  font-weight: 600;
}

/* Painel do gráfico */
.chart-panel {
  margin-top: 0.1rem;
  padding: 0.85rem 0.85rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--background-muted);
  min-width: 0;
}

.chart-title {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--foreground);
  line-height: 1.3;
  word-break: break-word;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.55rem;
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--foreground) 78%, transparent);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.chart-wrap {
  position: relative;
  height: 240px;
  width: 100%;
  max-width: 100%;
}

.chart-hint {
  margin: 0.55rem 0 0;
  color: color-mix(in srgb, var(--foreground) 50%, transparent);
  font-size: 0.78rem;
  line-height: 1.35;
}

/* CTA Nimbus Cloud — tokens Quarks (--gradient / --primary / --secondary) */
.nimbus-cloud-banner {
  margin-top: 0.75rem;
  border-radius: 0.25rem;
  /* Degradê Nimbus ampliado para animar o fluxo primary ↔ secondary */
  background: linear-gradient(
    90deg,
    var(--primary) 0%,
    var(--secondary) 35%,
    var(--primary) 70%,
    var(--secondary) 100%
  );
  background-size: 300% 100%;
  background-position: 0% 50%;
  animation: nimbus-banner-gradient 18s linear infinite;
  color: var(--white);
  padding: 0.7rem 1rem 0.8rem;
  min-width: 0;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  box-shadow: none;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.nimbus-cloud-banner::before {
  content: "";
  position: absolute;
  inset: -30%;
  background: linear-gradient(
    115deg,
    transparent 40%,
    color-mix(in srgb, var(--white) 28%, transparent) 50%,
    transparent 60%
  );
  transform: translateX(-80%) rotate(8deg);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

.nimbus-cloud-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 70% 100% at 100% 0%,
    color-mix(in srgb, var(--white) 12%, transparent),
    transparent 55%
  );
  pointer-events: none;
  z-index: 0;
}

.nimbus-cloud-banner:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 22%, transparent);
}

.nimbus-cloud-banner:hover::before {
  opacity: 1;
  animation: nimbus-banner-shine 0.85s ease forwards;
}

.nimbus-cloud-banner__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  text-align: center;
}

.nimbus-cloud-banner__text {
  margin: 0;
  max-width: 48rem;
  font-family: "Poppins", sans-serif;
  font-size: 0.98rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--white);
  text-wrap: pretty;
}

.nimbus-cloud-banner__text strong {
  font-weight: 600;
}

.nimbus-cloud-banner__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-height: 2rem;
  padding: 0 1.1rem;
  border-radius: 0.25rem;
  border: 1px solid color-mix(in srgb, var(--white) 85%, transparent);
  background: var(--white);
  color: var(--primary);
  font-family: "Poppins", sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: none;
  transition:
    transform 0.25s ease,
    background 0.25s ease,
    color 0.25s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nimbus-cloud-banner:hover .nimbus-cloud-banner__cta {
  transform: translateY(-1px);
  color: var(--secondary);
}

.nimbus-cloud-banner__cta:hover {
  background: color-mix(in srgb, var(--white) 90%, var(--secondary));
  color: var(--primary);
}

.nimbus-cloud-banner__cta:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

@keyframes nimbus-banner-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes nimbus-banner-shine {
  from { transform: translateX(-80%) rotate(8deg); }
  to { transform: translateX(80%) rotate(8deg); }
}

@media (min-width: 768px) {
  .nimbus-cloud-banner {
    padding: 0.75rem 1.25rem 0.85rem;
  }

  .nimbus-cloud-banner__text {
    font-size: 1.05rem;
  }

  .nimbus-cloud-banner__cta {
    min-height: 2.1rem;
    font-size: 0.84rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nimbus-cloud-banner {
    animation: none;
    background: var(--gradient);
    background-size: 100% 100%;
  }

  .nimbus-cloud-banner,
  .nimbus-cloud-banner__cta {
    transition: none;
  }

  .nimbus-cloud-banner:hover {
    transform: none;
  }

  .nimbus-cloud-banner:hover::before {
    animation: none;
    opacity: 0;
  }

  .nimbus-cloud-banner:hover .nimbus-cloud-banner__cta {
    transform: none;
  }
}

/* Lista de erros — Table Quarks (@nimbussistemas-quarks/table) */
.erros-panel {
  margin-top: 0.35rem;
  padding: 0.5rem 0 0;
  min-width: 0;
}

.erros-title {
  margin: 0 0 0.55rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 400;
  color: color-mix(in srgb, var(--foreground) 55%, transparent);
}

/* Table.Primitive.Root */
.qk-table-root {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--background);
}

/* Table.Primitive.Table */
.qk-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  border-radius: 0.125rem;
  table-layout: auto;
}

.qk-table.is-loading {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Table.Primitive.Header / Footer */
.qk-table-header,
.qk-table-footer {
  font-weight: 500;
}

.qk-table-header .qk-table-cell {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--background);
}

/* Table.Primitive.Body — divide-y */
.qk-table-body > .qk-table-row + .qk-table-row {
  border-top: 1px solid var(--border);
}

.qk-table-header + .qk-table-body {
  border-top: 1px solid var(--border);
}

/* Table.Primitive.Row — divide-x */
.qk-table-row > .qk-table-cell + .qk-table-cell {
  border-left: 1px solid var(--border);
}

/* Table.Primitive.Column */
.qk-table-cell {
  min-height: 2.5rem;
  height: 2.5rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--foreground);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.qk-table .col-data {
  width: 10.5rem;
}

.qk-table .col-erro {
  height: auto;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
  min-width: 12rem;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.qk-table-empty {
  text-align: center;
  white-space: normal;
  color: color-mix(in srgb, var(--foreground) 45%, transparent);
  padding: 1rem 0.5rem;
  height: auto;
}

/* Tablet+ */
@media (min-width: 768px) {
  .app-header {
    padding: 0.85rem 1.5rem;
  }

  .app-main {
    padding: 1.25rem 1.5rem 2.5rem;
  }

  .monitor-page {
    gap: 1rem;
  }

  .map-panel {
    min-height: 360px;
    padding: 0.75rem;
  }

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

  .uf-sidebar-list {
    grid-template-columns: 1fr;
    overflow: auto;
    max-height: 420px;
  }

  .uf-side-item {
    min-height: 2.4rem;
  }

  .chart-wrap {
    height: min(300px, 40vh);
  }

  .chart-title {
    font-size: 1.05rem;
  }
}

/* Desktop: mapa + sidebar */
@media (min-width: 960px) {
  .monitor-top {
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 1rem;
    min-height: 420px;
  }

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

  .brazil-map {
    min-height: 360px;
  }

  .uf-sidebar {
    max-height: 520px;
    min-height: 420px;
  }

  .uf-sidebar-list {
    flex: 1;
    max-height: none;
  }

  .chart-wrap {
    height: min(320px, 42vh);
  }
}

@media (max-width: 560px) {
  .brand-title {
    max-width: min(52vw, 14rem);
    font-size: 0.72rem;
  }

  .theme-switcher-label {
    font-size: 0.72rem;
  }

  .qk-table .col-data {
    width: 8.5rem;
  }
}
