/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
  user-select: none;
}

/* ─── Overlay ────────────────────────────────────────────────────────────────── */
#overlay {
  position: fixed;
  top: 28px;
  right: 28px;
  width: 300px;
  background: #0c0c14;
  border: 1px solid #1e1e30;
  border-right: 3px solid #00e676;
  border-radius: 4px;
  font-family: 'Outfit', system-ui, sans-serif;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.8), 0 0 0 1px rgba(0,230,118,0.08);
  transition: opacity 0.3s, border-right-color 0.3s;
}

#overlay.disconnected { opacity: 0.45; }

/* Bande latérale : couleur selon l'état d'impression */
#overlay[data-state="RUNNING"]  { border-right-color: #00e676; }
#overlay[data-state="PREPARE"]  { border-right-color: #00e676; }
#overlay[data-state="PAUSE"]    { border-right-color: #ffb300; }
#overlay[data-state="FINISH"]   { border-right-color: #7c83ff; }
#overlay[data-state="FAILED"]   { border-right-color: #ff3d57; }
#overlay[data-state="IDLE"]     { border-right-color: #4a4a6a; }
#overlay.disconnected           { border-right-color: #333; }

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.ov-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px 9px 11px;
  background: #111120;
  border-bottom: 1px solid #1e1e30;
  gap: 8px;
}

.ov-brand {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ov-brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00e676;
  box-shadow: 0 0 8px #00e67699;
  flex-shrink: 0;
}

.ov-brand-dot.disconnected { background: #333; box-shadow: none; }
.ov-brand-dot.connecting   { background: #ffb300; box-shadow: 0 0 8px #ffb30099; animation: blink 0.9s infinite; }
.ov-brand-dot.error        { background: #ff3d57; box-shadow: 0 0 8px #ff3d5799; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

.ov-brand-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7a7aa8;
}

.ov-state {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 2px;
  color: #7a7aa8;
  background: #181828;
}
.ov-state[data-state="RUNNING"]  { color: #00e676; background: rgba(0,230,118,0.1); }
.ov-state[data-state="PAUSE"]    { color: #ffb300; background: rgba(255,179,0,0.1); }
.ov-state[data-state="FINISH"]   { color: #7c83ff; background: rgba(124,131,255,0.1); }
.ov-state[data-state="FAILED"]   { color: #ff3d57; background: rgba(255,61,87,0.1); }

/* ─── Badge surveillance IA ────────────────────────────────────────────────── */
.ov-ai-badge {
  padding: 5px 12px 5px 11px;
  background: rgba(0,230,118,0.08);
  border-bottom: 1px solid rgba(0,230,118,0.18);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #00e676;
}

/* ─── Bannière arrêt ─────────────────────────────────────────────────────────── */
.ov-frozen-banner {
  padding: 6px 12px 6px 11px;
  background: rgba(255, 61, 87, 0.12);
  border-bottom: 1px solid rgba(255, 61, 87, 0.25);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #ff3d57;
  text-transform: uppercase;
  animation: blink 1.4s infinite;
}

/* ─── Écran auto-stop (remplace tout l'overlay en fin d'impression) ──────────── */
.ov-autostop-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px 16px 28px;
  text-align: center;
}

.ov-autostop-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9898cc;
}

.ov-autostop-time {
  font-family: 'Outfit', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 46px;
  font-weight: 700;
  color: #7c83ff;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 0 20px rgba(124, 131, 255, 0.35);
}

.ov-autostop-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6e6e9c;
}

/* Quand actif : tout le reste de l'overlay disparaît au profit du décompte */
#overlay.autostop-active > *:not(#autostop-full) { display: none !important; }
#overlay.autostop-active { border-right-color: #7c83ff; }

/* ─── Fichier ────────────────────────────────────────────────────────────────── */
.ov-file {
  padding: 8px 12px 8px 11px;
  border-bottom: 1px solid #1a1a2a;
  font-size: 12px;
  font-weight: 500;
  color: #c8c8e8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

/* ─── Progression ────────────────────────────────────────────────────────────── */
.ov-progress {
  padding: 10px 12px 10px 11px;
  border-bottom: 1px solid #1a1a2a;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ov-progress-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.ov-pct {
  font-family: 'Outfit', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  letter-spacing: -0.02em;
}

.ov-pct span {
  font-size: 14px;
  font-weight: 400;
  color: #7a7aa8;
  margin-left: 1px;
}

.ov-eta {
  font-family: 'Outfit', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: #b0b0dc;
  text-align: right;
  line-height: 1.3;
}

.ov-eta strong {
  display: block;
  font-size: 17px;
  color: #d0d0f0;
  font-weight: 600;
}

#eta-end {
  display: block;
  font-size: 12px;
  color: #b0b0dc;
  margin-top: 2px;
}

.ov-bar-track {
  height: 3px;
  background: #1e1e32;
  border-radius: 1px;
  overflow: hidden;
}

.ov-bar-fill {
  height: 100%;
  background: #00e676;
  border-radius: 1px;
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 2px 0 8px #00e67660;
}

.ov-layers {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #7a7aa8;
  font-family: 'Outfit', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.ov-layers em {
  color: #9898cc;
  font-style: normal;
}

#elapsed-val {
  color: #9898cc;
}

/* ─── Métriques ──────────────────────────────────────────────────────────────── */
.ov-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #1a1a2a;
}

.ov-metric {
  padding: 10px 12px 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid #1a1a2a;
  border-bottom: 1px solid #1a1a2a;
}

.ov-metric:nth-child(even) { border-right: none; }
.ov-metric:nth-last-child(-n+2) { border-bottom: none; }

.ov-metric-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8888aa;
}

.ov-metric-val {
  font-family: 'Outfit', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  color: #d0d0f0;
  line-height: 1;
  transition: color 0.4s;
}

.ov-metric-val .unit {
  font-size: 10px;
  font-weight: 400;
  color: #6e6e9c;
}

.ov-metric-val .tgt {
  font-size: 13px;
  font-weight: 600;
  color: #a0a0d0;
}

.ov-metric-val.hot  { color: #ff6b35; }
.ov-metric-val.warm { color: #ffb300; }

@keyframes val-flash {
  0%   { color: #00e676; }
  100% { color: inherit; }
}
.ov-metric-val.changed { animation: val-flash 0.7s ease-out; }

/* ─── Filament actif ─────────────────────────────────────────────────────────── */
.ov-filament {
  padding: 8px 12px 8px 11px;
  border-bottom: 1px solid #1a1a2a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ov-filament-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a1a2a;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 6px currentColor;
  flex-shrink: 0;
}

.ov-filament-label {
  font-size: 12px;
  font-weight: 600;
  color: #d0d0f0;
  letter-spacing: 0.02em;
}

/* ─── AMS ────────────────────────────────────────────────────────────────────── */
.ov-ams {
  padding: 8px 12px 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ov-ams-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6e6e9c;
}

.ov-ams-slots {
  display: flex;
  gap: 4px;
}

.ov-ams-slot {
  flex: 1;
  height: 8px;
  border-radius: 1px;
  background: #1a1a2a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s;
  opacity: 0.55;
}

.ov-ams-slot.active {
  opacity: 1;
  box-shadow: 0 0 8px currentColor;
}

/* ─── Message déconnecté ─────────────────────────────────────────────────────── */
.ov-offline {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6e6e9c;
  background: rgba(12,12,20,0.7);
}

#overlay.disconnected .ov-offline { display: flex; }
