/* Assistente AI Stock Italia Express — widget PC/mobile */
.sie-ai-fab{
  position:fixed !important;
  right:max(14px, env(safe-area-inset-right, 0px)) !important;
  left:auto !important;
  /* Sopra il bottone Cookie (di solito ~40-56px in basso a destra) */
  bottom:calc(78px + env(safe-area-inset-bottom, 0px)) !important;
  z-index:2147483000 !important;
  width:58px !important;
  height:58px !important;
  min-width:58px !important;
  min-height:58px !important;
  border:2px solid #fff !important;
  border-radius:18px !important;
  cursor:pointer !important;
  background:linear-gradient(145deg,#0b3d91,#0f766e) !important;
  color:#fff !important;
  font-weight:900 !important;
  font-size:.9rem !important;
  letter-spacing:.02em !important;
  box-shadow:0 14px 34px rgba(7,20,45,.35) !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  opacity:1 !important;
  visibility:visible !important;
  pointer-events:auto !important;
  -webkit-tap-highlight-color:transparent;
}
.sie-ai-fab:focus-visible{outline:3px solid #93c5fd;outline-offset:2px}
.sie-ai-panel{
  position:fixed !important;
  right:max(12px, env(safe-area-inset-right, 0px)) !important;
  left:auto !important;
  bottom:calc(148px + env(safe-area-inset-bottom, 0px)) !important;
  z-index:2147483001 !important;
  width:min(380px, calc(100vw - 24px)) !important;
  height:min(68vh, 560px);
  display:none;
  flex-direction:column;
  background:#fff;
  border:1px solid #dbe5f1;
  border-radius:20px;
  box-shadow:0 24px 60px rgba(7,20,45,.22);
  overflow:hidden;
}
.sie-ai-panel.is-open{display:flex !important}
.sie-ai-head{
  flex:0 0 auto;display:flex;align-items:flex-start;justify-content:space-between;gap:12px;
  padding:14px;background:linear-gradient(135deg,#07142d,#0b3d91);color:#fff;
}
.sie-ai-head > div{min-width:0;flex:1}
.sie-ai-head strong{display:block;font-size:.95rem;line-height:1.25}
.sie-ai-head small{display:block;opacity:.85;font-weight:600;font-size:.72rem;line-height:1.35;margin-top:4px}
.sie-ai-notice{
  flex:0 0 auto;padding:8px 12px;background:#fff7ed;color:#9a3412;
  font-size:.72rem;font-weight:800;line-height:1.35;border-bottom:1px solid #fed7aa;
}
.sie-ai-notice a{color:#9a3412;text-decoration:underline}
.sie-ai-close{
  flex:0 0 auto;border:0;background:rgba(255,255,255,.14);color:#fff;
  border-radius:10px;width:36px;height:36px;min-width:36px;min-height:36px;
  cursor:pointer;font-size:1.2rem;line-height:1;
}
.sie-ai-body{
  flex:1 1 auto;min-height:0;padding:12px;overflow:auto;
  display:flex;flex-direction:column;gap:8px;background:#f7fafc;
  -webkit-overflow-scrolling:touch;
}
.sie-ai-msg{
  padding:10px 12px;border-radius:14px;font-size:.86rem;font-weight:650;
  line-height:1.45;overflow-wrap:anywhere;word-break:break-word;max-width:100%;
}
.sie-ai-msg.bot{background:#eef4fb;color:#16324f;border:1px solid #d5e3f5;align-self:stretch}
.sie-ai-msg.user{background:#0b3d91;color:#fff;align-self:flex-end;max-width:88%}
.sie-ai-msg.typing{opacity:.75;font-style:italic}
.sie-ai-msg.err{background:#fef2f2;color:#991b1b;border:1px solid #fecaca}
.sie-ai-chips{
  flex:0 0 auto;display:flex;flex-wrap:wrap;gap:6px;
  padding:8px 12px;background:#fff;border-top:1px solid #e2e8f0;
}
.sie-ai-chips button{
  border:1px solid #d5e3f5;background:#f8fbff;color:#0b3d91;
  border-radius:999px;padding:8px 12px;min-height:36px;
  font-size:.72rem;font-weight:800;cursor:pointer;line-height:1.25;text-align:left;
}
.sie-ai-composer{
  flex:0 0 auto;display:flex;gap:8px;align-items:flex-end;
  padding:10px 12px;border-top:1px solid #e2e8f0;background:#fff;
}
.sie-ai-composer textarea{
  flex:1;min-height:44px;max-height:96px;resize:none;margin:0;
  border:1px solid #d5e3f5;border-radius:12px;padding:10px 12px;
  font:inherit;font-size:.86rem;font-weight:600;line-height:1.35;
}
.sie-ai-composer button{
  flex:0 0 auto;border:0;border-radius:12px;background:#0b3d91;color:#fff;
  padding:12px 14px;min-height:44px;font-weight:900;font-size:.82rem;cursor:pointer;
}
.sie-ai-foot{
  flex:0 0 auto;padding:8px 12px 10px;background:#f8fafc;
  display:flex;flex-wrap:wrap;gap:10px;align-items:center;
}
.sie-ai-foot a{font-size:.76rem;font-weight:800;color:#0b3d91;text-decoration:none}
.sie-ai-status{display:inline-flex;align-items:center;gap:6px;font-size:.72rem;font-weight:700;color:#166534}
.sie-ai-status i{width:7px;height:7px;border-radius:50%;background:#16a34a;display:inline-block}
body.sie-ai-open{overflow:hidden;touch-action:none}

@media (max-width:700px){
  .sie-ai-fab{
    right:max(12px, env(safe-area-inset-right, 0px)) !important;
    left:auto !important;
    bottom:calc(86px + env(safe-area-inset-bottom, 0px)) !important;
    width:56px !important;
    height:56px !important;
    min-width:56px !important;
    min-height:56px !important;
    font-size:.85rem !important;
    opacity:1 !important;
  }
  .sie-ai-panel{
    left:10px !important;
    right:10px !important;
    width:auto !important;
    max-width:none !important;
    bottom:calc(156px + env(safe-area-inset-bottom, 0px)) !important;
    height:min(58vh, 480px);
    border-radius:16px;
  }
  .sie-ai-chips{max-height:76px;overflow:auto}
  .sie-ai-chips button{white-space:normal;max-width:100%}
}

/* sie-admin-mobile-v1: solo pannello admin — FAB a sinistra, non copre CTA */
body.admin-portal .sie-ai-fab{
  left:max(12px, env(safe-area-inset-left, 0px)) !important;
  right:auto !important;
  bottom:calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  z-index:900 !important;
  width:52px !important;
  height:52px !important;
  min-width:52px !important;
  min-height:52px !important;
}
body.admin-portal .sie-ai-panel{
  left:10px !important;
  right:10px !important;
  width:auto !important;
  bottom:calc(78px + env(safe-area-inset-bottom, 0px)) !important;
  z-index:901 !important;
}
