/* ==========================================================================
   Wildix Kite — pannello «Parla direttamente con il nostro team»
   Template: page-voip-wildix.php. Comportamento in assets/js/ai-kite.js.

   Avatar: stessa area per tutti (--ak-avatar). La silhouette è sempre
   presente sotto la foto, quindi foto assente, non valida o in ritardo non
   spostano il layout. Icone SVG inline: nessuna immagine esterna.
   ========================================================================== */

.ak {
  --ak-red: var(--ai-red, #BE1521);
  --ak-red-dim: var(--ai-red-dim, rgba(190,21,33,0.07));
  --ak-ink: var(--ai-ink, #1e293b);
  --ak-text-2: var(--ai-text-2, #475569);
  --ak-text-3: var(--ai-text-3, #64748b);
  --ak-bg: var(--ai-bg, #f1f5f9);
  --ak-line: var(--ai-line, #d1d9e0);
  --ak-surface: var(--ai-surface, #fff);
  --ak-ease: var(--ai-ease, cubic-bezier(.2,.7,.2,1));
  --ak-avatar: 84px;
  --ak-ok: #16a34a;
  --ak-busy: #d97706;
  --ak-off: #94a3b8;
  font-family: var(--ai-font, inherit);
  background: var(--ak-surface);
  border: 1px solid var(--ak-line);
  border-radius: 18px;
  padding: 28px 30px;
}

/* Intestazione */
.ak-head { margin-bottom: 20px; }
.ak .ak-head h2 {
  font-family: inherit;
  font-size: var(--ai-fs-md, 1.0625rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ak-ink);
  margin: 0 0 4px;
}
.ak-head p { font-size: var(--ai-fs-xs, 0.8125rem); line-height: 1.5; color: var(--ak-text-3); margin: 0; }

/* Operatori */
.ak-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.ak-op {
  display: grid;
  grid-template-rows: auto auto 1fr;
  justify-items: center;
  text-align: center;
  background: var(--ak-bg);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 20px 14px 14px;
  transition: border-color 160ms var(--ak-ease), box-shadow 160ms var(--ak-ease);
}
.ak-op:hover, .ak-op:focus-within { border-color: var(--ak-line); box-shadow: 0 8px 18px -14px rgba(15,23,42,0.35); }

/* Avatar: area fissa e circolare, uguale per tutti */
.ak-avatar {
  position: relative;
  width: var(--ak-avatar);
  height: var(--ak-avatar);
  flex: 0 0 auto;
  margin-bottom: 12px;
}
.ak-avatar-frame {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(180deg, #f4f6f9 0%, #e2e8f0 100%);
  box-shadow: 0 0 0 3px var(--ak-surface), 0 0 0 4px var(--ak-line);
}
.ak-silhouette, .ak-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.ak-silhouette { color: #a9b4c2; }
.ak-photo {
  object-fit: cover;
  opacity: 0;
  transition: opacity 280ms var(--ak-ease);
}
.ak-avatar.has-photo .ak-photo { opacity: 1; }

/* Pallino di presenza sull'avatar: solo con un dato reale */
.ak-dot {
  position: absolute;
  right: 3%;
  bottom: 3%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid var(--ak-surface);
  background: var(--ak-off);
  display: none;
}
.ak-op[data-state="available"] .ak-dot,
.ak-op[data-state="busy"] .ak-dot,
.ak-op[data-state="away"] .ak-dot,
.ak-op[data-state="offline"] .ak-dot { display: block; }
.ak-op[data-state="available"] .ak-dot { background: var(--ak-ok); }
.ak-op[data-state="busy"] .ak-dot,
.ak-op[data-state="away"] .ak-dot { background: var(--ak-busy); }

/* Nome, ruolo, stato */
.ak-info { min-width: 0; }
.ak .ak-name {
  font-family: inherit;
  font-size: var(--ai-fs-sm, 0.9375rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ak-ink);
  margin: 0;
}
.ak-role {
  font-size: var(--ai-fs-xs, 0.8125rem);
  line-height: 1.4;
  color: var(--ak-text-3);
  margin: 2px 0 0;
  min-height: 1.4em;
}
/* Senza JavaScript lo stato non è noto: la riga resta invisibile ma occupa
   già il suo spazio, così l'avvio dello script non sposta il layout. */
.ak-status {
  display: inline-flex;
  visibility: hidden;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--ak-text-3);
}
.ak-js .ak-status { visibility: visible; }
.ak-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  box-sizing: border-box;
}
.ak-op[data-state="available"] .ak-status { color: #15803d; }
.ak-op[data-state="busy"] .ak-status,
.ak-op[data-state="away"] .ak-status { color: #b45309; }
.ak-op:is([data-state="available"], [data-state="busy"], [data-state="away"]) .ak-status::before { background: currentColor; }

/* Pulsanti Kite */
.ak-actions {
  align-self: end;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 16px;
}
.ak .ak-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 54px;
  padding: 8px 4px;
  background: var(--ak-surface);
  border: 1px solid var(--ak-line);
  border-radius: 10px;
  color: var(--ak-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 160ms var(--ak-ease), border-color 160ms var(--ak-ease), background-color 160ms var(--ak-ease), transform 160ms var(--ak-ease);
}
.ak-btn svg { width: 20px; height: 20px; flex: 0 0 auto; }
.ak .ak-btn:hover { color: var(--ak-red); border-color: var(--ak-red); background: var(--ak-red-dim); }
.ak .ak-btn:focus-visible { outline: 2px solid var(--ak-red); outline-offset: 2px; color: var(--ak-red); border-color: var(--ak-red); }
.ak .ak-btn:active { transform: scale(0.97); }

.ak .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ak-note {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ak-text-3);
}

/* Pannello stretto (telefono, hero a 1024 px): una riga per operatore, stessa
   struttura e stesso avatar per tutti. Decide la larghezza del pannello, non
   quella dello schermo. */
.ak { container: ak / inline-size; }
@media (max-width: 560px) {
  .ak { padding: 22px 18px; }
}
@container ak (max-width: 380px) {
  .ak-list { --ak-avatar: 64px; grid-template-columns: minmax(0, 1fr); }
  .ak-op {
    grid-template-columns: var(--ak-avatar) minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 14px;
    justify-items: start;
    align-items: center;
    text-align: left;
    padding: 16px 14px 14px;
  }
  .ak-avatar { margin-bottom: 0; }
  .ak-actions { grid-column: 1 / -1; margin-top: 14px; }
  .ak .ak-btn { flex-direction: row; gap: 6px; min-height: 48px; font-size: 13px; }
  .ak-btn svg { width: 18px; height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .ak-op, .ak .ak-btn, .ak-photo { transition: none; }
  .ak .ak-btn:active { transform: none; }
}
