﻿:root {
  --bg: #f4f5f2;
  --card-bg: #ffffff;
  --text: #1c1c1c;
  --text-muted: #666666;
  --border: #dcdcd8;
  --accent: #2f6f4f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 24px 20px 12px;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

section {
  margin-top: 32px;
}

section h2 {
  font-size: 18px;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 6px;
}

.model-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.model-selector button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.model-selector button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.status {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}

/* Selecteur de plage - un seul champ declencheur (comme le "Start date -
   End date" de Home Assistant), tout le reste vit dans le popover. */
.range-control {
  position: relative;
  display: inline-block;
  margin: 12px 0;
}

.range-trigger {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 220px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  border-bottom: 2px solid var(--accent);
}

.range-trigger-caption {
  font-size: 12px;
  color: var(--accent);
}

.range-trigger-value {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}

.range-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  display: flex;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.range-panel.hidden {
  display: none;
}

.range-presets {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  min-width: 170px;
  border-right: 1px solid var(--border);
}

.range-presets button {
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}

.range-presets button:hover {
  background: var(--bg);
}

.range-presets button.active {
  background: var(--accent);
  color: white;
}

.range-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  min-width: 220px;
}

.range-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.range-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.range-fields input[type="datetime-local"] {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  width: 100%;
}

.range-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.link-button {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 6px 4px;
}

.pill-button {
  padding: 8px 18px;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 480px) {
  .range-panel {
    flex-direction: column;
    width: min(320px, 90vw);
  }
  .range-presets {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.chart-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.chart-card canvas {
  max-height: 260px;
}

#forecast-table {
  margin-top: 16px;
  overflow-x: auto;
}

#forecast-table table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

#forecast-table th, #forecast-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}

footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 12px;
}
