/* Charte Drone Cast Company : noir, bleu #00AAFF, Poppins, titres techno */
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("fonts/poppins-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("fonts/poppins-500.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("fonts/poppins-600.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-display: swap; src: url("fonts/poppins-700.woff2") format("woff2"); }
@font-face { font-family: "Michroma"; font-weight: 400; font-display: swap; src: url("fonts/michroma-400.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #121212;
  --surface: #1c1c1c;
  --surface-2: #2a2a2a;
  --text: #fffffe;
  --muted: #b0b0b0;
  --line: #343434;
  --accent: #00aaff;
  --accent-text: #000000;
  --accent-soft: #00314a;
  --danger: #ff8a80;
  --danger-soft: #45201d;
  --ok: #6fd6a2;
  --ok-soft: #173a2a;
  --warn: #f0c261;
  --warn-soft: #40310f;
  --nav-bg: #000000;
  --nav-text: #d4d4d4;
  --nav-active: #00aaff;
  --nav-active-bg: #00263a;
  --radius: 14px;
  --font-title: "Michroma", "Poppins", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16.5px/1.45 "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Navigation */
#nav {
  background: var(--nav-bg);
  display: flex;
  flex: none;
  /* Sur téléphone, les onglets défilent horizontalement au lieu de se comprimer. */
  overflow-x: auto;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  scrollbar-width: none;
}

#nav::-webkit-scrollbar { display: none; }

.nav-brand { display: none; }

.nav-btn {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 12px;
  color: var(--nav-text);
  display: flex;
  flex: 1 0 72px;
  flex-direction: column;
  font-size: 13px;
  gap: 2px;
  min-height: 56px;
  justify-content: center;
  padding: 4px;
}

.nav-btn svg { height: 25px; width: 25px; }

.nav-btn[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active); font-weight: 600; }

/* Barre latérale en paysage */
@media (min-width: 1000px) {
  body { flex-direction: row; }
  #nav {
    flex-direction: column;
    gap: 6px;
    justify-content: flex-start;
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    width: 196px;
  }
  #nav { border-right: 1px solid var(--line); overflow-x: hidden; overflow-y: auto; }
  .nav-brand { display: block; padding: 0 6px 12px; }
  .nav-brand img { display: block; height: auto; width: 100%; }
  .page-logo { display: none; }
  .nav-btn {
    flex: none;
    flex-direction: row;
    font-size: 17px;
    gap: 12px;
    justify-content: flex-start;
    padding: 8px 12px;
  }
  .nav-btn.nav-end { margin-top: auto; }
}

#main {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(20px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 32px 24px;
}

#main.is-notes {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 12px;
}

.wrap { margin: 0 auto; max-width: 1040px; }

/* Titres */
.page-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
}

h1 { font-family: var(--font-title); font-size: 25px; font-weight: 400; line-height: 1.25; margin: 0; }

.page-logo { flex: none; height: 72px; width: 120px; }

.domain-title { color: var(--accent); font-family: var(--font-title); font-size: 15px; font-weight: 400; letter-spacing: .02em; }

.domain-tops { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-bottom: 16px; }

.domain-tops .card { padding: 6px 16px; }

.domain-tops .row-title { color: var(--accent); font-family: var(--font-title); font-size: 15px; font-weight: 400; }

.sub { color: var(--muted); margin: 2px 0 0; }

h2 { font-size: 19px; margin: 0 0 10px; }

h3 {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  margin: 22px 0 8px;
}

/* Cartes */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card-head { align-items: baseline; display: flex; justify-content: space-between; gap: 10px; }

.empty { color: var(--muted); margin: 6px 0; }

/* Boutons */
.btn {
  align-items: center;
  background: var(--surface-2);
  border: 0;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  font-weight: 600;
  gap: 6px;
  justify-content: center;
  min-height: 46px;
  padding: 8px 16px;
}

.btn.primary { background: var(--accent); color: var(--accent-text); }

.btn.danger { background: var(--danger-soft); color: var(--danger); }

.btn.outline { background: none; border: 2px solid var(--text); }

.btn.link { background: none; color: var(--accent); min-height: 44px; padding: 8px; }

.btn:disabled { opacity: .45; }

/* Champs : 16 px minimum, sinon iOS zoome sur la page */
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 17px;
  min-height: 46px;
  padding: 8px 12px;
  width: 100%;
}

textarea { min-height: 96px; resize: vertical; }

input[type="checkbox"] { height: 26px; min-height: 0; width: 26px; flex: none; }

.quick-add { display: grid; gap: 10px; grid-template-columns: 1fr 170px auto auto; align-items: center; }

.check-label { align-items: center; display: flex; gap: 8px; min-height: 46px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

.toolbar input[type="search"] { flex: 1 1 240px; width: auto; }

.chip {
  background: var(--surface-2);
  border: 0;
  border-radius: 999px;
  font-size: 15px;
  min-height: 44px;
  padding: 6px 15px;
}

.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }

/* Lignes de liste */
.list { display: flex; flex-direction: column; }

.row { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 8px; min-height: 58px; }

.row:first-child { border-top: 0; }

.check {
  align-items: center;
  background: none;
  border: 0;
  display: flex;
  flex: none;
  height: 48px;
  justify-content: center;
  padding: 0;
  width: 44px;
}

.check span {
  align-items: center;
  border: 2px solid var(--muted);
  border-radius: 50%;
  color: transparent;
  display: flex;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.check[aria-pressed="true"] span { background: var(--ok); border-color: var(--ok); color: var(--surface); }

.row-main {
  background: none;
  border: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 56px;
  justify-content: center;
  min-width: 0;
  padding: 7px 0;
  text-align: left;
}

.row-title { font-weight: 500; overflow-wrap: anywhere; }

.row-sub { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }

.is-done .row-title { color: var(--muted); text-decoration: line-through; }

.row-action {
  align-items: center;
  background: var(--surface-2);
  border-radius: 10px;
  color: var(--accent);
  display: inline-flex;
  flex: none;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  padding: 6px 12px;
  text-decoration: none;
}

.date-block {
  background: var(--accent-soft);
  border-radius: 10px;
  flex: none;
  font-size: 13px;
  line-height: 1.1;
  padding: 7px 4px;
  text-align: center;
  width: 58px;
}

.date-block b { display: block; font-size: 21px; }

.badge {
  background: var(--surface-2);
  border-radius: 7px;
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  margin-right: 5px;
  padding: 1px 7px;
  white-space: nowrap;
}

.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.domain { background: none; border: 1px solid var(--accent); color: var(--accent); }

.notice {
  align-items: center;
  background: var(--warn-soft);
  border-radius: var(--radius);
  color: var(--warn);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 10px 16px;
}

.notice .btn { background: var(--surface); color: var(--text); }

/* Pointeuse */
.clock { align-items: center; display: flex; flex-direction: column; gap: 10px; padding: 8px 0; text-align: center; }

.clock-time { font-size: 50px; font-variant-numeric: tabular-nums; font-weight: 700; line-height: 1.1; }

.clock-state { color: var(--muted); }

.clock-btn { font-size: 20px; max-width: 420px; min-height: 68px; width: 100%; }

.clock-btn.stop { background: var(--danger); color: var(--surface); }

.stats { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 12px; }

.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; }

.stat b { display: block; font-size: 25px; font-variant-numeric: tabular-nums; }

.stat span { color: var(--muted); font-size: 15px; }

.punch-mini { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }

.punch-mini .clock-time { font-size: 32px; }

/* Connexion */
body.signed-out #nav { display: none; }

.login {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8vh auto 0;
  max-width: 460px;
  padding: 28px;
  text-align: center;
}

.login img { height: auto; max-width: 240px; width: 70%; }

.login-btn { margin-top: 10px; width: 100%; }

.who { color: var(--muted); display: block; font-size: 13px; }

p .who { display: inline; margin-left: 4px; }

/* Alertes de pointage */
.notice.alert { background: var(--danger-soft); color: var(--danger); }

/* Équipe */
.team-card { margin-bottom: 12px; padding: 4px 16px; }

.team-card summary { align-items: center; cursor: pointer; display: flex; flex-wrap: wrap; gap: 10px; min-height: 60px; }

.team-name { display: flex; flex: 1 1 200px; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

.team-name .sub { font-size: 14px; margin: 0; }

.team-total { font-size: 20px; font-variant-numeric: tabular-nums; }

/* Météo */
.verdict { border-left: 6px solid; border-radius: 10px; display: flex; flex-direction: column; padding: 10px 14px; }
.verdict b { font-size: 21px; }
.verdict span { font-size: 15px; }
.verdict.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.verdict.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.verdict.danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.wx-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.wx-coords { font-variant-numeric: tabular-nums; margin: 4px 0; }

.table-scroll { overflow-x: auto; }

.wx-table { border-collapse: collapse; font-size: 15px; min-width: 100%; white-space: nowrap; }
.wx-table th { color: var(--muted); font-weight: 500; text-align: left; }
.wx-table th, .wx-table td { border-top: 1px solid var(--line); padding: 8px 12px 8px 0; }
.wx-table thead th { border-top: 0; }
.wx-table .badge { margin: 0; }

.wx-source { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.wx-source a { color: var(--accent); }

/* Checklists */
.progress { background: var(--surface-2); border-radius: 999px; height: 8px; margin: 4px 0 8px; overflow: hidden; }

.progress span { background: var(--accent); display: block; height: 100%; }

.check-add { display: flex; gap: 8px; margin-top: 12px; }

.check-add input { flex: 1; min-width: 0; }

button.row-action { border: 0; color: var(--muted); }

button.row-action[data-act^="approve"] { background: var(--accent); color: var(--accent-text); }

/* Notes */
.note-bar { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.note-bar select { flex: 1 1 170px; width: auto; }

.note-bar input { flex: 1 1 170px; width: auto; }

.tool {
  align-items: center;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 12px;
  display: inline-flex;
  font-size: 15px;
  justify-content: center;
  min-height: 46px;
  min-width: 46px;
  padding: 4px 10px;
}

.tool[aria-pressed="true"] { border-color: var(--accent); font-weight: 600; }

.tool:disabled { opacity: .4; }

.swatch { border: 2px solid #ffffff; border-radius: 50%; display: block; height: 26px; width: 26px; }

.dot { background: currentColor; border-radius: 50%; display: block; }

.paper-wrap {
  align-items: center;
  display: flex;
  flex: 1;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

#paper {
  background: #fffefb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

/* Fenêtre de saisie */
dialog {
  background: var(--surface);
  border: 0;
  border-radius: 18px;
  color: var(--text);
  max-height: 88dvh;
  max-width: 560px;
  padding: 22px;
  width: calc(100% - 32px);
}

dialog::backdrop { background: rgba(5, 15, 25, .5); }

dialog h2 { font-size: 22px; margin-bottom: 14px; }

.field { display: block; margin-bottom: 12px; }

.field > span { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }

.field-check { align-items: center; display: flex; gap: 10px; margin-bottom: 12px; min-height: 46px; }

.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.dialog-actions .spacer { flex: 1; }

.form-error { color: var(--danger); font-weight: 600; margin: 8px 0 0; }

.form-error:empty { display: none; }

#toast {
  background: #000000;
  border: 1px solid var(--accent);
  border-radius: 12px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  color: #ffffff;
  font-weight: 600;
  left: 50%;
  max-width: calc(100% - 32px);
  opacity: 0;
  padding: 10px 18px;
  pointer-events: none;
  position: fixed;
  transform: translateX(-50%);
  transition: opacity .2s;
  z-index: 10;
}

#toast.show { opacity: 1; }

@media (max-width: 700px) {
  #main { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .quick-add { grid-template-columns: 1fr 1fr; }
  .quick-add > :first-child { grid-column: 1 / -1; }
  .nav-btn { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
