/* =========================================================================
   Shared Styles — Grist Durabilité Widgets
   Variables CSS, reset, composants communs à tous les widgets
   ========================================================================= */

/* === Design Tokens === */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #e2e8f0;
  --border: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --accent: #3b82f6;
  --accent-light: #2563eb;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
}

/* === Reset === */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 16px;
  min-height: 100vh;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.header h1 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header h1 .icon { font-size: 20px; }

/* === Status indicator === */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface);
}
.status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.5s infinite;
}
.status.ready .dot { background: var(--success); animation: none; }
.status.error .dot { background: var(--error); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* === Cards === */
.card {
  background: var(--surface);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* === Info grid === */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.info-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}
.info-item .label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.info-item .value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.info-item .unit {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #2563eb; }
.btn-primary:disabled {
  background: var(--surface2);
  color: var(--text-dim);
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }

/* === Controls / params === */
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.param-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.param-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.param-group label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.param-group input, .param-group select {
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.param-group input:focus, .param-group select:focus {
  outline: none;
  border-color: var(--accent);
}

/* === Log === */
.log {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 8px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.6;
  white-space: pre-wrap;
}
.log .ok { color: var(--success); }
.log .warn { color: var(--warning); }
.log .err { color: var(--error); }

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text-muted); margin-bottom: 6px; }
.empty-state p { font-size: 13px; line-height: 1.5; max-width: 360px; margin: 0 auto; }

/* === Tabs (dashboard) === */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.tab {
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-bottom: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
}

/* === Filter bar (dashboard, map) === */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar select {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
}
.filter-bar select:focus {
  outline: none;
  border-color: var(--accent);
}

/* === Mode selector (fick dual input) === */
.mode-selector {
  display: flex;
  gap: 4px;
}
.mode-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.mode-btn:hover { border-color: var(--border); color: var(--text); }
.mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
