/* ============================================================
   telos-emails.css — pole adresów e-mail z kartami (chipami).
   Wspolne dla paneli i formularzy admina/klienta. Kolory bierze ze zmiennych brandu,
   z bezpiecznymi wartościami zapasowymi, żeby działało też tam,
   gdzie zmienne nie są zdefiniowane.
   ============================================================ */

.tmails{
  --tm-green: var(--brand-green, #1eb88a);
  --tm-green-dark: var(--brand-green-dark, #17946e);
  --tm-green-text: var(--brand-green-text, #117657);
  --tm-green-light: var(--brand-green-light, #e8f8f2);
  --tm-green-soft: var(--brand-green-soft, #cfeadd);
  --tm-err: #dc2626;
  --tm-err-soft: #fecaca;
  --tm-err-light: #fef2f2;
  --tm-text: var(--text-dark, #1a1a1a);
  --tm-muted: var(--text-light, #666);

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 46px;
  padding: 7px 8px;
  background: #fff;
  border: 1.5px solid var(--tm-green-soft);
  border-radius: 11px;
  cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.tmails.is-focused{
  border-color: var(--tm-green);
  box-shadow: 0 0 0 3px var(--tm-green-light);
}
.tmails.has-error{ border-color: var(--tm-err-soft); }
.tmails.has-error.is-focused{
  border-color: var(--tm-err);
  box-shadow: 0 0 0 3px var(--tm-err-light);
}
.tmails.is-disabled{
  background: #f6f7f8;
  cursor: not-allowed;
  border-color: var(--border-light, #e3e6e9);
}

/* --- pojedyncza karta adresu --- */
.tmails-chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 5px 5px 11px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--tm-green-text);
  background: var(--tm-green-light);
  border: 1px solid var(--tm-green-soft);
  border-radius: 999px;
  animation: tmails-in .16s ease both;
}
.tmails-chip__text{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.tmails-chip__x{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 999px;
  opacity: .55;
  cursor: pointer;
  transition: background-color .12s ease, opacity .12s ease;
}
.tmails-chip__x:hover{ opacity: 1; background: rgba(17, 118, 87, .13); }
.tmails-chip__x svg{ width: 11px; height: 11px; }

.tmails-chip.is-invalid{
  color: #991b1b;
  background: var(--tm-err-light);
  border-color: var(--tm-err-soft);
  border-style: dashed;
}
.tmails-chip.is-invalid .tmails-chip__x:hover{ background: rgba(153, 27, 27, .12); }
.tmails-chip.is-invalid .tmails-chip__warn{
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin-right: -2px;
  color: var(--tm-err);
}
.tmails-chip.is-armed{
  box-shadow: 0 0 0 2px var(--tm-green);
}
.tmails-chip.is-dupe{ animation: tmails-shake .3s ease; }

/* --- pole wpisywania ---
   Selektor jest celowo bardziej szczegolowy niz `.tmails-input`: panele maja wlasne
   reguly typu `.al-mails input` albo `.set-input`, ktore inaczej domalowalyby drugie
   obramowanie w srodku ramki z kartami. */
.tmails input.tmails-input,
.tmails input.tmails-input:focus{
  flex: 1 1 130px;
  width: auto;
  min-width: 110px;
  margin: 0;
  padding: 5px 3px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--tm-text);
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
}
.tmails input.tmails-input::placeholder{ color: var(--text-muted, #999); font-weight: 500; }
.tmails input.tmails-input:disabled{ cursor: not-allowed; }

/* --- komunikaty pod polem --- */
.tmails-msg{
  display: none;
  align-items: flex-start;
  gap: 6px;
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--tm-err);
}
.tmails-msg.is-on{ display: flex; }
.tmails-msg svg{ flex: 0 0 auto; width: 14px; height: 14px; margin-top: 2px; }

.tmails-count{
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--tm-muted);
}

@keyframes tmails-in{
  from{ opacity: 0; transform: translateY(3px) scale(.94); }
  to{ opacity: 1; transform: none; }
}
@keyframes tmails-shake{
  0%,100%{ transform: none; }
  25%{ transform: translateX(-3px); }
  75%{ transform: translateX(3px); }
}
@media (prefers-reduced-motion: reduce){
  .tmails-chip{ animation: none; }
  .tmails-chip.is-dupe{ animation: none; }
}

/* Na telefonie karty łamią się swobodnie, a pole wpisywania
   dostaje całą szerokość wiersza, żeby nie zwężało się do 2 znaków. */
@media (max-width: 480px){
  .tmails{ min-height: 44px; }
  .tmails input.tmails-input{ flex: 1 1 100%; }
  .tmails-chip{ font-size: 12.5px; }
}
