/* ============================================================
   Printy, l'assistant de moneyprinter.uk
   Feuille de style autonome. Tout est préfixé "py-".
   Couleurs et police : identité HUD du site.
   ============================================================ */

.py-root {
  --py-bg: #070b10;
  --py-panel: rgba(9, 14, 20, 0.95);
  --py-glass: rgba(255, 255, 255, 0.04);
  --py-line: rgba(255, 255, 255, 0.08);
  --py-line-soft: rgba(255, 255, 255, 0.06);
  --py-text: #e6edf3;
  --py-text-soft: #c9d4de;
  --py-muted: #8b98a5;
  --py-accent: #2ee6f6;
  --py-accent-line: rgba(46, 230, 246, 0.35);
  --py-accent-glow: rgba(46, 230, 246, 0.08);
  --py-violet: #b18cff;
  --py-amber: #f5b13d;
  --py-mint: #4fe3a0;
  --py-font: var(--mono, ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace);
  --py-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --py-dur: 320ms;

  font-family: var(--py-font);
  color: var(--py-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.py-root *,
.py-root *::before,
.py-root *::after { box-sizing: border-box; }

.py-root button,
.py-root input {
  font: inherit;
  color: inherit;
}

.py-root button { cursor: pointer; }

/* Pas de zoom au double appui sur les commandes du widget (iOS, Android) */
.py-root button,
.py-root a,
.py-root input { touch-action: manipulation; }

.py-root a { color: inherit; text-decoration: none; }

.py-root .py-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Chevron de signature : largeur fixe pour un alignement net */
.py-chev {
  display: inline-block;
  width: 12px;
  flex: none;
  color: var(--py-accent);
  font-weight: 700;
}

.py-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  flex: none;
  background: var(--py-accent);
  animation: py-blink 1.1s steps(1, end) infinite;
}

@keyframes py-blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* ---------------- Bouton flottant ---------------- */
.py-launcher {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 9990;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 0 10px;
  background: rgba(9, 14, 20, 0.92);
  border: 1px solid var(--py-accent-line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 4px var(--py-accent-glow);
  color: var(--py-text);
  white-space: nowrap;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transform: translateZ(0);
  transition:
    opacity var(--py-dur) var(--py-ease),
    transform var(--py-dur) var(--py-ease),
    padding var(--py-dur) var(--py-ease),
    box-shadow var(--py-dur) var(--py-ease);
}

.py-launcher:hover { box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6), 0 0 0 6px var(--py-accent-glow); }

.py-launcher:focus-visible,
.py-root button:focus-visible,
.py-root a:focus-visible {
  outline: 2px solid var(--py-accent);
  outline-offset: 2px;
}

/* Le champ de saisie montre déjà son état via .py-field:focus-within */
.py-root .py-input:focus,
.py-root .py-input:focus-visible { outline: none; }

.py-launcher .py-mascot { width: 32px; height: 32px; flex: none; }

.py-launcher-label {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  transition: max-width var(--py-dur) var(--py-ease), opacity 200ms var(--py-ease), margin var(--py-dur) var(--py-ease);
}

/* Version compacte au défilement : juste Printy et le curseur */
.py-launcher.is-compact { padding: 0 10px; }
.py-launcher.is-compact .py-launcher-label { max-width: 0; opacity: 0; margin-left: -8px; }

.py-launcher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

/* ---------------- Voile et panneau ---------------- */
.py-scrim {
  position: fixed;
  inset: 0;
  z-index: 9991;
  background: rgba(4, 7, 10, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--py-dur) var(--py-ease);
}

.py-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9992;
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 760px);
  background: var(--py-panel);
  border-top: 1px solid var(--py-accent-line);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -24px 64px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transform: translate3d(0, 100%, 0);
  visibility: hidden;
  will-change: transform;
  transition: transform var(--py-dur) var(--py-ease), visibility 0s linear var(--py-dur);
}

.py-root.is-open .py-scrim { opacity: 1; pointer-events: auto; }
.py-root.is-open .py-panel {
  transform: translate3d(0, 0, 0);
  visibility: visible;
  transition: transform var(--py-dur) var(--py-ease), visibility 0s;
}

/* Sur grand écran : carte en bas à droite */
@media (min-width: 720px) {
  .py-panel {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 420px;
    max-height: min(80vh, 720px);
    border: 1px solid var(--py-accent-line);
    border-radius: 18px;
    transform: translate3d(0, 24px, 0) scale(0.98);
    opacity: 0;
    transition: transform var(--py-dur) var(--py-ease), opacity var(--py-dur) var(--py-ease), visibility 0s linear var(--py-dur);
  }
  .py-root.is-open .py-panel {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 1;
    transition: transform var(--py-dur) var(--py-ease), opacity var(--py-dur) var(--py-ease), visibility 0s;
  }
  .py-scrim { background: rgba(4, 7, 10, 0.25); }
  .py-grip { display: none; }
}

.py-grip {
  display: flex;
  justify-content: center;
  padding-top: 10px;
  flex: none;
}

.py-grip span {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
}

/* En-tête */
.py-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 12px 16px;
  flex: none;
}

.py-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--py-accent-glow);
  border: 1px solid var(--py-accent-line);
}

.py-avatar .py-mascot { width: 34px; height: 34px; }

.py-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.py-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 22px;
}

.py-title-line .py-cursor { margin-left: -6px; }

.py-subtitle {
  font-size: 11.5px;
  line-height: 16px;
  color: var(--py-muted);
}

.py-close {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--py-muted);
}

.py-close:hover { color: var(--py-text); background: var(--py-glass); }

.py-rule {
  height: 1px;
  margin: 0 16px;
  background: var(--py-line-soft);
  flex: none;
}

/* Zone de réponse */
.py-body {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.py-welcome {
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--py-text-soft);
}

.py-welcome .py-chev { line-height: 21px; }

.py-question {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  line-height: 22px;
  font-weight: 700;
  color: #fff;
  overflow-wrap: anywhere;
}

.py-understood {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 20px;
  margin-top: -6px;
  font-size: 12px;
  line-height: 20px;
  color: var(--py-muted);
}

.py-understood svg { flex: none; }
.py-understood b { font-weight: 400; color: var(--py-text); }

/* Fiche */
.py-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.py-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--py-text-soft);
}

.py-label > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.py-label i { font-style: normal; color: var(--py-accent); }

.py-text {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--py-text-soft);
}

.py-dash {
  height: 0;
  margin: 12px 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.14);
}

.py-link {
  margin-top: 4px;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--py-text);
  border-radius: 8px;
}

.py-link + .py-link { border-top: 1px solid var(--py-line-soft); }

.py-link:hover .py-link-title { color: var(--py-accent); }

.py-link-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.py-link-title { font-size: 13px; font-weight: 700; line-height: 18px; transition: color 150ms; }
.py-link-sub { font-size: 11px; line-height: 15px; color: var(--py-muted); }

.py-link svg { flex: none; color: var(--py-muted); }

/* Badges */
.py-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  flex: none;
  border: 1px solid;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
}

.py-badge-live { color: var(--py-mint); border-color: rgba(79, 227, 160, 0.5); }
.py-badge-ref { color: var(--py-amber); border-color: rgba(245, 177, 61, 0.5); }
.py-badge-hors { color: var(--py-violet); border-color: rgba(177, 140, 255, 0.55); }
.py-badge-garde { color: var(--py-amber); border-color: rgba(245, 177, 61, 0.5); }

.py-note {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 16px;
  color: var(--py-muted);
}

/* Suggestions */
.py-chips {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.py-chips-label {
  font-size: 11.5px;
  line-height: 16px;
  color: var(--py-muted);
}

.py-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.py-root .py-chip {
  height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--py-text);
  font-size: 12.5px;
  transition: border-color 150ms, background 150ms;
}

.py-chip:hover { border-color: var(--py-accent-line); background: var(--py-glass); }
.py-chip i { font-style: normal; color: var(--py-accent); }

/* Saisie */
.py-form {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--py-line-soft);
}

@media (min-width: 720px) {
  .py-form { padding-bottom: 14px; }
}

.py-field {
  flex: 1;
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--py-glass);
  border: 1px solid var(--py-accent-line);
  border-radius: 8px;
  transition: border-color 150ms, box-shadow 150ms;
}

.py-field:focus-within {
  border-color: var(--py-accent);
  box-shadow: 0 0 0 3px var(--py-accent-glow);
}

.py-field .py-chev { font-size: 14px; }

/* Spécificité renforcée : ".py-root input { font: inherit }" gagnait sur ".py-input"
   et ramenait le champ à 14 px, ce qui déclenche le zoom automatique d'iOS au focus */
.py-root .py-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--py-text);
  font-size: 16px; /* 16px évite le zoom automatique sur iPhone */
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 720px) { .py-root .py-input { font-size: 14px; } }

.py-input::placeholder { color: #7f8c99; }

.py-send {
  width: 48px;
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--py-accent);
  border: 0;
  border-radius: 8px;
  color: var(--py-bg);
  transition: filter 150ms, transform 150ms var(--py-ease);
}

.py-send:hover { filter: brightness(1.08); }
.py-send:active { transform: scale(0.96); }

.py-privacy {
  flex: none;
  padding: 0 16px 10px;
  text-align: center;
  font-size: 10.5px;
  line-height: 14px;
  color: var(--py-muted);
}

/* ---------------- Mascotte ---------------- */
.py-mascot { display: block; overflow: visible; }

.py-mascot .py-m-bill,
.py-mascot .py-m-eyes,
.py-mascot .py-m-arm-l,
.py-mascot .py-m-arm-r {
  transition: transform 260ms var(--py-ease), opacity 200ms;
  transform-box: fill-box;
  transform-origin: center;
}

.py-mascot .py-m-bill { transform-origin: 50% 100%; }

/* Humeur : réfléchit (le billet rentre, les yeux se plissent, bras levé) */
.py-mascot.is-thinking .py-m-bill { transform: scaleY(0.45); }
.py-mascot.is-thinking .py-m-eyes { transform: scaleY(0.4); }
.py-mascot.is-thinking .py-m-arm-r { transform: rotate(-40deg); transform-origin: 0% 50%; }
.py-mascot.is-thinking .py-m-dots { opacity: 1; }

/* Humeur : trouvé (le billet jaillit, bras en l'air) */
.py-mascot.is-found .py-m-bill { transform: scaleY(1.35); }
.py-mascot.is-found .py-m-arm-l { transform: rotate(40deg); transform-origin: 100% 50%; }
.py-mascot.is-found .py-m-arm-r { transform: rotate(-40deg); transform-origin: 0% 50%; }
.py-mascot.is-found .py-m-spark { opacity: 1; }

.py-mascot .py-m-dots,
.py-mascot .py-m-spark { opacity: 0; transition: opacity 200ms; }

/* Clignement des yeux, en CSS uniquement */
.py-mascot .py-m-eyes { animation: py-eyes 5.2s var(--py-ease) infinite; }

@keyframes py-eyes {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

.py-mascot.is-thinking .py-m-eyes,
.py-mascot.is-found .py-m-eyes { animation: none; }

/* Respect des réglages d'accessibilité */
@media (prefers-reduced-motion: reduce) {
  .py-root *,
  .py-root *::before,
  .py-root *::after {
    animation: none !important;
    transition-duration: 1ms !important;
  }
  .py-cursor { opacity: 1; }
}
