/* Alfred Stucki SA — Feuille d'heures */
:root {
  --blue: #16365c;
  --blue-2: #24507f;
  --blue-soft: #e8eef6;
  --ink: #1b1f24;
  --muted: #5d6670;
  --line: #d5dbe2;
  --bg: #f3f5f8;
  --card: #ffffff;
  --atelier: #8a5a00;
  --atelier-bg: #fff3d6;
  --chantier: #1f6b3a;
  --chantier-bg: #ddf3e4;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --radius: 14px;
  --tap: 52px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

.demo-banner {
  position: sticky; top: 0; z-index: 50;
  background: #ffd23f; color: #3a2a00;
  font-weight: 700; font-size: .85rem; text-align: center;
  padding: 6px 12px; border-bottom: 2px solid #c79a00;
}
.config-error {
  background: var(--danger); color: #fff; padding: 16px; font-weight: 700; text-align: center;
}

.view { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }
.center { min-height: 60vh; display: flex; align-items: center; justify-content: center; }

/* ---------- Formulaires ---------- */
label, .label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=date], textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
textarea { resize: vertical; min-height: 88px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue-2); box-shadow: 0 0 0 3px #24507f33; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 24px; height: 24px; flex: none; }
.hint { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.error { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: 10px 14px; font-weight: 600; margin: 14px 0 0; }
.ok { background: var(--chantier-bg); color: var(--chantier); }

.pw-wrap { display: flex; gap: 8px; }
.pw-wrap input { flex: 1; min-width: 0; }
.pw-toggle {
  flex: none; font: inherit; font-size: .9rem; padding: 0 14px; border-radius: 10px;
  border: 2px solid var(--line); background: #fff; color: var(--blue); cursor: pointer;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px;
  font: inherit; font-weight: 600;
  border-radius: 12px; border: 2px solid var(--line);
  background: #fff; color: var(--blue);
  cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-big { width: 100%; min-height: 60px; font-size: 1.1rem; margin-top: 16px; }
.btn-round { width: var(--tap); padding: 0; font-size: 1.8rem; line-height: 1; border-radius: 50%; }

/* ---------- Connexion ---------- */
.login-card {
  background: var(--card); border-radius: var(--radius); padding: 28px 22px;
  margin-top: 6vh; box-shadow: 0 2px 14px #16365c14;
}
.login-card h1 { text-align: center; margin-top: 10px; }
.login-logo { display: block; margin: 0 auto; }
.company { text-align: center; color: var(--muted); margin: -4px 0 8px; }

/* ---------- En-tête ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 0 10px;
}
.who { display: flex; flex-direction: column; min-width: 0; }
.who-name { font-weight: 700; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-company { color: var(--muted); font-size: .85rem; }

.tabs { display: flex; gap: 6px; background: #e3e8ef; padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tab {
  flex: 1; min-height: 46px; font: inherit; font-weight: 600; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.tab.active { background: #fff; color: var(--blue); box-shadow: 0 1px 4px #0001; }

.owner-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--blue-soft); border-radius: 12px; padding: 4px 12px 4px 0; margin-bottom: 8px;
}

/* ---------- Mois ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.month-nav h2 { margin: 0; text-align: center; flex: 1; text-transform: capitalize; }

.total-card {
  background: var(--blue); color: #fff; border-radius: var(--radius);
  padding: 16px 20px; text-align: center;
}
.total-label { opacity: .85; font-size: .95rem; }
.total-value { font-size: 2.1rem; font-weight: 800; letter-spacing: .5px; }
.total-dec { font-size: 1.05rem; opacity: .95; }

/* ---------- Jours et lignes ---------- */
.day-list { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; background: var(--card); border-radius: var(--radius); }
.day { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 6px #16365c10; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 12px 16px; background: var(--blue-soft);
}
.day-name { font-weight: 700; text-transform: capitalize; }
.day-total { font-weight: 700; white-space: nowrap; }
.day-total small { font-weight: 500; color: var(--muted); }
.line {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 12px 16px; border-top: 1px solid var(--line);
  width: 100%; text-align: left; font: inherit; color: inherit; background: #fff; border-left: 0; border-right: 0; border-bottom: 0;
}
button.line { cursor: pointer; }
button.line:active { background: #f6f8fb; }
.line-main { min-width: 0; }
.line-desc { font-weight: 600; overflow-wrap: anywhere; }
.line-where { color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.line-dur { text-align: right; font-weight: 700; white-space: nowrap; }
.line-dur small { display: block; font-weight: 500; color: var(--muted); }
.badge {
  display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  margin-right: 6px; vertical-align: 1px; text-transform: uppercase; letter-spacing: .3px;
}
.badge-atelier { background: var(--atelier-bg); color: var(--atelier); }
.badge-chantier { background: var(--chantier-bg); color: var(--chantier); }

.export-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.export-row .btn { flex: 1 1 200px; }

/* ---------- Responsable ---------- */
.staff-list { display: flex; flex-direction: column; gap: 10px; }
.staff {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  border: 0; width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer;
  box-shadow: 0 1px 6px #16365c10;
}
.staff.inactive { opacity: .6; }
.staff-name { font-weight: 700; }
.staff-sub { color: var(--muted); font-size: .88rem; }
.staff-hours { text-align: right; font-weight: 700; white-space: nowrap; }
.staff-hours small { display: block; color: var(--muted); font-weight: 500; }
.tag { font-size: .75rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: #e3e8ef; color: var(--muted); margin-left: 6px; }
.tag-off { background: var(--danger-bg); color: var(--danger); }

/* ---------- Fenêtres ---------- */
dialog {
  border: 0; padding: 0; color: inherit; background: var(--card);
  border-radius: 18px; box-shadow: 0 10px 40px #0004;
}
dialog::backdrop { background: #0d1a2b88; }
dialog.sheet { width: min(640px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); }
dialog.sheet form { padding: 20px 18px 22px; overflow-y: auto; max-height: calc(100dvh - 16px); }
dialog.small-dialog { width: min(420px, calc(100vw - 32px)); }
dialog.small-dialog form { padding: 22px 18px 18px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.sheet-actions .btn-big { margin-top: 0; }
.row-actions { display: flex; gap: 10px; }
.row-actions .btn { flex: 1; }
#userManageFields .btn { width: 100%; margin-top: 10px; }

.seg { display: flex; gap: 10px; }
.seg-btn { flex: 1; margin: 0; }
.seg-btn input { position: absolute; opacity: 0; pointer-events: none; }
.seg-btn span {
  display: flex; align-items: center; justify-content: center;
  min-height: 58px; border-radius: 12px; border: 2px solid var(--line);
  font-weight: 700; font-size: 1.05rem; cursor: pointer; background: #fff; color: var(--muted);
}
.seg-btn input:focus-visible + span { box-shadow: 0 0 0 3px #24507f55; }
.seg-btn input[value=atelier]:checked + span { background: var(--atelier-bg); border-color: var(--atelier); color: var(--atelier); }
.seg-btn input[value=chantier]:checked + span { background: var(--chantier-bg); border-color: var(--chantier); color: var(--chantier); }

.duration { display: flex; gap: 12px; }
.dur-part { flex: 1; display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.dur-part select { font-size: 1.3rem; font-weight: 700; text-align: center; }
.dur-dec { margin: 8px 0 0; font-weight: 700; color: var(--blue); font-size: 1.05rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #1b1f24; color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600;
  z-index: 100; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 4px 20px #0004;
}
.toast.bad { background: var(--danger); }

/* ---------- Impression ---------- */
.print-area { display: none; }

@media print {
  @page { size: A4 portrait; margin: 12mm 10mm; }
  body { background: #fff; font-size: 10pt; padding: 0; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; color: #000; }
  .p-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #000; padding-bottom: 4mm; margin-bottom: 4mm; }
  .p-company { font-size: 15pt; font-weight: 800; }
  .p-title { font-size: 12pt; font-weight: 700; }
  .p-meta { text-align: right; font-size: 10.5pt; line-height: 1.5; }
  .p-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .w-date { width: 15%; } .w-ac { width: 6%; } .w-ac2 { width: 7%; } .w-client { width: 20%; }
  .w-dur { width: 9%; } .w-dec { width: 8%; }
  .p-table th, .p-table td { border: 1px solid #000; padding: 1.4mm 1.6mm; vertical-align: top; overflow-wrap: anywhere; }
  .p-table th { background: #e6e6e6; font-size: 8.5pt; text-align: center; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-table td.c { text-align: center; }
  .p-table td.r { text-align: right; white-space: nowrap; }
  .p-table tr { break-inside: avoid; }
  .p-table tr.p-daysep td { border-top: 1.6pt solid #000; }
  .p-table tfoot td { font-weight: 800; font-size: 11pt; background: #f0f0f0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-sum { margin-top: 5mm; display: flex; gap: 10mm; font-size: 10.5pt; }
  .p-sign { margin-top: 12mm; display: flex; gap: 12mm; }
  .p-sign div { flex: 1; border-top: 1px solid #000; padding-top: 2mm; font-size: 9.5pt; }
  .p-foot { margin-top: 6mm; font-size: 8pt; color: #444; }
  .p-demo { border: 2px solid #000; padding: 2mm; font-weight: 800; text-align: center; margin-bottom: 3mm; }
}
