/* ============================================================
   Campi flottanti (floating labels) — componente CONDIVISO

   Markup:
   <div class="campo-flot">
     <input id="x" placeholder="…">     (placeholder obbligatorio, anche " ")
     <label for="x">Etichetta</label>
     <p class="campo-hint">nota opzionale</p>
   </div>
   ============================================================ */
.campo-flot { position: relative; width: 100%; }
.campo-flot > input,
.campo-flot > select,
.campo-flot > textarea {
  width: 100%;
  min-height: 56px;
  padding: 1.45rem 0.85rem 0.4rem;
  background: var(--bg-700);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--cream);
  font: inherit;
}
.campo-flot > textarea { min-height: 10rem; resize: vertical; }

/* Tendine: chevron custom al posto della freccia nativa */
.campo-flot > select,
.riga-controllo select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23cbb9ae' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 14px;
  padding-right: 2.4rem;
  cursor: pointer;
}
.campo-flot > label {
  position: absolute;
  top: 0;
  left: 0;
  max-width: calc(100% - 1.2rem);
  padding: 1.05rem 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--taupe);
  font-weight: 600;
  line-height: 1.1;
  pointer-events: none;
  transform-origin: 0 0;
  transition: transform 0.15s ease, color 0.15s ease;
}

/* il placeholder resta invisibile finché l'etichetta non si è alzata */
.campo-flot > input::placeholder,
.campo-flot > textarea::placeholder { color: transparent; transition: color 0.15s ease; }
.campo-flot > input:focus::placeholder,
.campo-flot > textarea:focus::placeholder { color: var(--taupe); }

/* etichetta sollevata: focus, campo compilato, select e date (mai vuoti a schermo) */
.campo-flot > input:focus ~ label,
.campo-flot > input:not(:placeholder-shown) ~ label,
.campo-flot > input[type="date"] ~ label,
.campo-flot > textarea:focus ~ label,
.campo-flot > textarea:not(:placeholder-shown) ~ label,
.campo-flot > select ~ label {
  transform: translateY(-0.5rem) scale(0.74);
  color: var(--sand);
}
.campo-flot > :focus ~ label { color: var(--flame-300); }

.campo-flot > :focus {
  outline: none;
  border-color: var(--flame-400);
  box-shadow: var(--focus-ring);
}

.campo-hint { margin: 0.3rem 0 0; font-size: 0.8rem; color: var(--taupe); }

@media (prefers-reduced-motion: reduce) {
  .campo-flot > label,
  .campo-flot > input::placeholder,
  .campo-flot > textarea::placeholder { transition: none; }
}

/* ============================================================
   Selettore data (assets/js/seldata.js)
   ============================================================ */
.seldata { position: relative; }
.seldata-etichetta {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sand);
}
.seldata-bottone {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  width: 100%;
  min-height: 44px;
  padding: 0 0.8rem;
  background: var(--bg-700);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--cream);
  font: inherit;
  cursor: pointer;
}
.seldata-bottone .bi { color: var(--flame-400); }
.seldata-bottone:hover { border-color: var(--flame-400); }
.seldata-bottone:focus-visible { outline: none; border-color: var(--flame-400); box-shadow: var(--focus-ring); }
.seldata.errore .seldata-bottone { border-color: var(--danger); }
.seldata-pannello {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(0 0 0 / 65%);
}
.seldata-pannello[hidden] { display: none; }
.seldata-box {
  width: min(320px, 100%);
  padding: 0.9rem;
  background: var(--bg-800);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 48px rgb(0 0 0 / 60%);
}
.seldata-testa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.seldata-mese { font-weight: 700; font-size: 0.92rem; color: var(--cream); }
.seldata-freccia {
  min-width: 36px;
  min-height: 36px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--sand);
  cursor: pointer;
}
.seldata-freccia:hover { color: var(--cream); border-color: var(--flame-400); }
.seldata-griglia { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.seldata-giorno-sett {
  padding: 0.25rem 0;
  text-align: center;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--taupe);
}
.seldata-cella {
  min-height: 34px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--cream);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.seldata-cella:hover:not(:disabled) { background: var(--bg-700); color: var(--flame-300); }
.seldata-cella:disabled { color: var(--bg-600); cursor: default; }
.seldata-cella.e-oggi { box-shadow: inset 0 0 0 1px var(--line-strong); }
.seldata-cella.e-scelto {
  background: linear-gradient(100deg, var(--flame-500), var(--ember-gold));
  color: var(--bg-950);
  font-weight: 700;
}

/* ============================================================
   Selettore voci (assets/js/selvoci.js) — markup dal helper
   PHP campo_voci(); con data-crea si creano voci nuove
   ============================================================ */
/* la barra in alto è un normale .campo-flot */
.selvoci { position: relative; }
.selvoci-scelte {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.selvoci-scelte:empty { display: none; }
.selvoci-token {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.3rem 0.25rem 0.7rem;
  background: var(--bg-800);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-full);
  color: var(--cream);
  font-size: 0.88rem;
  font-weight: 600;
}
.selvoci-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--taupe);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.selvoci-x:hover { color: var(--danger); background: var(--bg-600); }
/* top auto: il pannello si aggancia da solo subito sotto il campo */
.selvoci-lista {
  position: absolute;
  z-index: 60;
  left: 0;
  right: 0;
  margin-top: 6px;
  padding: 0.35rem;
  background: var(--bg-800);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
}
.selvoci-voce {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--cream);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.selvoci-voce:hover, .selvoci-voce.evidenziata { background: var(--bg-700); color: var(--flame-300); }
.selvoci-crea { color: var(--flame-300); font-weight: 600; }

/* ---- Anteprime delle foto scelte nei form (onboarding e gestionale) ---- */
.anteprime-foto { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.anteprime-foto img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
}
.anteprime-foto img.copertina { border-color: var(--flame-400); }
