/* =============================================================================
   CRM EcoThatch — 02-base.css
   -----------------------------------------------------------------------------
   Pièces communes : en-tête, boutons, champs, bandeaux, toasts, statistiques.
   ========================================================================== */

/* ============================ EN-TÊTE ==================================== */

header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  min-height: var(--h-entete);
  background: rgba(20, 26, 43, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .2px;
  white-space: nowrap;
}

.brand .logo { font-size: 20px; }

.search-box { flex: 1 1 200px; min-width: 160px; }

.search-box input,
.control,
.mini-sel {
  width: 100%;
  padding: 8px 11px;
  background: var(--panel);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.control, .mini-sel { width: auto; }
.mini-sel { padding: 3px 7px; font-size: 12px; }

.search-box input::placeholder { color: var(--muted); }

/* Sélecteur segmenté (Tableau / Liste) */
.seg {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.seg button {
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  border: 0;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }

/* Identité du compte connecté */
.moi {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.moi .role {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.moi .role.admin   { background: var(--accent); color: #fff; }
.moi .role.vendeur { background: var(--panel2); color: var(--muted); }

/* ============================ BOUTONS ==================================== */

.btn {
  padding: 9px 15px;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .05s;
}

.btn:hover  { background: var(--accent2); }
.btn:active { transform: translateY(1px); }

.btn.ghost {
  background: var(--panel);
  color: var(--txt);
  border-color: var(--line);
}

.btn.ghost:hover { background: var(--panel2); }

.btn.sm { padding: 6px 11px; font-size: 13px; }

.btn.danger { background: var(--alert); }
.btn.danger:hover { background: #c73b40; }

.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
}

.icon-btn:hover { background: var(--panel2); }

/* Bouton flottant « nouvelle fiche » */
.fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 45;
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.fab:hover { background: var(--accent2); }

/* ============================ CHAMPS ===================================== */

.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }

.field label { font-size: 13px; color: var(--muted); font-weight: 600; }

.field input,
.field select,
.field textarea {
  padding: 9px 11px;
  background: var(--bg2);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.field textarea { min-height: 84px; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); outline: none; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

@media (max-width: 620px) {
  .grid2 { grid-template-columns: 1fr; }
}

/* Choix par pastilles (priorité, catégorie, sample, vente) */
.picker { display: flex; flex-wrap: wrap; gap: 7px; }

.picker .opt {
  padding: 7px 13px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.picker .opt:hover { border-color: var(--accent); }
.picker .opt.sel { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.sub {
  margin: 20px 0 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ============================ STATISTIQUES =============================== */

.statbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 11px;
  padding: 14px 16px;
}

.stat {
  position: relative;
  padding: 12px 14px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat .n { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat .l { margin-top: 2px; font-size: 12px; color: var(--muted); }

.stat .bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--muted);
}

.stat.all .bar { background: var(--accent); }
.stat.t   .bar { background: var(--s-todo); }
.stat.p   .bar { background: var(--s-progress); }
.stat.d   .bar { background: var(--s-done); }

/* ============================ BANDEAUX =================================== */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: rgba(242, 168, 58, .12);
  border: 1px solid rgba(242, 168, 58, .45);
  border-radius: var(--radius);
  font-size: 14px;
}

.banner.info {
  background: rgba(91, 141, 255, .12);
  border-color: rgba(91, 141, 255, .45);
}

.banner.erreur {
  background: rgba(229, 72, 77, .12);
  border-color: rgba(229, 72, 77, .5);
}

.banner .txt { flex: 1; }

.banner .x {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

/* ============================ TOASTS ===================================== */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 90;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 520px);
  padding: 11px 16px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 14px;
  pointer-events: auto;
}

.toast .undo {
  padding: 3px 10px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ============================ ÉTAT VIDE ================================== */

.empty-all {
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-all .big { font-size: 46px; margin-bottom: 10px; }

/* ============================ CHARGEMENT ================================= */

.chargement {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 70px 20px;
  color: var(--muted);
}

.chargement::before {
  content: "";
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tourne .8s linear infinite;
}

@keyframes tourne { to { transform: rotate(360deg); } }
