/* ==========================================================================
   Nuovo evento a voce (js/voce.js) e impostazioni dell'assistente IA
   Il colore del tipo di evento arriva in --c.
   ========================================================================== */
.nb-modal.vc-modal {
  width: min(560px, 100%); height: min(780px, calc(100dvh - 32px)); max-height: none;
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
@media (max-width: 600px) {
  .nb-modal-back:has(> .vc-modal) { place-items: end center; padding: calc(10px + var(--sat, 0px)) 0 0; }
  .nb-modal.vc-modal {
    width: 100%; height: calc(100dvh - 10px - var(--sat, 0px)); border-radius: 22px 22px 0 0; border-bottom: 0;
    transform: translateY(40px);
  }
}
.vc { display: flex; flex-direction: column; height: 100%; min-height: 0; }

/* --- testata --- */
.vc-head { display: flex; align-items: flex-start; gap: 8px; padding: 16px 14px 6px 20px; }
.vc-head-t { flex: 1; min-width: 0; }
.vc-head h3 { margin: 0; font-size: 19px; }
.vc-mode { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12.5px; color: var(--ink-3); }
.vc-mode::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); }
.vc-mode.ai { color: var(--ink-2); }
.vc-mode.ai::before { background: var(--ok); }
.vc-x { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--fill-2); color: var(--ink-2); cursor: pointer; }
.vc-x:hover { background: var(--fill-3); }
.vc-x svg { width: 18px; height: 18px; }
.vc-reset { background: transparent; }
.vc-reset:hover { background: var(--fill-2); }

/* --- conversazione --- */
.vc-log { flex: 1 1 auto; min-height: 70px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; padding: 8px 16px 12px; }
.vc-b {
  max-width: 86%; padding: 9px 13px; border-radius: 18px; font-size: 15px; line-height: 1.38;
  overflow-wrap: anywhere; animation: rise 0.32s var(--ease) both;
}
.vc-bot { align-self: flex-start; background: var(--fill-2); color: var(--ink); border-bottom-left-radius: 6px; }
.vc-me { align-self: flex-end; background: var(--solid); color: var(--on-solid); border-bottom-right-radius: 6px; }
.vc-b.vc-ok { background: var(--ok-fill); color: var(--ok); font-weight: 500; }
.vc-typing { letter-spacing: 3px; animation: rise 0.32s var(--ease) both, vcBlink 1s ease-in-out infinite; }
@keyframes vcBlink { 50% { opacity: 0.45; } }

/* --- bozza --- */
.vc-card {
  --c: var(--ink-4);
  position: relative; margin: 0 14px; padding: 14px 14px 12px 18px; flex: none;
  border: 1px solid var(--stroke-2); border-radius: 16px; background: var(--fill); overflow: hidden;
  transition: border-color 0.25s;
}
.vc-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); transition: background 0.25s; }
.vc-card-top { display: flex; flex-direction: column; gap: 4px; padding: 2px 4px; margin: -2px -4px 8px; border-radius: 8px; }
.vc-type { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-2); padding: 3px 9px 3px 7px; border-radius: 99px; background: var(--fill-2); background: color-mix(in srgb, var(--c) 16%, transparent); }
.vc-type i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.vc-title { font-size: 18px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; padding: 1px 4px; margin: 0 -4px; border-radius: 7px; }
.vc-title.empty { color: var(--ink-3); font-weight: 500; }
.vc-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 0; }
.vc-fields > div { min-width: 0; padding: 3px 6px; margin: -3px -6px; border-radius: 8px; }
.vc-fields > div[hidden] { display: none; }
.vc-fields .vc-notes { grid-column: 1 / -1; }
.vc-fields dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.vc-fields dd { margin: 1px 0 0; font-size: 14.5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.vc-fields dd.empty { color: var(--ink-4); }
.vc-notes dd { white-space: pre-line; color: var(--ink-2); }
.vc-flash { animation: vcFlash 1.1s var(--ease); }
.vc-card-top.vc-flash, .vc-title.vc-flash { animation: vcFlash 1.1s var(--ease); }
@keyframes vcFlash {
  0% { background: var(--fill-3); background: color-mix(in srgb, var(--c) 30%, transparent); transform: scale(1.025); }
  100% { background: transparent; transform: none; }
}
.vc-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.vc-actions .btn-sm { height: 38px; }
.vc-sp { flex: 1; }
.vc-save { height: 42px; padding: 0 22px; }

/* --- microfono e testo --- */
.vc-compose { flex: none; padding: 10px 14px 6px; }
.vc-interim { margin: 0 0 8px; min-height: 20px; font-size: 14px; color: var(--ink-2); font-style: italic; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-interim:empty { display: none; }
.vc-row { display: flex; align-items: center; gap: 12px; }
.vc-mic {
  position: relative; flex: none; width: 62px; height: 62px; border: 0; border-radius: 50%; padding: 0;
  background: var(--solid); color: var(--on-solid); cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22); transition: background 0.2s, transform 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.vc-mic:active { transform: scale(0.94); }
.vc-mic-ic { position: relative; z-index: 1; display: grid; place-items: center; }
.vc-mic svg { width: 27px; height: 27px; }
.vc-ring { position: absolute; inset: 0; border-radius: 50%; background: var(--ko); opacity: 0; pointer-events: none; }
.vc-mic.on { background: var(--ko); color: #fff; }
.vc-mic.on .vc-ring { animation: vcPulse 1.6s ease-out infinite; }
.vc-mic.on .vc-ring.r2 { animation-delay: 0.8s; }
.vc-mic.bump .vc-mic-ic { animation: vcBump 0.3s var(--ease); }
@keyframes vcPulse { from { opacity: 0.45; transform: scale(1); } to { opacity: 0; transform: scale(1.75); } }
@keyframes vcBump { 40% { transform: scale(1.18); } }
.vc-form { flex: 1; min-width: 0; position: relative; display: flex; }
.vc-input { height: 50px; border-radius: 25px; padding: 0 52px 0 18px; }
.vc-send {
  position: absolute; right: 5px; top: 5px; width: 40px; height: 40px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--fill-3); color: var(--ink); cursor: pointer;
}
.vc-send:hover { background: var(--solid); color: var(--on-solid); }
.vc-send svg { width: 18px; height: 18px; }
.vc-hint { margin: 8px 2px 0; font-size: 12.5px; line-height: 1.35; color: var(--ink-3); }
.vc-listening .vc-hint { visibility: hidden; }

/* --- assistente IA --- */
.vc-ai { flex: none; margin: 4px 14px calc(8px + var(--sab, 0px)); border-top: 1px solid var(--stroke); }
.vc-ai summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; list-style: none;
  font-size: 14px; color: var(--ink-2); -webkit-tap-highlight-color: transparent;
}
.vc-ai summary::-webkit-details-marker { display: none; }
.vc-ai summary svg { width: 17px; height: 17px; flex: none; }
.vc-ai summary span { flex: 1; }
.vc-ai summary em { font-style: normal; font-size: 12px; color: var(--ink-3); padding: 2px 9px; border-radius: 99px; background: var(--fill-2); }
.vc-ai summary::after { content: ""; width: 7px; height: 7px; border-right: 1.6px solid var(--ink-3); border-bottom: 1.6px solid var(--ink-3); transform: rotate(45deg) translateY(-2px); transition: transform 0.2s var(--ease); margin: 0 4px; }
.vc-ai[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.vc-ai-body { padding: 2px 0 8px; animation: rise 0.25s var(--ease) both; }

.ai-set { display: grid; gap: 10px; }
.ai-toggle { align-items: flex-start; color: var(--ink); }
.ai-toggle input { margin-top: 2px; }
.ai-toggle span { display: grid; gap: 2px; }
.ai-toggle b { font-weight: 600; font-size: 14px; }
.ai-toggle small { font-size: 12.5px; color: var(--ink-3); line-height: 1.35; }
.ai-toggle input:disabled { opacity: 0.5; cursor: default; }
.ai-models { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; transition: opacity 0.2s; }
.ai-models[hidden] { display: none; }
.ai-models.off { opacity: 0.55; }
.ai-model {
  display: grid; gap: 2px; text-align: left; padding: 9px 12px; min-height: 52px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--stroke-2); background: transparent; color: var(--ink); font: inherit;
}
.ai-model b { font-size: 13.5px; font-weight: 600; }
.ai-model small { font-size: 12px; color: var(--ink-3); }
.ai-model.active { border-color: var(--ink-2); background: var(--fill-2); }
.ai-prog { height: 6px; border-radius: 6px; background: var(--fill-3); overflow: hidden; }
.ai-prog[hidden] { display: none; }
.ai-prog i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ink-2); transition: width 0.3s var(--ease); }
.ai-status { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--ink-3); }
.ai-status:empty { display: none; }
.ai-status.err { color: var(--ko); }

@media (max-width: 600px) {
  .vc-card { padding: 12px 12px 10px 16px; }
  .vc-title { font-size: 17px; }
  .vc-card-top { margin-bottom: 6px; }
  .vc-actions { margin-top: 10px; }
}
@media (max-width: 380px) {
  .vc-mic { width: 56px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .vc-b, .vc-typing, .vc-ai-body { animation: none; }
  .vc-mic.on .vc-ring { animation: none; opacity: 0.25; transform: scale(1.2); }
  .vc-flash, .vc-mic.bump .vc-mic-ic { animation: none; }
  .nb-modal.vc-modal { transform: none; }
}

/* assistente IA: online o sul dispositivo */
.ai-where { justify-self: start; }
.ai-free { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.ai-free[hidden] { display: none; }
