/* =========================================================================
   style.css — UI checklist mobile-first
   ========================================================================= */

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --nok: #dc2626;
  --nok-bg: #fee2e2;
  --skip: #d97706;
  --skip-bg: #fef3c7;
  --accent: #2563eb;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: var(--ink);
  color: #fff;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.status-badge {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #374151;
}
.status-badge.ok { background: var(--ok); }
.status-badge.nok { background: var(--nok); }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.btn-reset { background: #4b5563; }
.icon-btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.3rem;
  padding: 6px;
  cursor: pointer;
  line-height: 1;
}

/* --- Controls (filtre + onglets), collés sous la topbar --- */
.controls {
  position: sticky;
  top: calc(54px + var(--safe-top));
  z-index: 9;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

/* --- Filtre rapide --- */
.quickfilter {
  position: relative;
  padding: 8px 10px 0;
}
.catfilter { padding: 8px 10px 0; }
.catfilter .cat-select { width: 100%; }
.qf-input {
  width: 100%;
  padding: 11px 38px 11px 14px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.qf-clear {
  position: absolute;
  right: 18px;
  top: 8px;
  height: calc(100% - 8px);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 6px;
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
  overflow-x: auto;
}
.tab {
  flex: 1 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--ink); border-color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--line);
  font-size: 0.78rem;
  margin-left: 2px;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-nok { background: var(--nok-bg); color: var(--nok); }
.badge-skip { background: var(--skip-bg); color: var(--skip); }

/* --- Liste --- */
.list {
  padding: 10px 10px 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* En-tête de catégorie */
.cat-header {
  margin: 14px 4px 2px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.cat-header:first-child { margin-top: 2px; }

/* Sélecteur de catégorie */
.cat-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.92rem;
  background: #fff;
  color: var(--ink);
  max-width: 100%;
}

.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.item.s-OK { border-left-color: var(--ok); }
.item.s-NOK { border-left-color: var(--nok); }
.item.s-SKIP { border-left-color: var(--skip); }

.item-label {
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  word-break: break-word;
}
.item-del {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 4px;
}

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.seg button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 4px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  min-height: 46px;
}
.seg button.sel-OK { background: var(--ok); color: #fff; border-color: var(--ok); }
.seg button.sel-NOK { background: var(--nok); color: #fff; border-color: var(--nok); }
.seg button.sel-SKIP { background: var(--skip); color: #fff; border-color: var(--skip); }

/* --- FAB --- */
.fab-wrap {
  position: fixed;
  right: 18px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 20;
}
.fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(37,99,235,.45);
  cursor: pointer;
}

/* --- Sheets (bottom) --- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: flex-end;
}
.sheet-inner {
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  padding: 14px 14px calc(20px + var(--safe-bottom));
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; }
.sheet-head .icon-btn { color: var(--ink); }

.search {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 10px;
}
.results { display: flex; flex-direction: column; gap: 6px; }
.result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 12px;
  font-size: 1rem;
  cursor: pointer;
}
.result .tag {
  margin-left: auto;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
}
.result .tag.rec { background: #e0e7ff; color: #4338ca; }

.create-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.btn-create { background: var(--ok); }
.switch { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.switch input { width: 22px; height: 22px; }

/* --- Manage list --- */
.manage-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.manage-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.manage-item .m-main { display: flex; align-items: center; gap: 10px; }
.manage-item.archived { opacity: .55; }
.manage-item .m-label { flex: 1; font-weight: 600; word-break: break-word; }
.manage-item .cat-select { width: 100%; }
.manage-item .switch span { display: none; }
.manage-item button {
  border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; color: var(--muted);
}

/* --- Toast --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

/* --- Plein écran simple --- */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card { background: var(--card); border-radius: var(--radius); padding: 26px; text-align: center; max-width: 380px; }
.card h1 { margin-top: 0; }
