/* =====================================================
   MERIDIAN OPS — Design system
   Tokens repris de Meridian Stay, variante "outil" :
   plus dense, orienté lisibilité terrain (mobile, plein soleil).
   ===================================================== */

:root {
  --ink:     #111009;
  --ink-2:   #1B1814;
  --bone:    #EDE6D5;
  --stone:   #918B81;
  --brass:   #C4A55A;
  --gold:    #A8893A;
  --cream:   #F8F4EF;
  --cream-2: #EFE9DF;
  --muted:   #7A7268;

  /* Statuts mission */
  --st-open:     #C4A55A;
  --st-assigned: #5A87C4;
  --st-done:     #6FA06B;
  --st-cancel:   #918B81;

  /* Priorités */
  --prio-urgent: #B4552D;

  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans:  'DM Sans', -apple-system, sans-serif;

  --nav-h:    64px;
  --topbar-h: 56px;
  --safe-b:   env(safe-area-inset-bottom);
  --safe-t:   env(safe-area-inset-top);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* L'attribut hidden doit gagner sur les display: flex des composants */
[hidden] { display: none !important; }

body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding-top: var(--safe-t);
  background: var(--ink);
  color: var(--bone);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 20px; padding-right: 20px;
}
.topbar .brand { font-family: var(--serif); font-size: 20px; letter-spacing: .06em; }
.topbar .brand em { color: var(--brass); font-style: normal; }

main {
  padding: calc(var(--topbar-h) + var(--safe-t) + 16px) 16px
           calc(var(--nav-h) + var(--safe-b) + 24px);
  max-width: 640px; margin: 0 auto;
}

/* ── Vues (une seule visible) ───────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Login ──────────────────────────────────────────── */
.login-card {
  background: #fff; border-radius: 14px; padding: 28px 22px;
  margin-top: 10vh; box-shadow: 0 2px 24px rgba(17,16,9,.07);
}
.login-card h1 { font-family: var(--serif); font-size: 28px; margin-bottom: 4px; }
.login-card p  { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 13px 14px; font-size: 16px;
  border: 1px solid var(--cream-2); border-radius: 10px;
  background: var(--cream); font-family: var(--sans);
}
.field input:focus { outline: 2px solid var(--brass); border-color: transparent; }

.btn {
  display: block; width: 100%; padding: 14px; border: 0; border-radius: 10px;
  background: var(--ink); color: var(--bone); font-size: 15px; font-weight: 600;
  font-family: var(--sans); cursor: pointer;
}
.btn.brass { background: var(--brass); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; }

.form-error { color: var(--prio-urgent); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── Missions : carte ───────────────────────────────── */
.day-header {
  font-family: var(--serif); font-size: 20px; margin: 22px 0 10px;
  text-transform: capitalize;
}

.mission-card {
  background: #fff; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
  border-left: 4px solid var(--villa-color, var(--brass));
  box-shadow: 0 1px 10px rgba(17,16,9,.05);
}
.mission-card .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mission-card .villa { font-weight: 600; font-size: 15px; }
.mission-card .type  { color: var(--muted); font-size: 13px; }
.mission-card .notes { color: var(--muted); font-size: 13px; margin-top: 6px; }

.badge {
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.badge.open     { background: color-mix(in srgb, var(--st-open) 18%, white);     color: var(--gold); }
.badge.assigned { background: color-mix(in srgb, var(--st-assigned) 15%, white); color: var(--st-assigned); }
.badge.done     { background: color-mix(in srgb, var(--st-done) 15%, white);     color: var(--st-done); }
.badge.urgent   { background: var(--prio-urgent); color: #fff; }

.mission-card .actions { margin-top: 12px; display: flex; gap: 8px; }
.mission-card .actions .btn { padding: 11px; font-size: 14px; }

/* ── Bottom nav ─────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--ink); display: flex;
}
.bottom-nav button {
  flex: 1; background: none; border: 0; color: var(--stone);
  font-family: var(--sans); font-size: 11px; letter-spacing: .04em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer;
}
.bottom-nav button.active { color: var(--brass); }
.bottom-nav svg { width: 22px; height: 22px; }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14px; }

/* ── Espace partenaire : Flux du jour ───────────────── */
.topbar-session { display: flex; align-items: center; gap: 12px; }
#logout-btn {
  padding: 6px 13px; border: 1px solid rgba(237,230,213,.3); border-radius: 18px;
  background: transparent; font-family: var(--sans); font-size: 12.5px;
  color: inherit; cursor: pointer;
}

/* En mobile, « Bonjour {prénom} » suffit — on ne répète pas le nom dans la topbar */
@media (max-width: 480px) {
  #topbar-user { display: none; }
}

.hello { margin: 6px 0 18px; }
.hello h1 { font-family: var(--serif); font-size: 26px; }
.hello p  { color: var(--muted); font-size: 14px; margin-top: 2px; }

.section-title {
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.section-title .count {
  background: var(--cream-2); border-radius: 12px; padding: 1px 8px;
  font-weight: 600; color: var(--ink);
}

.badge.late { background: var(--prio-urgent); color: #fff; }

.mission-card .slotline { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mission-card.done-card { opacity: .55; }

/* Bloc accès : UNIQUEMENT présent sur les missions assignées à ce partenaire
   (l'API ne renvoie la donnée que dans ce cas) */
.access-block {
  margin-top: 10px; padding: 10px 12px; border-radius: 9px;
  background: color-mix(in srgb, var(--brass) 12%, white);
  border: 1px dashed color-mix(in srgb, var(--brass) 50%, white);
  font-size: 13.5px; line-height: 1.55;
}
.access-block b { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }

/* ── Disponibilité villas (partenaire) ──────────────── */
.villa-avail {
  background: #fff; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
  border-left: 4px solid var(--villa-color, var(--brass));
  box-shadow: 0 1px 10px rgba(17,16,9,.05);
}
.villa-avail .vname { font-weight: 600; font-size: 15px; }
.villa-avail .vfree { font-size: 13px; color: var(--st-done); font-weight: 600; margin-top: 2px; }
.villa-avail .vfree.none { color: var(--muted); font-weight: 400; }
.avail-strip { display: flex; gap: 2px; margin-top: 10px; }
.avail-day { flex: 1; }
.avail-day .sq {
  height: 16px; border-radius: 3px; background: var(--cream-2);
}
.avail-day.busy .sq { background: color-mix(in srgb, var(--villa-color, var(--stone)) 45%, white); }
.avail-day.today .sq { outline: 2px solid var(--gold); outline-offset: 1px; }
.avail-day .dl { font-size: 8.5px; color: var(--muted); text-align: center; margin-top: 3px; }
.avail-legend { font-size: 12px; color: var(--muted); padding: 4px 2px 14px; }

.toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  left: 50%; transform: translateX(-50%); z-index: 95;
  background: var(--ink); color: var(--bone); border-radius: 10px;
  padding: 11px 20px; font-size: 13.5px; white-space: nowrap;
  box-shadow: 0 8px 30px rgba(17,16,9,.3);
}
