:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #0891b2;
  --accent-2: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --border: #475569;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  position: sticky; top: 0; z-index: 10;
}
.header-row { display: flex; justify-content: space-between; align-items: center; }
.header-row h1 { margin: 0; font-size: 1.15rem; }
.header-actions { display: flex; gap: 0.4rem; }

.week-bar { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.5rem; }
.week-bar .spacer { flex: 1; }
.week-bar strong { font-size: 0.95rem; }

main { padding: 1rem; max-width: 1100px; margin: 0 auto; }

#onboarding {
  background: rgba(8, 145, 178, 0.12);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin: 0.7rem auto 0;
  max-width: 1100px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
#onboarding .ob-text { flex: 1; }
#onboarding h2 { margin: 0 0 0.2rem; font-size: 0.95rem; color: var(--accent); }
#onboarding p { margin: 0; color: var(--text); font-size: 0.85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.card h3 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.card .lede { color: var(--muted); font-size: 0.88rem; margin: -0.3rem 0 0.8rem; }

.empty {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
}
.empty p { margin: 0.4rem 0 1rem; }

button {
  font-family: inherit; font-size: 0.9rem;
  padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
button:hover { filter: brightness(1.1); }
button.primary { background: var(--accent); color: white; border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.icon { padding: 0.4rem 0.6rem; font-size: 1rem; }
button.danger-light { background: transparent; color: var(--danger); border-color: var(--danger); padding: 0.3rem 0.6rem; font-size: 0.8rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}
input[type="checkbox"] { width: auto; }
input[type="date"], input[type="time"] { color-scheme: dark; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.field { margin-bottom: 0.7rem; }
.field label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.25rem; }
.field .help { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.field .check-row { display: flex; align-items: center; gap: 0.5rem; }
.field .check-row label { display: inline; margin: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.55rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 500; }
td.actions { text-align: right; white-space: nowrap; }
.tag { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; background: var(--surface-2); margin-right: 0.3rem; }

/* ───── Timeline jour ───── */
.day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.8rem;
}
.day.closed-day { opacity: 0.55; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; gap: 0.5rem; flex-wrap: wrap; }
.day-head .date { font-weight: 600; font-size: 1.02rem; }
.day-head .info { font-size: 0.82rem; color: var(--muted); }

.tl {
  position: relative;
  background: var(--surface-2);
  border-radius: 8px;
  height: 64px;
  cursor: copy;
  overflow: hidden;
  user-select: none;
}
.tl-hour-line {
  position: absolute;
  top: 18px; bottom: 0;
  width: 1px;
  background: var(--border);
  opacity: 0.4;
  pointer-events: none;
}
.tl-hour-line.major { opacity: 0.7; }
.tl-hour-label {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.tl-closed {
  position: absolute;
  top: 18px; bottom: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,0.04) 0 6px, transparent 6px 12px);
  pointer-events: none;
}
.tl-lunch {
  position: absolute;
  top: 18px; bottom: 0;
  background: repeating-linear-gradient(45deg, rgba(245,158,11,0.18) 0 6px, transparent 6px 12px);
  border-left: 1px dashed var(--warn);
  border-right: 1px dashed var(--warn);
  pointer-events: none;
}
.tl-shift {
  position: absolute;
  top: 22px; height: 38px;
  background: var(--accent);
  border-radius: 5px;
  padding: 2px 6px;
  color: white;
  font-size: 0.72rem;
  line-height: 1.1;
  display: flex; flex-direction: column; justify-content: center;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  transition: filter 0.15s, transform 0.1s;
}
.tl-shift:hover { filter: brightness(1.15); transform: translateY(-1px); }
.tl-shift.locked::after { content: "🔒"; position: absolute; top: 1px; right: 3px; font-size: 0.65rem; }
.tl-shift .who { font-weight: 600; }
.tl-shift .when { font-size: 0.65rem; opacity: 0.9; }

/* Plusieurs shifts en parallele : tracks empilees, le tl s'agrandit */
.tl.tracks-2 { height: 110px; }
.tl.tracks-3 { height: 152px; }
.tl.tracks-4 { height: 194px; }

/* ───── Heures par employé (synthese sous le planning) ───── */
.hours-summary { margin-top: 0.5rem; }
.hbar-wrap { position: relative; background: var(--surface-2); border-radius: 4px; height: 18px; overflow: hidden; }
.hbar { height: 100%; background: var(--accent-2); transition: width 0.2s; }
.hbar.under { background: var(--warn); }
.hbar.empty { background: var(--danger); }
.hbar.over { background: var(--danger); }
.hbar-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; color: white; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.hours-status { font-size: 0.8rem; }
.hours-status.ok { color: var(--accent-2); }
.hours-status.under { color: var(--warn); }
.hours-status.empty { color: var(--danger); }
.hours-status.over { color: var(--danger); }

/* ───── Drawer config ───── */
.config-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.config-drawer[hidden] { display: none; }
.config-drawer.open { transform: translateX(0); }
.drawer-header { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.drawer-header h2 { margin: 0; font-size: 1.1rem; }
.drawer-nav { display: flex; gap: 0.3rem; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; flex-shrink: 0; }
.drawer-nav button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.drawer-nav button.active { background: var(--accent); border-color: var(--accent); color: white; }
.drawer-nav button.ok { border-color: var(--accent-2); }
.drawer-nav button .step { background: rgba(0,0,0,0.2); color: inherit; padding: 1px 6px; border-radius: 99px; font-size: 0.65rem; }
.drawer-nav button.ok .step { background: var(--accent-2); color: white; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1rem; }

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  opacity: 0; transition: opacity 0.25s;
}
.drawer-backdrop[hidden] { display: none; }
.drawer-backdrop.open { opacity: 1; }

/* ───── Day cards (config Horaires) ───── */
.day-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.6rem;
  background: var(--surface-2);
}
.day-card.closed { opacity: 0.55; }
.day-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.day-card-head strong { font-size: 1.05rem; }
.day-card-head label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); margin: 0; }
.day-card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.7rem; align-items: end; }
.day-card-row .field { margin-bottom: 0; }
.day-card-row .field label { font-size: 0.78rem; margin-bottom: 0.2rem; }
.day-lunch-toggle { margin-top: 0.5rem; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 0.35rem; }
.day-lunch-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.5rem; }
.day-lunch-row.hidden { display: none; }

/* ───── Modal ───── */
.modal-root { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; }
.modal-root[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: min(520px, 92vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; padding: 0 0.4rem; }
.modal-body { padding: 1rem; overflow-y: auto; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* ───── Toast ───── */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--accent-2); padding: 0.6rem 1rem; border-radius: 6px; z-index: 400; display: none; max-width: 90vw; }
#toast.show { display: block; }
#toast.err { border-color: var(--danger); color: var(--danger); }

/* ───── Banners ───── */
.warning { background: rgba(245, 158, 11, 0.12); border: 1px solid var(--warn); color: var(--warn); padding: 0.5rem 0.8rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.85rem; }
.info-banner { background: rgba(16, 185, 129, 0.1); border: 1px solid var(--accent-2); color: var(--accent-2); padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }

@media (max-width: 700px) {
  header h1 { font-size: 1rem; }
  .input-row { grid-template-columns: 1fr; }
  .tl { height: 70px; }
  .tl.tracks-2 { height: 120px; }
  .tl.tracks-3 { height: 170px; }
  .tl-shift { font-size: 0.65rem; }
}
