/* ========================================================================
   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);
}
/* ────────── Logo Rokudan officiel ──────────
   On utilise les SVG fournis :
   - horizontal-dark : version classique sur fond clair
   - horizontal-light : version inversée sur fond sombre (admin, hero dark)
   - square-* : version compacte mobile / sidebar repliée
   On masque le texte "Rokudan" du HTML car le wordmark est DANS le SVG. */
.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 0; /* on masque toute typo, le SVG fait tout */
  line-height: 0;
  height: 36px;
  letter-spacing: 0;
}
.brand-mark {
  /* Square fallback / mobile */
  width: 36px; height: 36px;
  display: inline-block;
  background-image: url('/assets/logo/rokudan-square-dark.svg');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}
/* Texte "Rokudan" du HTML est masqué — le wordmark est dans le SVG */
.brand-mark span,
.brand > :not(.brand-mark) {
  display: none;
}
/* Desktop : on affiche l'horizontal complet, on masque le mark seul */
@media (min-width: 720px) {
  .brand-mark {
    width: 170px;
    background-image: url('/assets/logo/rokudan-horizontal-violet.svg');
  }
}
/* Contextes sombres → versions claires */
.admin .brand-mark,
.v-section.dark .brand-mark,
.auth-aside .brand-mark,
.v-footer .brand-mark {
  background-image: url('/assets/logo/rokudan-square-light.svg');
}
@media (min-width: 720px) {
  .admin .brand-mark,
  .v-section.dark .brand-mark,
  .auth-aside .brand-mark,
  .v-footer .brand-mark {
    background-image: url('/assets/logo/rokudan-horizontal-white.svg');
  }
}
/* Pour le sidebar admin/client, on garde le format square (compact) */
.sidebar .brand-mark {
  width: 36px !important;
  background-image: url('/assets/logo/rokudan-square-dark.svg') !important;
}
.admin .sidebar .brand-mark {
  background-image: url('/assets/logo/rokudan-square-light.svg') !important;
}

/* Conserver l'ancienne API pour ne pas casser les pages déjà publiées */
.brand-mark::before { content: none; }
.brand-mark > * {
  /* Si jamais un span est dedans : masqué */
  display: none;
  z-index: 1;
}

/* ============================================================
   Sidebar logo — version agrandie (horizontal en clair/sombre)
   ============================================================ */
.sidebar .brand-mark {
  width: 140px !important;
  height: 32px !important;
  background-image: url('/assets/logo/rokudan-horizontal-violet.svg') !important;
}
.admin .sidebar .brand-mark {
  background-image: url('/assets/logo/rokudan-horizontal-white.svg') !important;
}
.sidebar .brand { gap: 0; }
.sidebar .brand > :not(.brand-mark) { display: none; }

/* ============================================================
   Modal Support / Callback
   ============================================================ */
.rk-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,10,10,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity .2s ease;
  padding: 16px;
}
.rk-modal-overlay.is-open { opacity: 1; }
.rk-modal {
  background: #FAF6E8;
  color: #0A0A0A;
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
  transform: translateY(16px);
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  font-family: var(--font-ui, 'Poppins', sans-serif);
}
.rk-modal-overlay.is-open .rk-modal { transform: translateY(0); }
.rk-modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px;
  border: 0; border-radius: 50%;
  background: rgba(10,10,10,0.06);
  font-size: 22px; line-height: 1;
  cursor: pointer; color: #0A0A0A;
}
.rk-modal-close:hover { background: rgba(10,10,10,0.12); }
.rk-modal-title {
  font-family: var(--font-display, 'Poppins', sans-serif);
  font-size: 22px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.rk-modal-sub {
  color: #6B7280;
  font-size: 13.5px;
  margin: 0 0 18px;
}
.rk-modal-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(119,71,255,0.06);
  border: 1px solid rgba(119,71,255,0.12);
  margin-bottom: 10px;
  text-decoration: none; color: #0A0A0A;
  transition: background .15s ease, transform .15s ease;
}
.rk-modal-row:hover { background: rgba(119,71,255,0.12); transform: translateY(-1px); }
.rk-modal-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: #7747FF; color: #fff;
  border-radius: 10px;
}
.rk-modal-icon svg { width: 18px; height: 18px; }
.rk-modal-k { display: block; font-size: 11px; color: #6B7280; text-transform: uppercase; letter-spacing: .08em; }
.rk-modal-v { display: block; font-weight: 600; font-size: 15px; }
.rk-modal-form { display: flex; flex-direction: column; gap: 12px; }
.rk-modal-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.rk-modal-field span { color: #6B7280; font-weight: 500; }
.rk-modal-field input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #E7E5E0;
  background: #fff;
  font: inherit;
  outline: none;
}
.rk-modal-field input:focus { border-color: #7747FF; box-shadow: 0 0 0 3px rgba(119,71,255,0.15); }
.rk-modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.rk-modal-btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.rk-modal-btn-ghost { background: transparent; color: #0A0A0A; }
.rk-modal-btn-primary { background: #7747FF; color: #fff; }
.rk-modal-btn-primary:hover { background: #6a3ee8; }
.rk-modal-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.rk-modal-status { font-size: 13px; min-height: 18px; }
.rk-modal-status.is-ok { color: #2D8C5C; }
.rk-modal-status.is-err { color: #C9362D; }

/* ============================================================
   Brand kit éditable
   ============================================================ */
.bk-swatch { position: relative; }
.bk-swatch-color {
  border: 0; padding: 0;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.bk-swatch-color:hover { transform: scale(1.04); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.bk-swatch-name[contenteditable="true"] {
  outline: 1px dashed rgba(119,71,255,.4);
  outline-offset: 2px;
  border-radius: 4px;
  cursor: text;
}
.bk-swatch.bk-copied::after {
  content: "✓ copié";
  position: absolute; top: -10px; right: -10px;
  background: #7747FF; color: #fff;
  font-size: 10px; font-family: var(--font-mono);
  padding: 4px 8px; border-radius: 999px;
  animation: bkFade .9s ease;
}
@keyframes bkFade {
  0% { opacity: 0; transform: translateY(4px); }
  20%, 80% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}
.bk-x {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(10,10,10,.7); color: #fff;
  border: 0; font-size: 16px; line-height: 1;
  cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
.bk-x:hover { background: #C9362D; }
.bk-add, .bk-add-tile {
  background: transparent;
  border: 2px dashed var(--line);
  border-radius: var(--r-md);
  color: var(--mute);
  font-family: var(--font-ui, 'Poppins', sans-serif);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .15s ease;
}
.bk-add { padding: 14px 18px; }
.bk-add-tile { flex-direction: column; min-height: 110px; }
.bk-add:hover, .bk-add-tile:hover { border-color: #7747FF; color: #7747FF; background: rgba(119,71,255,.04); }

.bk-font-select {
  font: inherit; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer;
  margin-bottom: 4px;
}
.bk-font-use[contenteditable="true"] {
  outline: 1px dashed rgba(119,71,255,.4);
  outline-offset: 2px; border-radius: 4px;
}
.bk-font { position: relative; }
