/**
 * Youfriend Chat Stylesheet
 * Replica fedele e moderna dell'interfaccia a schede fluttuanti (Floating Hub + Docked Windows)
 */

:root {
  --yf-primary: #0084ff;
  --yf-primary-hover: #0073e6;
  --yf-bg-card: #ffffff;
  --yf-text-main: #111827;
  --yf-text-muted: #6b7280;
  --yf-border: #e5e7eb;
  --yf-bubble-recv: #f0f2f5;
  --yf-bubble-recv-text: #050505;
  --yf-bubble-sent: #0084ff;
  --yf-bubble-sent-text: #ffffff;
  --yf-online: #22c55e;
  --yf-offline: #9ca3af;
  --yf-badge-bg: #dcfce7;
  --yf-badge-text: #15803d;
  --yf-danger: #ef4444;
}

#yf-chat-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================================================
   PULSANTE FLOTTANTE IN BASSO A DESTRA (FLOATING LAUNCHER BUBBLE)
   ========================================================================== */
#yf-chat-root .yf-launcher-btn {
  position: fixed;
  bottom: 14px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--yf-primary);
  border: none;
  box-shadow: 0 4px 16px rgba(0, 132, 255, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
  outline: none;
}
#yf-chat-root .yf-launcher-btn:hover {
  transform: scale(1.06);
  background: var(--yf-primary-hover);
}
#yf-chat-root .yf-launcher-btn svg {
  width: 26px;
  height: 26px;
  fill: #ffffff;
}

/* Badge contatore sul pulsante flottante */
#yf-chat-root .yf-launcher-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #dcfce7;
  color: #15803d;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  border: 2px solid #ffffff;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* ==========================================================================
   SCHEDA PRINCIPALE DELL'HUB ("CHAT") - ATTACCATA A BORDO SCHERMO IN BASSO
   ========================================================================== */
#yf-chat-root .yf-hub-card {
  position: fixed;
  bottom: 0px; /* Attaccato a bordo schermo */
  right: 80px; /* Subito a sinistra del pulsante circolare */
  width: 330px;
  height: 520px;
  max-height: calc(100vh - 30px);
  background: var(--yf-bg-card);
  border-radius: 12px 12px 0 0; /* Arrotondato solo in alto come screenshot */
  box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--yf-border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999998;
  animation: yf-slide-up 0.22s ease-out;
}

@keyframes yf-slide-up {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header dell'Hub */
.yf-hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #ffffff;
  position: relative;
}
.yf-hub-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--yf-text-main);
  letter-spacing: -0.3px;
}
.yf-hub-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--yf-primary);
}
.yf-hub-action-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--yf-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 16px;
  transition: opacity 0.15s;
}
.yf-hub-action-btn:hover { opacity: 0.75; }
.yf-hub-action-btn svg { width: 17px; height: 17px; fill: currentColor; }

/* Menu Dropdown Opzioni Hub (3 Puntini) */
.yf-hub-menu-dropdown {
  position: absolute;
  top: 48px;
  right: 14px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--yf-border);
  min-width: 210px;
  padding: 6px 0;
  z-index: 1000;
  flex-direction: column;
}
.yf-hub-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.yf-hub-menu-item:hover {
  background: #f8fafc;
  color: #0f172a;
}
.yf-hub-menu-item .yf-menu-icon {
  font-size: 14px;
  width: 18px;
  display: inline-block;
  text-align: center;
}
.yf-hub-menu-item .yf-menu-label {
  font-weight: 500;
}

/* Barra di Ricerca */
.yf-search-wrap {
  padding: 0 16px 12px;
  position: relative;
  background: #ffffff;
}
.yf-search-wrap svg {
  position: absolute;
  left: 28px;
  top: 10px;
  width: 15px;
  height: 15px;
  fill: #9ca3af;
}
.yf-search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  color: var(--yf-text-main);
  transition: border-color 0.2s;
}
.yf-search-input:focus {
  border-color: var(--yf-primary);
}

/* Schede di Navigazione (Utenti / Gruppi / Privati) */
.yf-nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--yf-border);
  background: #ffffff;
}
.yf-tab-btn {
  flex: 1;
  padding: 10px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--yf-text-muted);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  position: relative;
}
.yf-tab-btn.active {
  color: var(--yf-primary);
  border-bottom-color: var(--yf-primary);
}
.yf-tab-badge {
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.4);
}

/* Lista Conversazioni nel Tab Privati */
.yf-private-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
  border-bottom: 1px solid #f8fafc;
}
.yf-private-item:hover {
  background: #f1f5f9;
}
.yf-private-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}
.yf-private-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #cbd5e1;
}
.yf-private-status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #ffffff;
}
.yf-private-status-dot.online { background: #22c55e; }
.yf-private-status-dot.offline { background: #94a3b8; }
.yf-private-info {
  flex: 1;
  min-width: 0;
}
.yf-private-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}
.yf-private-name {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yf-private-time {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
}
.yf-private-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.yf-private-last-msg {
  font-size: 13px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.yf-private-unread-badge {
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(239, 68, 68, 0.4);
}

/* Contenuto Schede */
.yf-hub-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  background: #ffffff;
}
/* Banner informativo per visitatori/ospiti nell'Hub */
.yf-guest-banner {
  background: #f8fafc;
  border-bottom: 1px solid var(--yf-border);
  padding: 9px 16px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.45;
  text-align: center;
}
.yf-guest-banner a {
  color: var(--yf-primary);
  font-weight: 600;
  text-decoration: underline;
}

.yf-section-label {
  padding: 8px 16px 4px;
  font-size: 12px;
  font-weight: 700;
  color: #4b5563;
}

/* Elemento Lista Stanza */
.yf-room-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.yf-room-card:hover {
  background: #f9fafb;
}
.yf-room-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.yf-room-icon-wrap img,
.yf-room-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.yf-room-details {
  flex: 1;
  min-width: 0;
}
.yf-room-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--yf-text-main);
  display: flex;
  align-items: center;
  gap: 5px;
}
.yf-room-desc {
  font-size: 11px;
  color: var(--yf-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.yf-user-count-badge {
  background: var(--yf-badge-bg);
  color: var(--yf-badge-text);
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  padding: 2px 7px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.yf-user-count-badge svg { width: 10px; height: 10px; fill: currentColor; }

/* Elemento Lista Utente Online / Offline */
.yf-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.yf-user-card:hover {
  background: #f9fafb;
}
.yf-user-avatar-wrap {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 13px;
}
.yf-user-avatar-wrap img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.yf-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--yf-text-main);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yf-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}
.yf-status-dot.online { background: var(--yf-online); }
.yf-status-dot.offline { background: var(--yf-offline); }

/* ==========================================================================
   FINESTRE DI CHAT DOCKED (AFFIANCATE A SINISTRA DELL'HUB, ATTACCATE IN BASSO)
   ========================================================================== */
#yf-chat-root .yf-docked-windows {
  position: fixed;
  bottom: 0px; /* Attaccato a filo bordo inferiore schermo */
  right: 80px; /* Quando l'hub è chiuso, si attacca subito a fianco del launcher circolare */
  display: flex;
  flex-direction: row-reverse; /* Nuove finestre o prima finestra si ancora a destra, le successive verso sinistra */
  gap: 10px;
  align-items: flex-end;
  pointer-events: none;
  z-index: 999997;
  transition: right 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

#yf-chat-root.hub-open .yf-docked-windows {
  right: 422px; /* Quando l'hub principale è aperto, le finestre di chat slittano a sinistra dell'hub */
}

.yf-docked-box {
  pointer-events: auto;
  width: 330px;
  height: 520px;
  max-height: calc(100vh - 30px);
  background: #ffffff;
  border-radius: 12px 12px 0 0; /* Arrotondato in alto come screenshot */
  box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--yf-border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height 0.22s ease;
}
.yf-docked-box.minimized {
  height: 48px;
}

/* Header Finestra Chat */
.yf-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--yf-border);
  background: #ffffff;
}
.yf-box-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.yf-box-header-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}
.yf-box-header-avatar .yf-room-icon-mini {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.yf-box-header-avatar img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}
.yf-box-header-avatar .yf-mini-count {
  position: absolute;
  bottom: -3px;
  left: -3px;
  background: var(--yf-badge-bg);
  color: var(--yf-badge-text);
  font-size: 9px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 4px;
  border: 1px solid #fff;
}
.yf-box-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.yf-box-title-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.yf-box-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--yf-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yf-box-gear-btn {
  background: none;
  border: none;
  padding: 2px 3px;
  cursor: pointer;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s ease;
}
.yf-box-gear-btn:hover {
  color: var(--yf-primary);
  background: #f1f5f9;
}
.yf-box-gear-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.yf-box-subtitle {
  font-size: 11px;
  color: var(--yf-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Menu a tendina Opzioni Utente / Scheda */
.yf-box-options-menu {
  display: none;
  position: absolute;
  top: 52px;
  left: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 6px 0;
  min-width: 210px;
  z-index: 9999999;
  animation: yf-menu-fade 0.15s ease-out;
}
@keyframes yf-menu-fade {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.yf-box-opt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.yf-box-opt-item:hover {
  background: #f8fafc;
  color: #0f172a;
}
.yf-box-opt-item svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex-shrink: 0;
  opacity: 0.75;
}
.yf-box-opt-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 5px 0;
}
.yf-box-opt-header {
  padding: 6px 14px 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.5px;
}
.yf-box-opt-item.warning {
  color: #d97706;
}
.yf-box-opt-item.warning:hover {
  background: #fffbeb;
  color: #b45309;
}
.yf-box-opt-item.danger {
  color: #dc2626;
}
.yf-box-opt-item.danger:hover {
  background: #fef2f2;
  color: #991b1b;
}

.yf-box-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
}
.yf-box-action-btn {
  background: none;
  border: none;
  padding: 3px 5px;
  cursor: pointer;
  color: #64748b;
  border-radius: 4px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.yf-box-action-btn:hover { color: #0f172a; background: #f1f5f9; }
.yf-box-action-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* Corpo Messaggi */
.yf-box-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.yf-msg-row {
  display: flex;
  gap: 8px;
  max-width: 85%;
  align-items: flex-end;
}
.yf-msg-row.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.yf-msg-row.recv {
  align-self: flex-start;
}

.yf-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.yf-msg-content-wrap {
  display: flex;
  flex-direction: column;
}
.yf-msg-sender-name {
  font-size: 11px;
  color: var(--yf-text-muted);
  margin-bottom: 2px;
  margin-left: 4px;
}
.yf-msg-bubble {
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 15px !important;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}
.yf-msg-row.recv .yf-msg-bubble {
  background: var(--yf-bubble-recv);
  color: var(--yf-bubble-recv-text);
  border-bottom-left-radius: 4px;
}
.yf-msg-row.sent .yf-msg-bubble {
  background: var(--yf-bubble-sent);
  color: var(--yf-bubble-sent-text);
  border-bottom-right-radius: 4px;
}

.yf-msg-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 4px;
  display: block;
}

.yf-welcome-notice {
  text-align: center;
  font-size: 13px;
  color: #9ca3af;
  margin: 10px 0;
  font-weight: 500;
}

/* Footer / Input Bar Finestra Chat */
.yf-box-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid var(--yf-border);
  position: relative;
}
.yf-plus-btn {
  background: var(--yf-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.yf-plus-btn:hover { opacity: 0.9; }

.yf-box-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: #f0f2f5;
  border-radius: 20px;
  padding: 0 12px;
}
.yf-box-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 4px;
  font-size: 15px !important;
  outline: none;
  color: var(--yf-text-main);
}
.yf-input-emoji-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  font-size: 16px;
  color: #6b7280;
  display: flex;
  align-items: center;
}
.yf-input-emoji-btn:hover { color: #111827; }

.yf-send-arrow-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--yf-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.yf-send-arrow-btn:hover { transform: scale(1.1); }
.yf-send-arrow-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ==========================================================================
   SELETTORE EMOJI MODERNO E CATEGORIALE
   ========================================================================== */
.yf-emoji-popover {
  position: absolute;
  bottom: 54px;
  right: 12px;
  width: 295px;
  height: 275px;
  max-height: 285px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  display: none;
  flex-direction: column;
  overflow: hidden; /* FONDAMENTALE: impedisce qualsiasi fuoriuscita sui comandi sottostanti! */
  z-index: 1000;
  animation: yf-menu-fade 0.15s ease-out;
}

.yf-emoji-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.yf-emoji-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}
.yf-emoji-tabs::-webkit-scrollbar {
  display: none;
}

.yf-emoji-tab {
  display: flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.yf-emoji-tab:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.yf-emoji-tab.active {
  background: #0084ff;
  color: #ffffff;
}

.yf-emoji-close-btn {
  background: none;
  border: none;
  font-size: 17px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.yf-emoji-close-btn:hover {
  color: #0f172a;
  background: #e2e8f0;
}

.yf-emoji-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.yf-emoji-body::-webkit-scrollbar {
  width: 5px;
}
.yf-emoji-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.yf-emoji-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.yf-emoji-section {
  margin-bottom: 12px;
}

.yf-emoji-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.5px;
  padding: 4px 2px;
  margin-bottom: 4px;
}

.yf-emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.yf-emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  font-size: 20px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, transform 0.12s;
}
.yf-emoji-item:hover {
  background: #f1f5f9;
  transform: scale(1.22);
  z-index: 2;
}
.yf-emoji-item:active {
  transform: scale(0.92);
}

/* Menu Opzioni Messaggio (⋮) */
.yf-msg-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.yf-mod-trigger {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: #94a3b8;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}
.yf-msg-row:hover .yf-mod-trigger,
.yf-mod-trigger:focus,
.yf-mod-trigger.active {
  opacity: 1;
}
@media (max-width: 768px) {
  .yf-mod-trigger {
    opacity: 0.75;
  }
}
.yf-mod-menu {
  position: fixed !important;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
  z-index: 2147483647 !important; /* Davanti a tutto il layout e senza tagli di overflow */
  display: none;
  flex-direction: column;
  min-width: 185px;
  max-width: 260px;
  padding: 6px 0;
  animation: yf-menu-fade 0.12s ease-out;
}

.yf-mod-menu button,
.yf-mod-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 8px 12px;
  text-align: left;
  font-size: 12.5px;
  cursor: pointer;
  color: #334155;
  width: 100%;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.yf-mod-menu button:hover,
.yf-mod-menu a:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.yf-mod-menu button svg,
.yf-mod-menu a svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
  opacity: 0.8;
}
.yf-mod-menu button.warning { color: #d97706; }
.yf-mod-menu button.warning:hover { background: #fffbeb; color: #b45309; }
.yf-mod-menu button.danger { color: #dc2626; }
.yf-mod-menu button.danger:hover { background: #fef2f2; color: #991b1b; }
.yf-mod-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 4px 0;
}

/* ==========================================================================
   MODAL DIALOG (UTENTI BLOCCATI, ECC.)
   ========================================================================== */
.yf-chat-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.yf-chat-modal-dialog {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: yfModalFadeIn 0.2s ease-out;
}
@keyframes yfModalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.yf-chat-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
}
.yf-chat-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}
.yf-chat-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.yf-chat-modal-close:hover {
  color: #0f172a;
  background: #f1f5f9;
}
.yf-chat-modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: 60vh;
}
.yf-blocked-list-desc {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 12px;
}
.yf-blocked-users-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.yf-blocked-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  gap: 10px;
}
.yf-blocked-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.yf-blocked-name {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.yf-btn-unblock {
  background: #ffffff;
  color: #0084ff;
  border: 1px solid #0084ff;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.yf-btn-unblock:hover {
  background: #0084ff;
  color: #ffffff;
}
.yf-modal-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  padding: 24px 12px;
  margin: 0;
}

/* ==========================================================================
   TESTINE NOTIFICHE NON LETTE (UNREAD HEADS SOPRA IL LAUNCHER)
   ========================================================================== */
#yf-unread-heads {
  position: fixed;
  bottom: 82px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 99999;
  pointer-events: none;
}
.yf-unread-head {
  pointer-events: auto;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  position: relative;
  border: 2px solid #ffffff;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: yfHeadPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.yf-unread-head:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
.yf-unread-head img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.yf-head-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #0084ff, #00c6ff);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.yf-unread-head .yf-head-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  top: auto;
  left: auto;
  background: #ef4444; /* Rosso vivo */
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  animation: yfBadgePulse 1.8s infinite;
  line-height: 1;
}
@keyframes yfHeadPop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes yfBadgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ==========================================================================
   AVATAR CLICCABILE E SCHEDA PROFILO UTENTE NEL CORPO MESSAGGI
   ========================================================================== */
.yf-msg-avatar-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  outline: none;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.yf-msg-avatar-btn:hover {
  transform: scale(1.1);
}
.yf-avatar-popover {
  position: fixed !important;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
  width: 220px;
  z-index: 2147483647 !important; /* Davanti a tutto! */
  overflow: hidden;
  animation: yfModalFadeIn 0.18s ease-out;
  display: flex;
  flex-direction: column;
}
.yf-popover-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
}
.yf-popover-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.yf-popover-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.yf-popover-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yf-popover-role {
  font-size: 11px;
  color: #64748b;
}
.yf-popover-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.yf-popover-close:hover {
  color: #0f172a;
}
.yf-popover-body {
  padding: 4px 0;
  display: flex;
  flex-direction: column;
}
.yf-popover-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: #334155;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.yf-popover-action:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.yf-popover-action svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex-shrink: 0;
}
.yf-popover-action.warning { color: #d97706; }
.yf-popover-action.warning:hover { background: #fffbeb; color: #b45309; }
.yf-popover-action.danger { color: #dc2626; }
.yf-popover-action.danger:hover { background: #fef2f2; color: #991b1b; }

/* ==========================================================================
   RESPONSIVE DESIGN (SMARTPHONE E TABLET - FULLSCREEN MODERNO)
   ========================================================================== */
@media (max-width: 768px) {
  #yf-chat-root .yf-launcher-btn {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
  #yf-unread-heads {
    display: none !important;
  }
  #yf-chat-root .yf-hub-card {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 100000 !important;
  }
  #yf-chat-root .yf-docked-windows,
  #yf-chat-root.hub-open .yf-docked-windows {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    z-index: 100002 !important;
    pointer-events: none !important;
    flex-direction: column !important;
    gap: 0 !important;
  }
  .yf-docked-box {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 100003 !important;
    pointer-events: auto !important;
  }
  .yf-docked-box.minimized {
    height: 100% !important;
    height: 100dvh !important;
  }
  .yf-docked-box.minimized .yf-box-body,
  .yf-docked-box.minimized .yf-box-footer {
    display: flex !important;
  }
  .yf-docked-box .yf-box-header {
    padding: 12px 16px !important;
    border-radius: 0 !important;
  }
  .yf-docked-box .yf-btn-min {
    display: none !important;
  }
  .yf-docked-box .yf-btn-close,
  .yf-hub-card #yf-hub-close {
    font-size: 28px !important;
    padding: 6px 12px !important;
    color: #64748b !important;
    line-height: 1 !important;
    cursor: pointer !important;
  }

  /* Selettore Emoji su Smartphone e Tablet */
  .yf-emoji-popover {
    position: absolute !important;
    bottom: 58px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    height: 250px !important;
    max-height: 45vh !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.22) !important;
    z-index: 100005 !important;
  }
  .yf-emoji-grid {
    grid-template-columns: repeat(8, 1fr) !important;
    gap: 4px !important;
  }
  .yf-emoji-item {
    height: 38px !important;
    font-size: 23px !important;
  }
  .yf-emoji-tab {
    padding: 6px 9px !important;
    font-size: 12px !important;
  }
}
