/* =========================================================
   Rabbit Assistant Right Safe v18
   - Sposta il launcher Chat/Assistente a destra
   - Riserva spazio alle notifiche/toast in basso a destra
   - Mantiene stile glass della sidebar/rightbar
   ========================================================= */
:root{
  /* Fallback sicuro se il JS anti-sovrapposizione non è ancora partito. */
  --rabbit-toast-stack-height:72px;
  --rabbit-assistant-edge:26px;
  --rabbit-assistant-base-bottom:24px;
  --rabbit-assistant-gap:18px;
}

/* Launcher principale spostato a destra, fuori dalla sidebar sinistra. */
#rabbitUnifiedHub{
  left:auto !important;
  right:var(--rabbit-assistant-edge) !important;
  bottom:calc(var(--rabbit-assistant-base-bottom) + var(--rabbit-toast-stack-height, 72px)) !important;
  z-index:8800 !important;
  justify-items:end !important;
  align-items:end !important;
  pointer-events:auto !important;
}

#rabbitUnifiedHub .rah-menu,
#rabbitUnifiedHubMenu{
  justify-items:end !important;
  align-items:end !important;
  transform-origin:right bottom !important;
}

#rabbitUnifiedHub .rah-choice{
  transform-origin:right bottom !important;
}

#rabbitUnifiedHub .rah-choice:hover{
  transform:translateX(-4px) !important;
}

/* Il bottone resta coerente con il nuovo stile chiaro/glass. */
#rabbitHubMain{
  min-width:184px !important;
  background:rgba(255,255,255,.94) !important;
  color:#0f172a !important;
  border:1px solid rgba(226,232,240,.98) !important;
  box-shadow:0 18px 44px rgba(15,23,42,.14), 0 8px 18px rgba(15,23,42,.06) !important;
  backdrop-filter:blur(16px) !important;
}
#rabbitHubMain .rah-main-icon{
  background:linear-gradient(135deg,#dbeafe,#ccfbf1) !important;
  border-color:#dbeafe !important;
  color:#1d4ed8 !important;
}
#rabbitHubMain .rah-main-text b{color:#0f172a !important;}
#rabbitHubMain .rah-main-text small{color:#64748b !important;}

/* Anche il pannello dell’assistente si apre da destra, sopra l’eventuale toast. */
#rabbitAssistantPanel{
  left:auto !important;
  right:var(--rabbit-assistant-edge) !important;
  bottom:calc(96px + var(--rabbit-toast-stack-height, 72px)) !important;
  z-index:8850 !important;
  transform-origin:right bottom !important;
}

/* Le notifiche applicative devono sempre poter stare sopra il launcher. */
#toast.toast,
.nexa-toast,
.nexa-official-toast,
.nexa-clean-toast,
.nexa-call-status-toast,
.nexa-call-watchdog-toast,
.nexa-peer-fix-toast{
  z-index:9000 !important;
}

/* Se una vecchia chat flottante usa il bottom-right, non deve incastrarsi col nuovo hub. */
.nexa-fb-launcher.show,
.nexa-floating-launcher.show{
  bottom:calc(24px + var(--rabbit-toast-stack-height, 72px)) !important;
}

@media (max-width:1180px){
  :root{
    --rabbit-assistant-edge:18px;
    --rabbit-assistant-base-bottom:18px;
  }
}

@media (max-width:640px){
  :root{
    --rabbit-assistant-edge:14px;
    --rabbit-assistant-base-bottom:calc(14px + env(safe-area-inset-bottom,0px));
  }

  #rabbitUnifiedHub{
    left:auto !important;
    right:var(--rabbit-assistant-edge) !important;
    bottom:calc(var(--rabbit-assistant-base-bottom) + var(--rabbit-toast-stack-height, 72px)) !important;
  }

  #rabbitHubMain{
    min-width:62px !important;
    width:62px !important;
    height:62px !important;
    padding:0 !important;
  }

  #rabbitHubMain .rah-main-text{display:none !important;}

  #rabbitAssistantPanel{
    left:10px !important;
    right:10px !important;
    bottom:calc(88px + env(safe-area-inset-bottom,0px) + var(--rabbit-toast-stack-height, 0px)) !important;
    width:auto !important;
    height:calc(100vh - 112px - env(safe-area-inset-bottom,0px) - var(--rabbit-toast-stack-height, 0px)) !important;
    min-height:0 !important;
  }
}
