:root {
  --bg: #14110f;
  --surface: #211b17;
  --surface-2: #2b231d;
  --border: #3a2f27;
  --accent: #f5a623;       /* travail */
  --accent-dim: #8a5d1f;
  --break: #5fb3b3;        /* pause */
  --break-dim: #3a6e6e;
  --danger: #e2574c;
  --text: #f2ece4;
  --text-dim: #9c948a;
  --radius: 14px;
  --mono: 'Space Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a { color: var(--accent); }

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
}

.sync-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--danger);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
}

.sync-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

.hidden { display: none !important; }

/* ---------- Layout / navigation ---------- */

.layout {
  flex: 1;
  display: flex;
  width: 100%;
}

.nav-sidebar {
  display: none;
}

.nav-bottom {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  padding: 8px 0 6px;
  font-size: 0.7rem;
}

.nav-btn .icon { font-size: 1.3rem; line-height: 1; }
.nav-btn.active { color: var(--accent); }

#content {
  flex: 1;
  min-width: 0;
  padding: 16px;
  padding-bottom: 84px; /* place pour la nav du bas */
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Bureau : sidebar à gauche, pas de nav en bas ---------- */

@media (min-width: 860px) {
  .nav-bottom { display: none; }

  .nav-sidebar {
    display: flex;
    flex-direction: column;
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    padding: 18px 0;
    gap: 4px;
  }

  .nav-sidebar .nav-btn {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 22px;
    font-size: 0.95rem;
    border-radius: 0;
  }

  .nav-sidebar .nav-btn.active {
    background: var(--surface-2);
    border-right: 3px solid var(--accent);
  }

  #content {
    padding: 28px 32px;
    padding-bottom: 28px;
    max-width: 920px;
    margin: 0 auto;
  }
}

/* ---------- Onglet Pointage ---------- */

.pointage-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding-top: 12px;
}

.clock-face {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, var(--surface-2), var(--surface));
  border: 6px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 0 0 6px rgba(245, 166, 35, 0.06);
  transition: box-shadow 0.3s ease;
}

.clock-face.is-active { box-shadow: 0 0 0 8px rgba(245, 166, 35, 0.16); border-color: var(--accent-dim); }
.clock-face.is-paused { box-shadow: 0 0 0 8px rgba(95, 179, 179, 0.18); border-color: var(--break-dim); }

.clock-state {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.clock-time {
  font-family: var(--mono);
  font-size: 2.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.clock-sub {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.pointage-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.btn-start { background: var(--accent); color: #1a1310; }
.btn-pause { background: var(--break); color: #0e2424; }
.btn-resume { background: var(--accent); color: #1a1310; }
.btn-end { background: var(--surface-2); color: var(--danger); border: 1px solid var(--danger); }
.btn-secondary { background: var(--surface-2); color: var(--text); width: 100%; justify-content: center; margin-top: 12px; }

.shift-details {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
}

.detail-row .label { color: var(--text-dim); }
.detail-row .value { font-family: var(--mono); display: flex; align-items: center; gap: 6px; }

.pin-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.95rem;
  padding: 0 0 0 4px;
}

.break-row .value { color: var(--break); }

/* ---------- Onglet Calendrier ---------- */

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.week-nav {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  font-size: 1.2rem;
}

.week-label {
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  flex: 1;
}

/* Vue liste — mobile */

.calendar-list { display: flex; flex-direction: column; gap: 10px; }

.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.day-card.is-today { border-color: var(--accent-dim); }

.day-heading {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 8px;
  text-transform: capitalize;
}

.day-empty {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.shift-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px dashed var(--border);
}

.shift-row:first-of-type { border-top: none; }

.shift-row .time-range {
  font-family: var(--mono);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.shift-row .sub-line {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  gap: 14px;
}

.sub-line .work { color: var(--accent); }
.sub-line .break { color: var(--break); }

/* Vue grille type Google Calendar — bureau uniquement */

.calendar-grid-wrap { display: none; }

@media (min-width: 860px) {
  .calendar-list { display: none; }

  .calendar-grid-wrap {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 70vh;
    background: var(--surface);
  }

  .calendar-grid {
    display: grid;
    grid-template-columns: 56px repeat(7, 1fr);
    position: relative;
  }

  .grid-col-header {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
    padding: 8px 4px;
    text-align: center;
    font-size: 0.76rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    text-transform: capitalize;
  }

  .grid-corner {
    position: sticky;
    top: 0;
    left: 0;
    background: var(--surface);
    z-index: 3;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .grid-col-header.is-today { color: var(--accent); }

  .grid-hour-labels {
    grid-column: 1;
    border-right: 1px solid var(--border);
  }

  .grid-hour-label {
    height: 32px;
    box-sizing: border-box;
    font-size: 0.65rem;
    color: var(--text-dim);
    text-align: right;
    padding-right: 6px;
    transform: translateY(-7px);
  }

  .grid-day-col {
    position: relative;
    height: 768px;
    border-right: 1px solid var(--border);
    background-image: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      var(--border) 31px,
      var(--border) 32px
    );
  }

  .shift-block {
    position: absolute;
    left: 3px;
    right: 3px;
    border-radius: 6px;
    font-size: 0.66rem;
    padding: 3px 5px;
    overflow: hidden;
    color: #14110f;
  }

  .shift-block.work { background: var(--accent); }
  .shift-block.break { background: var(--break); }
}

/* ---------- Onglet À venir ---------- */

.future-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}

.future-icon { font-size: 2.4rem; }

/* ---------- Modal carte ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* La carte peut s'ouvrir par-dessus une autre modal déjà affichée (détail d'un
   pointage) : elle doit alors passer au-dessus, pas rester dessous. */
#map-modal { z-index: 600; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  width: min(92vw, 480px);
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--surface-2);
  border: none;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  z-index: 2;
}

#map-container {
  width: 100%;
  height: 280px;
  border-radius: 10px;
  overflow: hidden;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 200;
}

@media (min-width: 860px) {
  .toast { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Écran de connexion / création de compte ---------- */

.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
  z-index: 500;
}

.auth-card {
  width: min(100%, 380px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.auth-logo { font-size: 2.4rem; line-height: 1; margin-bottom: 4px; }
.auth-title { font-size: 1.2rem; margin: 0 0 4px; }
.auth-sub { color: var(--text-dim); font-size: 0.82rem; text-align: center; margin: 0 0 10px; }

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.auth-submit { justify-content: center; width: 100%; margin-top: 4px; }

/* ---------- Champs de formulaire (partagés) ---------- */

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

input[type="text"],
input[type="email"],
input[type="password"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 0.95rem;
  font-family: var(--sans);
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input:disabled {
  opacity: 0.6;
}

.form-msg {
  font-size: 0.82rem;
  margin: -4px 0 0;
}

.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--accent); }

/* ---------- Onglet Compte ---------- */

.account-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  max-width: 420px;
  margin: 0 auto;
}

.avatar-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.avatar-preview {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder { font-size: 2.4rem; color: var(--text-dim); }
.avatar-btn { width: auto; }

.account-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.account-section-title {
  font-size: 0.9rem;
  margin: 0 0 4px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#logout-btn { width: 100%; justify-content: center; }

/* ---------- Icône avatar dans la navigation ---------- */

.nav-avatar-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* ---------- Modal de détail d'un pointage ---------- */

.shift-modal-title {
  font-size: 1rem;
  margin: 0 0 14px;
  text-transform: capitalize;
  padding-right: 30px;
}

.shift-row.clickable,
.shift-block {
  cursor: pointer;
}

.overnight-note {
  font-style: italic;
}

/* ---------- Champs select (partagés) ---------- */

select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 0.95rem;
  font-family: var(--sans);
}

/* ---------- Onglet Utilisateurs (admin) ---------- */

.users-screen {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 560px;
  margin: 0 auto;
}

.mode-toggle {
  display: flex;
  gap: 8px;
}

.mode-btn {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.mode-btn.active {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-row.is-archived { opacity: 0.55; }

.user-row-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.user-row-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-row-info { flex: 1; min-width: 0; }
.user-row-name { font-weight: 700; font-size: 0.92rem; }
.user-row-sub {
  font-size: 0.76rem;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-admin { background: rgba(245, 166, 35, 0.15); color: var(--accent); }
.badge-user { background: rgba(95, 179, 179, 0.15); color: var(--break); }
.badge-archived { background: rgba(226, 87, 76, 0.15); color: var(--danger); }
.badge-invite { background: var(--surface-2); color: var(--text-dim); }

.user-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 0.95rem;
}

.icon-btn.danger { color: var(--danger); border-color: var(--danger); }

.invite-link-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.78rem;
  font-family: var(--mono);
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
