/* ==========================================================================
   EcoPulse Clima — Design Limpo & Moderno
   Inspiração: Climatempo (detalhes Mín/Máx e listas) + Google Weather (curva
   suave e simplicidade) + Apple Weather (Bento Grid de condições e barras).
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg-page: #f2f5f9;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-pill: #f1f5f9;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent-blue: #0284c7;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-orange: #ea580c;
  --accent-green: #10b981;
  --accent-purple: #6366f1;
  --accent-red: #ef4444;

  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
}

[data-theme="dark"] {
  --bg-page: #0f172a;
  --bg-card: #1e293b;
  --bg-subtle: #162032;
  --bg-pill: #334155;
  --border-color: #334155;
  --border-hover: #475569;

  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-blue: #38bdf8;
  --accent-cyan: #22d3ee;
  --accent-amber: #fbbf24;
  --accent-orange: #fb923c;
  --accent-green: #34d399;
  --accent-purple: #818cf8;
  --accent-red: #f87171;

  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.container {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Barra de Navegação Limpa
   ========================================================================== */
.navbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background-color: rgba(2, 132, 199, 0.12);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: block;
  line-height: 1.15;
}

.brand-location {
  font-size: 12.5px;
  color: var(--text-muted);
  display: block;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-amber);
}

.live-dot.online {
  background-color: var(--accent-green);
}

.live-dot.offline {
  background-color: var(--accent-red);
}

.live-time {
  color: var(--text-muted);
  font-size: 12px;
  padding-left: 6px;
  border-left: 1px solid var(--border-color);
  font-variant-numeric: tabular-nums;
}

.icon-btn,
.clean-btn,
.clean-select {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.icon-btn:hover,
.clean-btn:hover,
.clean-select:hover {
  border-color: var(--border-hover);
}

/* ==========================================================================
   Conteúdo Principal e Cards Base
   ========================================================================== */
.main-content {
  padding-top: 24px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

/* Banner de Alerta */
.weather-alert {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 14px;
  background-color: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--text-main);
}

/* Eventos informativos (ex.: mudança de luminosidade) usam tom azul neutro */
.weather-alert.is-info {
  background-color: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.3);
}

.weather-alert.is-info .alert-icon {
  color: var(--accent-blue);
}

.alert-icon {
  color: var(--accent-amber);
  display: flex;
  align-items: center;
}

.alert-body {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
}

.alert-time {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   SEÇÃO 1: Tempo Agora (Card Google/Climatempo + Bento Grid iPhone)
   ========================================================================== */
.current-weather-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 980px) {
  .current-weather-grid {
    grid-template-columns: 1fr;
  }
}

/* Card Principal (Esquerda) */
.hero-weather-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
}

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

.eyebrow-location {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-blue);
  display: block;
  margin-bottom: 2px;
}

.city-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.condition-pill {
  padding: 6px 14px;
  border-radius: 999px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hero-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: 8px 0;
}

.hero-temp-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.weather-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-temp-value {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: flex-start;
}

.temp-unit {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 6px;
  margin-left: 2px;
}

.hero-summary-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

@media (max-width: 540px) {
  .hero-summary-stats {
    align-items: flex-start;
  }
}

/* Pílulas Mín / Máx Estilo Climatempo */
.minmax-pills {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.minmax-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.minmax-item.min-temp {
  background-color: rgba(2, 132, 199, 0.1);
  color: var(--accent-blue);
}

.minmax-item.max-temp {
  background-color: rgba(234, 88, 12, 0.1);
  color: var(--accent-orange);
}

.feels-like-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.dew-point-text {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Abas e Gráfico Suave Estilo Google Weather */
.google-chart-section {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.google-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.g-tab {
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.g-tab:hover {
  color: var(--text-main);
  background-color: var(--bg-subtle);
}

.g-tab.active {
  color: var(--accent-blue);
  background-color: rgba(2, 132, 199, 0.1);
}

.hero-chart-wrapper {
  position: relative;
  height: 175px;
  width: 100%;
}

/* ==========================================================================
   Bento Grid de Condições (6 Mini-Cards Estilo iPhone / Climatempo)
   ========================================================================== */
.conditions-bento {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (max-width: 520px) {
  .conditions-bento {
    grid-template-columns: 1fr;
  }
}

.mini-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.mini-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-blue {
  background-color: rgba(2, 132, 199, 0.12);
  color: var(--accent-blue);
}
.icon-cyan {
  background-color: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
}
.icon-amber {
  background-color: rgba(245, 158, 11, 0.14);
  color: var(--accent-amber);
}
.icon-green {
  background-color: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
}
.icon-purple {
  background-color: rgba(99, 102, 241, 0.12);
  color: var(--accent-purple);
}
.icon-slate {
  background-color: var(--bg-pill);
  color: var(--text-secondary);
}

.mini-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mini-body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.mini-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.mini-value small {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 3px;
}

.status-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background-color: var(--bg-pill);
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-tag.tag-green {
  background-color: rgba(16, 185, 129, 0.13);
  color: var(--accent-green);
}

.status-tag.tag-amber {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}

.status-tag.tag-red {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.mini-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background-color: var(--bg-pill);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.fill-blue {
  background-color: var(--accent-blue);
}
.fill-cyan {
  background-color: var(--accent-cyan);
}
.fill-amber {
  background-color: var(--accent-amber);
}
.fill-green {
  background-color: var(--accent-green);
}

.mini-caption {
  font-size: 12px;
  color: var(--text-muted);
}

.mini-caption-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   SEÇÃO 2: Dashboard e Histórico (Lista Estilo Climatempo/iPhone + Mapa)
   ========================================================================== */
.dashboard-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-divider-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 8px;
}

.section-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
}

.dashboard-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dashboard-bottom-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 980px) {
  .dashboard-bottom-grid {
    grid-template-columns: 1fr;
  }
}

.history-card,
.map-and-status-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.pill-tabs {
  display: inline-flex;
  background-color: var(--bg-subtle);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.pill-tab {
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.pill-tab.active {
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.history-list-container {
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Linhas Estilo Climatempo / iPhone Weather */
.climatempo-list {
  display: flex;
  flex-direction: column;
}

.ct-row {
  display: grid;
  grid-template-columns: 80px 70px 1fr 130px;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.ct-row:last-child {
  border-bottom: none;
}

@media (max-width: 560px) {
  .ct-row {
    grid-template-columns: 80px 65px 1fr;
  }
  .ct-row .ct-meta-col {
    display: none;
  }
}

.ct-time-col {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.ct-rain-col {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-blue);
  font-size: 12.5px;
  font-weight: 600;
}

/* Barra de Amplitude Térmica Estilo iPhone / Climatempo */
.ct-temp-bar-col {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ct-min {
  color: var(--text-muted);
  font-weight: 500;
  width: 34px;
  text-align: right;
}

.ct-max {
  color: var(--text-main);
  font-weight: 700;
  width: 34px;
}

.ct-bar-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background-color: var(--bg-pill);
  position: relative;
  overflow: hidden;
}

.ct-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8 0%, #f59e0b 60%, #ea580c 100%);
}

.ct-meta-col {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
}

/* Lista de Alertas */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-item {
  padding: 12px 14px;
  border-radius: 12px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.event-item-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Card de Mapa e Status */
.card-simple-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-simple-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.card-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

.device-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.map-container {
  width: 100%;
  height: 215px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  z-index: 1;
}

[data-theme="dark"] .map-container .leaflet-tile-pane {
  filter: brightness(0.68) invert(1) contrast(2.2) hue-rotate(200deg) saturate(0.35);
}

.system-summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.sys-stat {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}

.sys-label {
  font-size: 11.5px;
  color: var(--text-muted);
}

.sys-val {
  font-size: 18px;
  font-weight: 700;
  margin: 2px 0;
  font-variant-numeric: tabular-nums;
}

.text-emerald {
  color: var(--accent-green);
}

.sys-note {
  font-size: 11px;
  color: var(--text-muted);
}
