/* ──────────────────────────────────────────────────────────────
   Components — primitives UI partagées entre tous les écrans.
   Seulement les composants réutilisés plusieurs fois. Les styles
   spécifiques à un écran (login-card, clients-list, theme-editor…)
   restent dans index.html et seront extraits par écran en J3+.
   ────────────────────────────────────────────────────────────── */

/* ── Boutons ─────────────────────────────────────────────────── */

.btn-primary {
  width: 100%;
  padding: 15px;
  background: var(--primary);
  color: var(--text-inverse);
  border: none;
  border-radius: 12px;
  font-size: var(--text-lg);
  font-weight: 600;
  cursor: pointer;
  margin-top: var(--space-2);
  transition: opacity var(--t), transform 0.1s;
  font-family: inherit;
}
.btn-primary:active   { opacity: 0.85; transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5;  cursor: default; transform: none; }

/* ── Cartes ──────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-body { padding: 16px 20px 20px; }

/* ── Stats (tuiles du haut du dashboard) ─────────────────────── */

.stat-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.stat-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.stat-label {
  font-size: var(--text-xs);
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 500;
}

/* ── Toast (notification flottante bas-centrée) ──────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--primary);
  color: var(--text-inverse);
  padding: 11px 20px;
  border-radius: var(--radius-full);
  font-size: var(--text-md);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  z-index: var(--z-toast, 999);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Bottom navigation (mobile-first) ────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--separator);
  display: none;
  z-index: var(--z-nav, 100);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -1px 10px rgba(0,0,0,0.04);
}
.bottom-nav.visible { display: flex; }

.bottom-nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: color var(--t);
  min-height: 58px;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.bottom-nav-btn.active      { color: var(--primary); }
.bottom-nav-btn.active svg  { stroke-width: 2.4; }

/* Badge count sur onglet (ex: "Clients 42") — pastille arrondie à droite du label */
.nav-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  min-width: 18px;
  height: 16px;
  line-height: 16px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: 1px;
}
.bottom-nav-btn.active .nav-badge {
  background: rgba(255,255,255,0.85);
  color: var(--primary);
}
html.dark .bottom-nav-btn.active .nav-badge {
  background: var(--surface);
  color: var(--text);
}

/* ── Sidebar desktop (>900px) : la bottom-nav se transforme en rail vertical à gauche ── */
@media (min-width: 900px) {
  .bottom-nav {
    /* Position fixed à gauche, sous la topbar (64px, min-height fixe dans layout.css). */
    top: 64px;
    bottom: 0;
    right: auto;
    width: 220px;
    flex-direction: column;
    justify-content: flex-start;
    border-top: none;
    border-right: 1px solid var(--separator);
    box-shadow: none;
    padding-top: 16px;
    padding-bottom: 16px;
    gap: 4px;
  }
  .bottom-nav-btn {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding: 12px 20px;
    font-size: 14px;
    min-height: 48px;
    border-radius: 10px;
    margin: 0 10px;
    transition: background var(--t), color var(--t);
    letter-spacing: 0;
    text-transform: none;
  }
  .bottom-nav-btn:hover { background: rgba(0,0,0,0.04); color: var(--text); }
  .bottom-nav-btn.active {
    background: var(--primary);
    color: var(--text-inverse);
  }
  .bottom-nav-btn.active svg { stroke-width: 2; }
  .bottom-nav-btn svg { width: 20px; height: 20px; }

  /* Le container principal laisse la place pour la sidebar */
  #dashboard-screen.tabbed .main {
    margin-left: 220px;
    padding-bottom: 40px; /* plus besoin du gros padding bottom en desktop */
    max-width: 780px;
  }
}

/* Dark mode : sidebar plus subtile */
html.dark .bottom-nav {
  background: var(--card);
  border-top-color: var(--separator);
}
@media (min-width: 900px) {
  html.dark .bottom-nav-btn:hover { background: rgba(255,255,255,0.06); }
}

/* ── Skeleton screens (loading placeholders) ─────────────────
   Remplacent les spinners génériques : l'utilisateur voit le
   shape final dès le 1er paint, tout se remplit progressivement.
   Animation shimmer subtile qui passe de gauche à droite. */

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.05) 0%,
    rgba(0, 0, 0, 0.1)  50%,
    rgba(0, 0, 0, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm, 8px);
  color: transparent;
  user-select: none;
  pointer-events: none;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton clients list : 5 rangées factices */
.skeleton-clients-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--separator);
  border-radius: 12px;
  overflow: hidden;
}
.skeleton-client-row {
  background: var(--card);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.skeleton-client-row .skel-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  flex-shrink: 0;
}
.skeleton-client-row .skel-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.skeleton-client-row .skel-line-1 { width: 50%; height: 12px; }
.skeleton-client-row .skel-line-2 { width: 70%; height: 10px; }
.skeleton-client-row .skel-pts { width: 28px; height: 20px; border-radius: 4px; }
.skeleton-client-row .skel-btn { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }

/* Skeleton stats row : 3 tuiles factices */
.skeleton-stat-value {
  display: inline-block;
  width: 40px;
  height: 28px;
  border-radius: 4px;
  vertical-align: middle;
}

/* Skeleton generic row (pour rewards, notif history, etc.) */
.skeleton-row {
  height: 44px;
  margin-bottom: 8px;
}

/* ── Counter flash (animation +1 point quand le chiffre change) ─
   Pulse rapide en vert/couleur du thème pour feedback immédiat. */
@keyframes counterFlash {
  0%   { transform: scale(1);    color: var(--primary); }
  30%  { transform: scale(1.25); color: var(--green); }
  100% { transform: scale(1);    color: var(--primary); }
}
.counter-flash { animation: counterFlash 0.5s ease-out; }

/* ── Toast avec icône check animé ──────────────────────────── */
.toast.with-check::before {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  margin-right: 8px;
  vertical-align: -3px;
  border-radius: 50%;
  background: var(--green);
  /* Check en background-image SVG inline (contourne CSP unsafe-inline OK pour url()) */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 12 10 18 20 6'/></svg>");
  background-size: 12px 12px;
  background-repeat: no-repeat;
  background-position: center;
  animation: checkPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes checkPop {
  0%   { transform: scale(0);   opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
