/* ========================================================================
   Rokudan SaaS — Components partagés
   ======================================================================== */

/* —— Boutons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 42px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: all var(--t-fast) var(--ease-out);
  white-space: nowrap;
  cursor: pointer;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
}
.btn-primary:hover { background: var(--ink-3); border-color: var(--ink-3); }

.btn-violet {
  background: var(--violet);
  color: #fff;
  border: 1px solid var(--violet);
  box-shadow: var(--shadow-violet);
}
.btn-violet:hover { background: var(--violet-2); border-color: var(--violet-2); }

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--line-strong); background: var(--cream); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
}
.btn-ghost:hover { background: rgba(10, 10, 10, 0.05); }

.btn-sm { height: 34px; padding: 0 var(--sp-4); font-size: var(--fs-xs); }
.btn-lg { height: 52px; padding: 0 var(--sp-7); font-size: var(--fs-md); }
.btn-icon {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: var(--r-md);
}

/* —— Pills —— */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 26px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: -0.01em;
  background: var(--cream-2);
  color: var(--ink-2);
}
.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.no-dot::before { display: none; }

.pill-violet { background: var(--violet-soft); color: var(--violet-2); }
.pill-green  { background: var(--green-soft); color: var(--green); }
.pill-red    { background: var(--red-soft); color: var(--red); }
.pill-orange { background: var(--orange-soft); color: var(--orange); }
.pill-amber  { background: var(--amber-soft); color: var(--amber); }
.pill-blue   { background: var(--blue-soft); color: var(--blue); }
.pill-pink   { background: var(--pink-soft); color: var(--pink); }
.pill-teal   { background: var(--teal-soft); color: var(--teal); }
.pill-ink    { background: var(--ink); color: #fff; }

/* —— Inputs —— */
.input,
.select,
.textarea {
  width: 100%;
  height: 42px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.textarea { height: auto; padding: var(--sp-3) var(--sp-4); line-height: 1.55; resize: vertical; min-height: 96px; }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 4px var(--violet-mist);
}

.input-search {
  position: relative;
}
.input-search input {
  height: 38px;
  padding-left: var(--sp-9);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  width: 100%;
  font-size: var(--fs-sm);
  color: var(--ink);
}
.input-search svg {
  position: absolute;
  left: var(--sp-4);
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--mute-2);
}

/* —— Card —— */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
}
.card-flat {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
}
.card-soft {
  background: var(--surface-2);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
}

/* —— Stat tile —— */
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--paper);
  border: 1px solid var(--line);
  min-height: 130px;
  position: relative;
}
.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--mute);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.stat-icon {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--cream-2);
}
.stat-icon svg { width: 14px; height: 14px; }
.stat-value {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  letter-spacing: -0.03em;
  font-weight: 400;
  line-height: 1;
}
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}
.stat-trend.up { color: var(--green); }
.stat-trend.down { color: var(--red); }

/* —— Divider —— */
.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: var(--sp-6) 0;
}

/* —— Avatar —— */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--cream-3);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  flex-shrink: 0;
  text-transform: uppercase;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 24px; height: 24px; font-size: 9px; }
.avatar-lg { width: 44px; height: 44px; font-size: 13px; }

.avatar-stack {
  display: inline-flex;
}
.avatar-stack .avatar {
  margin-left: -8px;
  border: 2px solid var(--paper);
}
.avatar-stack .avatar:first-child { margin-left: 0; }

/* —— Tag —— */
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  background: var(--cream-2);
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* —— Progress —— */
.progress {
  width: 100%;
  height: 6px;
  background: var(--cream-3);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: var(--r-pill);
  transition: width 600ms var(--ease-out);
}
.progress.violet > span { background: linear-gradient(90deg, var(--violet) 0%, #9C7BFF 100%); }
.progress.green > span { background: var(--green); }
.progress.orange > span { background: var(--orange); }

/* —— Tooltip simple —— */
[data-tip] { position: relative; }

/* —— Toggle —— */
.toggle {
  position: relative;
  width: 38px;
  height: 22px;
  background: var(--cream-3);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-base) var(--ease-spring);
}
.toggle.on { background: var(--ink); }
.toggle.on::after { transform: translateX(16px); }

/* —— Tabs —— */
.tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  gap: 2px;
}
.tab {
  height: 32px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--mute);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
}
.tab:hover { color: var(--ink); }
.tab.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

/* —— Empty / Loading helpers —— */
.skeleton {
  background: linear-gradient(90deg, var(--cream-2) 0%, var(--cream-3) 50%, var(--cream-2) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes skel { to { background-position: -200% 0; } }

/* —— Icone système simple —— */
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }

/* —— Pricing pour crédits —— */
.credits {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.credits-value {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.credits-unit {
  font-size: var(--fs-xs);
  color: var(--mute);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

/* —— Catalog category pills —— */
.catalog-cats {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.cat-pill {
  height: 36px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-pill);
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  white-space: nowrap;
}
.cat-pill:hover { border-color: var(--ink); }
.cat-pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.cat-pill .count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mute);
  background: var(--cream-2);
  padding: 2px 6px;
  border-radius: var(--r-pill);
}
.cat-pill.active .count { background: rgba(255, 255, 255, 0.18); color: rgba(255, 255, 255, 0.8); }

/* —— Stripe : état de chargement + clickable pack —— */
[data-stripe] {
  cursor: pointer;
  transition: opacity var(--t-fast) var(--ease-out);
}
[data-stripe].is-loading {
  pointer-events: none;
  opacity: 0.6;
  position: relative;
}
[data-stripe].is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pack[data-stripe]:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

/* —— Stripe : banner status (checkout success / cancel) —— */
.stripe-banner {
  position: fixed;
  top: var(--sp-5);
  left: 50%;
  transform: translate(-50%, -120%);
  background: var(--ink);
  color: var(--cream);
  border: 1px solid rgba(255, 251, 236, 0.12);
  padding: var(--sp-4) var(--sp-6);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  transition: transform var(--t-base) var(--ease-spring);
  max-width: 480px;
}
.stripe-banner.show { transform: translate(-50%, 0); }
.stripe-banner strong { color: var(--cream); font-weight: 600; }
.stripe-banner.success { border-color: rgba(22, 163, 74, 0.4); }
.stripe-banner.success::before {
  content: "✓";
  display: inline-block;
  width: 18px; height: 18px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
  font-size: 11px;
  margin-right: var(--sp-2);
  vertical-align: middle;
}
.stripe-banner.cancel { border-color: rgba(217, 119, 6, 0.4); }
.stripe-banner.cancel::before {
  content: "!";
  display: inline-block;
  width: 18px; height: 18px;
  background: var(--amber);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
  font-size: 11px;
  font-weight: 600;
  margin-right: var(--sp-2);
  vertical-align: middle;
}

/* —— Logo Rokudan —— */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: var(--ink);
  display: grid;
  place-items: center;
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: -0.02em;
  position: relative;
  overflow: hidden;
}
.brand-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, var(--violet) 0%, transparent 60%);
  opacity: 0.7;
}
.brand-mark span {
  position: relative;
  z-index: 1;
}
