/* ============================================================
   Comptoir Or — mode vocal (personnes qui ne lisent pas)
   Toucher une fois = écouter ; toucher encore = agir.
   ============================================================ */

:root {
  --v-or: #c9a227;
  --v-or-clair: #f0d468;
  --v-nuit: #191510;
}

/* ---------- Bouton marche / arrêt ---------- */
.bascule-vocal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #d4cebe;
  background: #fffefb;
  color: #1c1813;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.bascule-vocal svg { width: 20px; height: 20px; flex-shrink: 0; }
.bascule-vocal:hover { border-color: var(--v-or); }
.bascule-vocal[aria-pressed="true"] {
  background: var(--v-nuit);
  border-color: var(--v-nuit);
  color: var(--v-or-clair);
}
.bascule-vocal .ondes { opacity: 0.35; }
.bascule-vocal[aria-pressed="true"] .ondes { opacity: 1; }

@media (max-width: 560px) {
  .bascule-vocal .bascule-texte { display: none; }
  .bascule-vocal { padding: 0; width: 42px; height: 42px; }
}

/* Version flottante (connexion, reçu) */
.bascule-vocal.flottante {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 60;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

/* ---------- Mode vocal actif : interface agrandie ---------- */
html.mode-vocal body { font-size: 17px; }
html.mode-vocal .btn { font-size: 15.5px; padding: 12px 18px; border-radius: 11px; }
html.mode-vocal .btn-petit { font-size: 14px; padding: 9px 13px; }
html.mode-vocal .nav-item { font-size: 16px; padding: 12px 12px; }
html.mode-vocal .nav-item svg { width: 23px; height: 23px; }
html.mode-vocal .champ label { font-size: 13px; }
html.mode-vocal .champ input,
html.mode-vocal .champ select,
html.mode-vocal .champ textarea,
html.mode-vocal .table-lots input { font-size: 18px; padding: 12px 13px; }
html.mode-vocal .tuile .valeur { font-size: 22px; }
html.mode-vocal .barre-bas span { font-size: 11.5px; }
html.mode-vocal .barre-bas svg { width: 26px; height: 26px; }
html.mode-vocal .barre-bas .onglet-plus svg { width: 50px; height: 50px; padding: 12px; }

/* Élément prêt : un deuxième toucher l'activera */
.vocal-arme {
  outline: 3px solid var(--v-or) !important;
  outline-offset: 3px;
  border-radius: 10px;
  animation: vocal-pulse 1.1s ease-in-out infinite;
  position: relative;
  z-index: 2;
}
@keyframes vocal-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.55); }
  50% { box-shadow: 0 0 0 9px rgba(201, 162, 39, 0); }
}

/* Élément en cours de lecture */
.vocal-lu {
  outline: 2px dashed var(--v-or) !important;
  outline-offset: 2px;
  background-color: rgba(247, 237, 210, 0.75) !important;
  transition: background-color 0.2s ease;
}

/* ---------- Commandes vocales flottantes ---------- */
.vocal-dock {
  position: fixed;
  right: 14px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 55;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;           /* seuls les boutons captent le toucher */
}
.vocal-dock > * { pointer-events: auto; }
.vocal-dock > .vocal-bulle { pointer-events: none; }
html.mode-vocal .vocal-dock { display: flex; }
/* Saisie d'achat : la barre « Enregistrer » reste dégagée */
body:has(#formAchat) .vocal-dock { bottom: calc(150px + env(safe-area-inset-bottom)); }
@media (min-width: 1024px) {
  .vocal-dock, body:has(#formAchat) .vocal-dock { bottom: 24px; right: 24px; }
}

.vocal-rond {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.vocal-rond svg { width: 30px; height: 30px; }
.vocal-rond.ecouter { background: linear-gradient(175deg, #f6dc78 0%, #c9a227 100%); color: var(--v-nuit); }
.vocal-rond.parler { background: var(--v-nuit); color: var(--v-or-clair); width: 56px; height: 56px; }
.vocal-rond.parler svg { width: 26px; height: 26px; }
.vocal-rond.actif::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--v-or);
  animation: vocal-onde 1.2s ease-out infinite;
}
.vocal-rond.ecoute { background: #b3261e; color: #fff; }
.vocal-rond.ecoute::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid #e2574c;
  animation: vocal-onde 1s ease-out infinite;
}
@keyframes vocal-onde {
  from { transform: scale(0.9); opacity: 1; }
  to { transform: scale(1.35); opacity: 0; }
}
.vocal-rond.appel { animation: vocal-appel 1.4s ease-in-out 4; }
@keyframes vocal-appel {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* Bulle de texte : ce qui est dit / entendu */
.vocal-bulle {
  max-width: min(320px, calc(100vw - 100px));
  background: var(--v-nuit);
  color: #f4efe4;
  font-size: 15px;
  line-height: 1.45;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.vocal-bulle.visible { opacity: 1; transform: none; }
.vocal-bulle strong { color: var(--v-or-clair); }

/* Micro intégré dans les champs de nombres */
.vocal-champ { position: relative; display: block; width: 100%; }
.vocal-micro {
  display: none;
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #f7edd2;
  color: #8a6d14;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
}
.vocal-micro svg { width: 18px; height: 18px; }
.vocal-micro.ecoute { background: #b3261e; color: #fff; }
html.mode-vocal .vocal-micro { display: flex; }
html.mode-vocal .vocal-champ input { padding-left: 46px !important; }

@media (prefers-reduced-motion: reduce) {
  .vocal-arme, .vocal-rond.actif::after, .vocal-rond.ecoute::after, .vocal-rond.appel { animation: none; }
}
@media print {
  .vocal-dock, .bascule-vocal, .vocal-micro { display: none !important; }
}

/* Pages sans barre du bas (connexion) : commandes vocales dans le coin */
body:not(:has(.barre-bas)):not(:has(.barre-actions)) .vocal-dock { bottom: calc(18px + env(safe-area-inset-bottom)); }
@media (max-width: 700px) {
  html.mode-vocal .tuile .valeur { font-size: 18px; }
  html.mode-vocal .tuiles { grid-template-columns: 1fr; }
}
