/* intelliTime */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  /* Palette alignée sur le design system Intellibooster (brand-primary/secondary, slate) */
  --bg: #111827;
  --surface: #1c2536;
  --surface2: #283245;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #48a8f4;
  --accent-strong: #008dd7;
  --danger: #ef5350;
  --ok: #4caf7d;
  --warn: #f0a63d;
}

html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  user-select: none;
}

.hidden { display: none !important; }

/* ---- Barre du haut ---- */
#topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.logo { justify-self: center; font-size: 1.15rem; font-weight: 600; letter-spacing: .3px; }
.logo b { color: var(--accent); font-weight: 800; }
#btn-back {
  justify-self: start; background: none; border: none; color: var(--accent);
  font-size: .95rem; font-weight: 600; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
#btn-back:active { background: var(--surface2); }
#btn-sync {
  justify-self: end; position: relative; font-size: 1.4rem; line-height: 1;
  background: none; border: none; color: var(--text); cursor: pointer; padding: 4px 8px;
  border-radius: 8px;
}
#btn-sync:active { background: var(--surface2); }
#btn-sync.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#sync-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff; border-radius: 10px;
  font-size: .65rem; padding: 1px 5px; font-weight: 700;
}

/* ---- Bandeau activité en cours ---- */
#banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.banner-titre { font-weight: 700; }
.banner-comment { font-size: .85rem; opacity: .9; }
.banner-right { text-align: right; }
#chrono { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.banner-stop { font-size: .75rem; opacity: .85; }

/* ---- Contenu ---- */
#view { flex: 1; overflow-y: auto; padding: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.tile {
  min-height: 92px; border: none; border-radius: 16px; padding: 14px;
  text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  transition: transform .12s ease, box-shadow .12s ease;
}
.tile:active { transform: scale(.96); }
.tile-active { outline: 3px solid #fff; outline-offset: -3px; box-shadow: 0 0 0 4px rgba(255,255,255,.15), 0 2px 8px rgba(0,0,0,.4); }
.tile-nom {
  font-weight: 600; font-size: clamp(.85rem, 1.4vw + .6rem, 1rem);
  line-height: 1.2; overflow-wrap: break-word; word-break: normal; hyphens: auto;
}
.tile-total { font-size: .78rem; font-weight: 600; opacity: .85; }

.subheader {
  margin: -14px -14px 12px; padding: 14px 16px;
  font-weight: 700; font-size: 1.05rem;
}

.liste { display: flex; flex-direction: column; gap: 8px; }
.row {
  background: var(--surface); color: var(--text); border: 1px solid rgba(255,255,255,.05);
  border-radius: 12px; padding: 13px 14px; text-align: left;
  font-size: .95rem; cursor: pointer; transition: background .12s ease;
}
.row:active { background: var(--surface2); }

.link {
  background: none; border: none; color: var(--accent);
  margin-top: 16px; padding: 8px; cursor: pointer; font-size: .9rem; font-weight: 600;
}

.comment-box { margin-bottom: 12px; }
.comment-actions { display: flex; gap: 8px; margin-top: 8px; }
.comment-actions button { flex: 1; }

/* ---- Historique ---- */
.day-header {
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: .85rem; font-weight: 700;
  text-transform: capitalize; margin: 14px 2px 6px;
}
.hist-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid rgba(255,255,255,.05); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 6px; cursor: pointer; transition: background .12s ease;
}
.hist-row:active { background: var(--surface2); }
.hist-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.hist-main { flex: 1; min-width: 0; }
.hist-titre { font-weight: 600; font-size: .92rem; }
.hist-comment { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.hist-heures { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.badge { font-size: .9rem; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.todo { color: var(--accent); }
.legende { color: var(--muted); font-size: .75rem; text-align: center; margin-top: 10px; }

/* ---- Formulaires ---- */
.setup { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.setup h2 { margin-bottom: 2px; }
.setup p { color: var(--muted); font-size: .9rem; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
input {
  background: var(--surface); border: 1px solid var(--surface2); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 1rem; width: 100%;
}
input:focus { outline: 2px solid var(--accent-strong); border-color: transparent; }
details summary { color: var(--muted); font-size: .85rem; cursor: pointer; margin: 4px 0; }
details label { margin-top: 8px; }

button.primary {
  background: var(--accent-strong); color: #fff; font-weight: 700;
  border: none; border-radius: 999px; padding: 13px; font-size: 1rem; cursor: pointer;
  transition: background .15s ease;
}
button.primary:active { background: #0070b3; }
button.danger {
  background: none; border: 1.5px solid var(--danger); color: var(--danger);
  border-radius: 999px; padding: 11px; cursor: pointer; font-weight: 600;
}
.comment-actions button:not(.primary), .dialog-actions button:not(.primary):not(.danger) {
  background: var(--surface); color: var(--text); border: 1px solid var(--surface2);
  border-radius: 999px; padding: 12px; cursor: pointer;
}

.info { background: var(--surface); border: 1px solid rgba(255,255,255,.05); border-radius: 12px; padding: 14px; }
.info p { color: var(--muted); font-size: .85rem; margin: 4px 0; }

.empty { color: var(--muted); text-align: center; margin-top: 40px; line-height: 1.6; }
.empty.small { margin-top: 10px; font-size: .85rem; }

/* ---- Onglets ---- */
#tabs {
  display: flex; background: var(--surface);
  border-top: 1px solid rgba(255,255,255,.06);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#tabs button {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 10px 0 12px; cursor: pointer; font-size: clamp(1.15rem, 1vw + .9rem, 1.7rem);
  display: flex; flex-direction: column; align-items: center; gap: clamp(2px, .3vw, 6px);
}
#tabs button span { font-size: clamp(.68rem, .5vw + .55rem, 1rem); font-weight: 600; }
#tabs button.active { color: var(--accent); }

/* ---- Dialogue d'édition ---- */
dialog {
  background: var(--surface); color: var(--text);
  border: none; border-radius: 16px; padding: 18px;
  width: min(92vw, 420px); margin: auto;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin-bottom: 12px; }
dialog label { margin-bottom: 10px; }
.dialog-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.spacer { flex: 1; }

/* ---- Toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: #000c; color: #fff; padding: 10px 18px; border-radius: 24px;
  font-size: .88rem; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
