/* bi-stepper.css — Bon d'Intervention V2, stepper mobile-first "gros doigts"
 * Scope strict : #modal-bi-v2 uniquement, aucun override global. */

#modal-bi-v2 {
  position: fixed; inset: 0; z-index: 9998;
  display: none; align-items: stretch; justify-content: center;
  background: rgba(3, 7, 18, .72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
#modal-bi-v2.open { display: flex; }

#modal-bi-v2 .biv2-panel {
  display: flex; flex-direction: column;
  width: 100%; max-width: 760px; margin: auto;
  background: #0f172a;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  max-height: 96vh; overflow: hidden;
  color: #e2e8f0;
}

/* ── HEADER ──────────────────────────────────────────────────────── */
#modal-bi-v2 .biv2-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
#modal-bi-v2 .biv2-title {
  font-size: 16px; font-weight: 700; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 8px;
}
#modal-bi-v2 .biv2-title .biv2-draft-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 10px #22c55e80;
}
#modal-bi-v2 .biv2-title .biv2-draft-dot.saving { background: #f59e0b; }
#modal-bi-v2 .biv2-close {
  background: transparent; border: 0; color: #94a3b8;
  font-size: 22px; cursor: pointer;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
}
#modal-bi-v2 .biv2-close:hover { background: rgba(255,255,255,.06); color: #fff; }

/* ── STEPPER BAR ─────────────────────────────────────────────────── */
#modal-bi-v2 .biv2-steps {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 2px; padding: 0 12px 10px;
}
#modal-bi-v2 .biv2-step {
  background: transparent; border: 0; cursor: pointer;
  padding: 8px 6px; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #64748b; font-size: 11px; font-weight: 600;
  min-height: 48px;
  transition: all .2s;
}
#modal-bi-v2 .biv2-step .biv2-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #1e293b; color: #94a3b8;
  font-size: 12px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.08);
}
#modal-bi-v2 .biv2-step.done .biv2-step-num { background: #16a34a; color: #fff; border-color: #16a34a; }
#modal-bi-v2 .biv2-step.current { color: #e2e8f0; }
#modal-bi-v2 .biv2-step.current .biv2-step-num { background: #3b82f6; color: #fff; border-color: #3b82f6; box-shadow: 0 0 0 4px rgba(59,130,246,.2); }
#modal-bi-v2 .biv2-step.invalid .biv2-step-num { background: #dc2626; color: #fff; border-color: #dc2626; }

/* ── BODY ────────────────────────────────────────────────────────── */
#modal-bi-v2 .biv2-body {
  flex: 1 1 auto; overflow-y: auto; padding: 14px 18px 6px;
  -webkit-overflow-scrolling: touch;
}
#modal-bi-v2 .biv2-page { display: none; animation: biv2-fade .2s ease; }
#modal-bi-v2 .biv2-page.active { display: block; }
@keyframes biv2-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

#modal-bi-v2 .biv2-card {
  background: rgba(30, 41, 59, .55);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
#modal-bi-v2 .biv2-card-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: #94a3b8;
  margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
#modal-bi-v2 .biv2-card-title .biv2-required { color: #ef4444; }

/* ── FORM CONTROLS (44px touch) ─────────────────────────────────── */
#modal-bi-v2 .biv2-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 10px;
}
#modal-bi-v2 .biv2-row.cols-1 { grid-template-columns: 1fr; }
#modal-bi-v2 .biv2-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
#modal-bi-v2 .biv2-field {
  display: flex; flex-direction: column; gap: 4px;
}
#modal-bi-v2 .biv2-label {
  font-size: 11px; font-weight: 600; color: #94a3b8;
  letter-spacing: .02em;
}
#modal-bi-v2 .biv2-label .biv2-required { color: #ef4444; margin-left: 2px; }
#modal-bi-v2 input[type="text"],
#modal-bi-v2 input[type="tel"],
#modal-bi-v2 input[type="email"],
#modal-bi-v2 input[type="date"],
#modal-bi-v2 input[type="time"],
#modal-bi-v2 input[type="number"],
#modal-bi-v2 select,
#modal-bi-v2 textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px; /* iOS no-zoom */
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(15, 23, 42, .7);
  color: #e2e8f0;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
#modal-bi-v2 textarea {
  min-height: 96px; padding: 12px;
  font-family: inherit; resize: vertical;
}
#modal-bi-v2 input:focus,
#modal-bi-v2 select:focus,
#modal-bi-v2 textarea:focus {
  outline: none; border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}
#modal-bi-v2 .biv2-field.invalid input,
#modal-bi-v2 .biv2-field.invalid select,
#modal-bi-v2 .biv2-field.invalid textarea {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,.2);
}
#modal-bi-v2 .biv2-error {
  font-size: 11px; color: #fca5a5; margin-top: 2px; display: none;
}
#modal-bi-v2 .biv2-field.invalid .biv2-error { display: block; }

/* ── BOUTONS (min 44px) ─────────────────────────────────────────── */
#modal-bi-v2 .biv2-btn {
  min-height: 44px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.08);
  background: rgba(30, 41, 59, .6); color: #e2e8f0;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s;
}
#modal-bi-v2 .biv2-btn:hover { background: rgba(51, 65, 85, .8); }
#modal-bi-v2 .biv2-btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
#modal-bi-v2 .biv2-btn-primary:hover { background: #1d4ed8; }
#modal-bi-v2 .biv2-btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
#modal-bi-v2 .biv2-btn-success:hover { background: #15803d; }
#modal-bi-v2 .biv2-btn-danger  { background: #dc2626; border-color: #dc2626; color: #fff; }
#modal-bi-v2 .biv2-btn-devis   { background: linear-gradient(135deg,#8b5cf6,#ec4899); border-color: #8b5cf6; color: #fff; }
#modal-bi-v2 .biv2-btn-devis:hover { background: linear-gradient(135deg,#7c3aed,#db2777); }
#modal-bi-v2 .biv2-btn-ghost   { background: transparent; }
#modal-bi-v2 .biv2-btn:disabled { opacity: .5; cursor: not-allowed; }
#modal-bi-v2 .biv2-btn-lg { min-height: 52px; font-size: 15px; }

/* ── CHIPS (type intervention, phrases types) ───────────────────── */
#modal-bi-v2 .biv2-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
#modal-bi-v2 .biv2-chip {
  min-height: 44px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(15, 23, 42, .6); color: #cbd5e1;
  font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
#modal-bi-v2 .biv2-chip:hover { border-color: #3b82f6; }
#modal-bi-v2 .biv2-chip.active {
  background: #2563eb; border-color: #2563eb; color: #fff;
}

/* ── TECHNICIENS PICKER ─────────────────────────────────────────── */
#modal-bi-v2 .biv2-tech-wrap {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px;
  background: rgba(15, 23, 42, .5);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  min-height: 52px;
  align-items: center;
}
#modal-bi-v2 .biv2-tech-chip {
  min-height: 36px; padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(15, 23, 42, .6); color: #cbd5e1;
  font-size: 13px; font-weight: 600; cursor: pointer;
  letter-spacing: .02em;
}
#modal-bi-v2 .biv2-tech-chip:hover { border-color: #3b82f6; }
#modal-bi-v2 .biv2-tech-chip.active {
  background: #2563eb; border-color: #2563eb; color: #fff;
}
#modal-bi-v2 .biv2-tech-custom {
  flex: 1; min-width: 140px;
  min-height: 36px; padding: 6px 12px;
  border-radius: 8px;
  border: 1px dashed rgba(255,255,255,.15);
  background: transparent; color: #e2e8f0;
  font-size: 13px;
}
#modal-bi-v2 .biv2-tech-custom:focus {
  outline: none; border-color: #3b82f6;
  background: rgba(15, 23, 42, .7);
}

/* ── MACHINES CARDS ─────────────────────────────────────────────── */
#modal-bi-v2 .biv2-machine {
  background: rgba(15, 23, 42, .5);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
}
#modal-bi-v2 .biv2-machine-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
#modal-bi-v2 .biv2-machine-num {
  font-size: 12px; font-weight: 700; color: #60a5fa;
  text-transform: uppercase; letter-spacing: .1em;
}
#modal-bi-v2 .biv2-machine-remove {
  min-width: 44px; min-height: 44px; padding: 0 10px;
  border-radius: 8px; border: 1px solid rgba(239,68,68,.3);
  background: rgba(239,68,68,.1); color: #fca5a5;
  font-size: 18px; cursor: pointer;
}
#modal-bi-v2 .biv2-machine-remove:hover { background: rgba(239,68,68,.2); }

/* ── LED tri-state (etat equipement) ────────────────────────────── */
#modal-bi-v2 .biv2-led-group {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 6px;
}
#modal-bi-v2 .biv2-led-group-4 {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 641px) {
  #modal-bi-v2 .biv2-led-group-4 { grid-template-columns: repeat(4, 1fr); }
}
#modal-bi-v2 .biv2-led {
  cursor: pointer;
  padding: 12px 8px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.08);
  background: rgba(15, 23, 42, .5);
  text-align: center;
  min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: #94a3b8;
  transition: all .15s;
}
#modal-bi-v2 .biv2-led-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor;
  background: transparent;
}
#modal-bi-v2 .biv2-led[data-state="green"]  { color: #22c55e; }
#modal-bi-v2 .biv2-led[data-state="yellow"] { color: #f59e0b; }
#modal-bi-v2 .biv2-led[data-state="red"]    { color: #ef4444; }
#modal-bi-v2 .biv2-led[data-state="devis"]  { color: #8b5cf6; }
#modal-bi-v2 .biv2-led.active[data-state="green"]  { background: rgba(34,197,94,.15);  border-color: #22c55e; }
#modal-bi-v2 .biv2-led.active[data-state="green"]  .biv2-led-dot { background: #22c55e; }
#modal-bi-v2 .biv2-led.active[data-state="yellow"] { background: rgba(245,158,11,.15); border-color: #f59e0b; }
#modal-bi-v2 .biv2-led.active[data-state="yellow"] .biv2-led-dot { background: #f59e0b; }
#modal-bi-v2 .biv2-led.active[data-state="red"]    { background: rgba(239,68,68,.15);  border-color: #ef4444; }
#modal-bi-v2 .biv2-led.active[data-state="red"]    .biv2-led-dot { background: #ef4444; }
#modal-bi-v2 .biv2-led.active[data-state="devis"]  { background: rgba(139,92,246,.15); border-color: #8b5cf6; }
#modal-bi-v2 .biv2-led.active[data-state="devis"]  .biv2-led-dot { background: #8b5cf6; }
#modal-bi-v2 .biv2-led-label { font-size: 11px; line-height: 1.2; }

/* ── Horodatage Arrivee / Depart ────────────────────────────────── */
#modal-bi-v2 .biv2-clock-group {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
#modal-bi-v2 .biv2-clock-btn {
  min-height: 64px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,.08);
  background: rgba(15, 23, 42, .5);
  color: #e2e8f0;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
#modal-bi-v2 .biv2-clock-btn:hover { border-color: #3b82f6; }
#modal-bi-v2 .biv2-clock-btn.set { background: rgba(37,99,235,.15); border-color: #3b82f6; color: #bfdbfe; }
#modal-bi-v2 .biv2-clock-btn .biv2-clock-icon { font-size: 20px; }
#modal-bi-v2 .biv2-clock-btn .biv2-clock-time { font-size: 16px; font-weight: 700; letter-spacing: .02em; }

/* ── Checklist (entretien) ──────────────────────────────────────── */
#modal-bi-v2 .biv2-check {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 6px 8px;
  border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
#modal-bi-v2 .biv2-check:hover { background: rgba(255,255,255,.03); }
#modal-bi-v2 .biv2-check input[type="checkbox"] {
  width: 22px; height: 22px; min-height: auto; margin: 0;
  accent-color: #22c55e; cursor: pointer; flex-shrink: 0;
}
#modal-bi-v2 .biv2-check-label { font-size: 14px; color: #e2e8f0; }

/* ── Signature canvas ────────────────────────────────────────────── */
#modal-bi-v2 .biv2-sig-box {
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  margin-top: 6px;
}
#modal-bi-v2 .biv2-sig-canvas {
  display: block; width: 100%; height: 180px;
  border-radius: 6px;
  touch-action: none;
  cursor: crosshair;
}
#modal-bi-v2 .biv2-sig-actions {
  display: flex; gap: 6px; margin-top: 8px;
}

/* ── Photos ──────────────────────────────────────────────────────── */
#modal-bi-v2 .biv2-photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px; margin-top: 6px;
}
#modal-bi-v2 .biv2-photo-thumb {
  position: relative; aspect-ratio: 1;
  border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  background: #0a0f1c;
}
#modal-bi-v2 .biv2-photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
#modal-bi-v2 .biv2-photo-thumb .biv2-photo-del {
  position: absolute; top: 4px; right: 4px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.7); color: #fff;
  font-size: 14px; cursor: pointer; line-height: 1;
}
#modal-bi-v2 .biv2-photo-add {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px dashed rgba(255,255,255,.15);
  background: transparent; color: #94a3b8;
  font-size: 24px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  min-height: 90px;
}
#modal-bi-v2 .biv2-photo-add:hover { border-color: #3b82f6; color: #60a5fa; }

/* ── Phrases types (chips defilantes) ───────────────────────────── */
#modal-bi-v2 .biv2-phrases {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 6px;
}
#modal-bi-v2 .biv2-phrase-chip {
  padding: 6px 10px; min-height: 36px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(15, 23, 42, .6); color: #cbd5e1;
  font-size: 12px; cursor: pointer;
}
#modal-bi-v2 .biv2-phrase-chip:hover { background: rgba(37,99,235,.2); border-color: #3b82f6; }

/* ── FOOTER NAV ─────────────────────────────────────────────────── */
#modal-bi-v2 .biv2-footer {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.2);
}
#modal-bi-v2 .biv2-footer .biv2-btn { flex: 1; }
#modal-bi-v2 .biv2-footer .biv2-btn-next,
#modal-bi-v2 .biv2-footer .biv2-btn-submit { flex: 1.4; }

/* ── Summary step 4 ─────────────────────────────────────────────── */
#modal-bi-v2 .biv2-summary {
  background: rgba(15, 23, 42, .5);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px; line-height: 1.5;
}
#modal-bi-v2 .biv2-summary-row { display: flex; justify-content: space-between; padding: 4px 0; gap: 12px; }
#modal-bi-v2 .biv2-summary-row strong { color: #94a3b8; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
#modal-bi-v2 .biv2-summary-row span { color: #e2e8f0; text-align: right; }

/* ── Mobile tweaks ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  #modal-bi-v2 .biv2-panel { max-height: 100vh; border-radius: 0; margin: 0; }
  #modal-bi-v2 .biv2-body { padding: 12px 14px 4px; }
  #modal-bi-v2 .biv2-row { grid-template-columns: 1fr; gap: 8px; }
  #modal-bi-v2 .biv2-row.cols-3 { grid-template-columns: 1fr 1fr; }
  #modal-bi-v2 .biv2-step { font-size: 10px; }
  #modal-bi-v2 .biv2-header { padding: 10px 14px; }
  #modal-bi-v2 .biv2-title { font-size: 14px; }
}
