/* ============================================================
   CI HELPDESK — Consumer Ideas AI Assistant (shared widget)
   Loaded on every page via <link>. Markup injected by
   assets/ci-helpdesk.js. Self-contained: falls back to its own
   palette if a page has not defined the site variables.
   ============================================================ */
:root{
  --cih-navy:var(--navy,#0d2b45);
  --cih-slate:var(--slate,#2c4a62);
  --cih-blue:var(--blue,#3a9fd6);
  --cih-blue-deep:var(--blue-deep,#1c7ab5);
  --cih-blue-light:var(--blue-light,#6fc3eb);
  --cih-blue-pale:var(--blue-pale,#e6f4fb);
  --cih-cream:var(--cream,#f0f5fa);
  --cih-ink:var(--ink,#0d1117);
  /* Chatbot uses Calibri throughout (per brand preference) */
  --cih-serif:'Calibri','Segoe UI',Candara,'Trebuchet MS',system-ui,sans-serif;
  --cih-sans:'Calibri','Segoe UI',Candara,'Trebuchet MS',system-ui,sans-serif;
}

/* ---------- Launcher ---------- */
#ci-help-launcher{
  position:fixed;bottom:24px;right:24px;z-index:9500;
  display:inline-flex;align-items:center;gap:0.55rem;
  background:linear-gradient(135deg,var(--cih-blue-deep),var(--cih-navy));
  color:#fff;border:none;cursor:pointer;
  padding:0.8rem 1.25rem 0.8rem 0.95rem;border-radius:50px;
  font-family:var(--cih-sans);font-size:0.82rem;font-weight:600;letter-spacing:0.04em;
  box-shadow:0 10px 30px rgba(13,43,69,0.38);
  transition:transform .28s cubic-bezier(.34,1.56,.64,1),box-shadow .28s,filter .28s;
  animation:cihFloat 4.5s ease-in-out infinite;
}
#ci-help-launcher:hover{transform:translateY(-3px) scale(1.03);box-shadow:0 16px 40px rgba(13,43,69,0.46);filter:brightness(1.06);}
#ci-help-launcher:active{transform:translateY(-1px) scale(.99);}
#ci-help-launcher .cih-orb{
  position:relative;width:30px;height:30px;border-radius:50%;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  background:radial-gradient(circle at 32% 30%,var(--cih-blue-light),var(--cih-blue) 70%);
  box-shadow:0 0 0 3px rgba(111,195,235,0.22),inset 0 -3px 6px rgba(13,43,69,0.35);
}
#ci-help-launcher .cih-orb svg{width:17px;height:17px;color:#fff;}
#ci-help-launcher .ci-pulse{position:absolute;top:6px;right:8px;width:10px;height:10px;border-radius:50%;background:#5ad07f;box-shadow:0 0 0 0 rgba(90,208,127,0.6);animation:ciPulse 2.2s infinite;}
#ci-help-launcher .cih-badge{
  position:absolute;top:-6px;right:-4px;min-width:18px;height:18px;padding:0 5px;border-radius:9px;
  background:#e8543f;color:#fff;font-size:0.62rem;font-weight:700;line-height:18px;text-align:center;
  box-shadow:0 3px 8px rgba(0,0,0,0.25);transform:scale(0);transition:transform .3s cubic-bezier(.34,1.56,.64,1);
}
#ci-help-launcher.cih-has-badge .cih-badge{transform:scale(1);}
@keyframes ciPulse{0%{box-shadow:0 0 0 0 rgba(90,208,127,0.55);}70%{box-shadow:0 0 0 10px rgba(90,208,127,0);}100%{box-shadow:0 0 0 0 rgba(90,208,127,0);}}
@keyframes cihFloat{0%,100%{transform:translateY(0);}50%{transform:translateY(-6px);}}
body.ci-open #ci-help-launcher{opacity:0;pointer-events:none;transform:scale(0.82);}

/* ---------- Proactive nudge ---------- */
#ci-help-nudge{
  position:fixed;bottom:86px;right:24px;z-index:9499;max-width:250px;
  background:#fff;color:var(--cih-ink);border:1px solid rgba(58,159,214,0.22);
  border-radius:14px 14px 4px 14px;padding:0.7rem 0.9rem;font-family:var(--cih-sans);
  font-size:0.82rem;line-height:1.45;box-shadow:0 14px 36px rgba(13,43,69,0.22);
  opacity:0;transform:translateY(12px) scale(.96);transform-origin:bottom right;pointer-events:none;
  transition:opacity .35s ease,transform .35s cubic-bezier(.34,1.56,.64,1);
}
#ci-help-nudge.show{opacity:1;transform:translateY(0) scale(1);pointer-events:auto;}
#ci-help-nudge strong{color:var(--cih-blue-deep);}
#ci-help-nudge .cih-nudge-close{position:absolute;top:4px;right:6px;border:none;background:none;color:rgba(13,17,23,.4);font-size:0.95rem;cursor:pointer;line-height:1;padding:2px;}
#ci-help-nudge .cih-nudge-close:hover{color:var(--cih-ink);}
body.ci-open #ci-help-nudge{opacity:0;pointer-events:none;}

/* ---------- Panel ---------- */
#ci-help-panel{
  position:fixed;bottom:24px;right:24px;z-index:9501;
  width:390px;max-width:calc(100vw - 32px);height:min(640px,calc(100vh - 48px));
  display:flex;flex-direction:column;background:var(--cih-cream);border-radius:18px;overflow:hidden;
  box-shadow:0 30px 70px rgba(8,13,20,0.42);
  opacity:0;transform:translateY(24px) scale(0.96);transform-origin:bottom right;pointer-events:none;
  transition:opacity .3s ease,transform .3s cubic-bezier(.34,1.4,.64,1);
  border:1px solid rgba(58,159,214,0.18);
}
#ci-help-panel.open{opacity:1;transform:translateY(0) scale(1);pointer-events:auto;}

/* Header */
.ci-head{position:relative;background:linear-gradient(135deg,var(--cih-navy) 0%,var(--cih-slate) 100%);padding:1.05rem 1.1rem;display:flex;align-items:center;gap:0.8rem;color:var(--cih-cream);overflow:hidden;}
.ci-head::before{content:'';position:absolute;inset:0;background:radial-gradient(120% 90% at 85% -10%,rgba(111,195,235,0.28),transparent 60%);pointer-events:none;}
.ci-head::after{content:'';position:absolute;left:0;right:0;bottom:0;height:3px;background:linear-gradient(to right,var(--cih-blue-deep),var(--cih-blue),var(--cih-blue-light),transparent 88%);}
.ci-head-avatar{position:relative;width:44px;height:44px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;
  background:radial-gradient(circle at 33% 30%,var(--cih-blue-light),var(--cih-blue) 72%);color:#fff;font-family:var(--cih-serif);font-weight:700;font-size:1.15rem;
  box-shadow:0 0 0 3px rgba(111,195,235,0.22);overflow:visible;}
.ci-head-avatar img{width:100%;height:100%;border-radius:50%;object-fit:cover;display:block;}
.ci-head-avatar::after{content:'';position:absolute;inset:-5px;border-radius:50%;border:1.5px solid rgba(111,195,235,0.4);animation:cihRing 2.6s ease-in-out infinite;}
@keyframes cihRing{0%,100%{transform:scale(1);opacity:.7;}50%{transform:scale(1.14);opacity:0;}}
.ci-head-meta{flex:1;min-width:0;}
.ci-head-title{font-family:var(--cih-serif);font-size:1.22rem;font-weight:700;line-height:1.1;letter-spacing:-0.01em;}
.ci-head-status{display:flex;align-items:center;gap:0.4rem;font-size:0.7rem;letter-spacing:0.03em;color:rgba(240,245,250,0.66);margin-top:0.18rem;}
.ci-head-status .ci-online{width:7px;height:7px;border-radius:50%;background:#5ad07f;box-shadow:0 0 0 2px rgba(90,208,127,0.25);animation:cihBlink 2.4s ease-in-out infinite;}
@keyframes cihBlink{0%,100%{opacity:1;}50%{opacity:.5;}}
.ci-head-btns{display:flex;align-items:center;gap:2px;flex-shrink:0;}
.ci-head-btns button{background:none;border:none;color:rgba(240,245,250,0.7);cursor:pointer;padding:6px;border-radius:8px;line-height:0;transition:background .2s,color .2s;}
.ci-head-btns button:hover{background:rgba(255,255,255,0.12);color:#fff;}

/* Body */
.ci-body{flex:1;overflow-y:auto;padding:1.1rem 1rem 0.5rem;display:flex;flex-direction:column;gap:0.8rem;scroll-behavior:smooth;background:linear-gradient(180deg,var(--cih-cream),#fff 90%);}
.ci-body::-webkit-scrollbar{width:7px;}
.ci-body::-webkit-scrollbar-thumb{background:rgba(58,159,214,0.3);border-radius:4px;}

.ci-msg{display:flex;gap:0.55rem;align-items:flex-end;max-width:90%;animation:ciFade .38s cubic-bezier(.22,1,.36,1) both;}
@keyframes ciFade{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:translateY(0);}}
.ci-msg.bot{align-self:flex-start;}
.ci-msg.user{align-self:flex-end;flex-direction:row-reverse;}
.ci-mini{width:27px;height:27px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;
  background:radial-gradient(circle at 33% 30%,var(--cih-blue-light),var(--cih-blue) 75%);color:#fff;font-family:var(--cih-serif);font-weight:700;font-size:0.66rem;overflow:hidden;}
.ci-mini img{width:100%;height:100%;border-radius:50%;object-fit:cover;display:block;}
.ci-msg.user .ci-mini{display:none;}
.ci-bubble{padding:0.7rem 0.9rem;border-radius:15px;font-size:0.875rem;line-height:1.55;font-family:var(--cih-sans);}
.ci-msg.bot .ci-bubble{background:#fff;color:var(--cih-ink);border:1px solid rgba(58,159,214,0.16);border-bottom-left-radius:5px;box-shadow:0 3px 12px rgba(13,43,69,0.06);}
.ci-msg.user .ci-bubble{background:linear-gradient(135deg,var(--cih-blue-deep),var(--cih-navy));color:#fff;border-bottom-right-radius:5px;box-shadow:0 4px 14px rgba(13,43,69,0.22);}
.ci-bubble a{color:var(--cih-blue-deep);font-weight:600;text-decoration:underline;text-underline-offset:2px;}
.ci-msg.user .ci-bubble a{color:#fff;}
.ci-bubble strong{font-weight:600;}
.ci-bubble ul{margin:0.4rem 0 0.1rem;padding-left:1.05rem;display:flex;flex-direction:column;gap:0.18rem;}
.ci-bubble li{font-size:0.84rem;}
.ci-bubble p{margin:0 0 .45rem;}
.ci-bubble p:last-child{margin-bottom:0;}

/* In-bubble quick action buttons */
.cih-actions{display:flex;flex-wrap:wrap;gap:0.4rem;margin-top:0.6rem;}
.cih-action{display:inline-flex;align-items:center;gap:0.35rem;font-family:var(--cih-sans);font-size:0.76rem;font-weight:600;
  color:#fff;background:linear-gradient(135deg,var(--cih-blue),var(--cih-blue-deep));border:none;border-radius:9px;
  padding:0.5rem 0.75rem;cursor:pointer;text-decoration:none;transition:transform .15s,box-shadow .2s,filter .2s;box-shadow:0 3px 10px rgba(28,122,181,0.28);}
.cih-action:hover{transform:translateY(-1px);filter:brightness(1.07);box-shadow:0 6px 16px rgba(28,122,181,0.36);}
.cih-action.ghost{background:#fff;color:var(--cih-blue-deep);border:1px solid rgba(58,159,214,0.35);box-shadow:none;}
.cih-action.ghost:hover{background:var(--cih-blue-pale);}
.cih-action svg{width:14px;height:14px;}

/* Typing */
.ci-typing{display:flex;gap:4px;padding:0.85rem 0.95rem;}
.ci-typing span{width:7px;height:7px;border-radius:50%;background:var(--cih-blue);opacity:0.5;animation:ciBounce 1.2s infinite;}
.ci-typing span:nth-child(2){animation-delay:0.18s;}
.ci-typing span:nth-child(3){animation-delay:0.36s;}
@keyframes ciBounce{0%,60%,100%{transform:translateY(0);opacity:0.4;}30%{transform:translateY(-5px);opacity:1;}}

/* Feedback row */
.cih-fb{display:flex;align-items:center;gap:0.5rem;margin-top:0.55rem;font-size:0.72rem;color:rgba(13,17,23,0.5);font-family:var(--cih-sans);}
.cih-fb button{border:1px solid rgba(58,159,214,0.28);background:#fff;border-radius:7px;padding:2px 7px;cursor:pointer;font-size:0.8rem;line-height:1.3;transition:background .18s,transform .15s,border-color .18s;}
.cih-fb button:hover{background:var(--cih-blue-pale);transform:translateY(-1px);}
.cih-fb.done{color:var(--cih-blue-deep);font-weight:600;}

/* Inline lead form */
.cih-form{background:#fff;border:1px solid rgba(58,159,214,0.2);border-radius:14px;padding:0.9rem;margin-top:0.2rem;box-shadow:0 4px 16px rgba(13,43,69,0.07);animation:ciFade .35s both;}
.cih-form h4{font-family:var(--cih-serif);font-size:1.05rem;color:var(--cih-navy);margin:0 0 0.15rem;font-weight:700;}
.cih-form p.cih-form-sub{font-size:0.76rem;color:rgba(13,17,23,0.55);margin:0 0 0.7rem;font-family:var(--cih-sans);}
.cih-form label{display:block;font-size:0.68rem;font-weight:600;letter-spacing:0.04em;text-transform:uppercase;color:var(--cih-slate);margin:0.55rem 0 0.2rem;font-family:var(--cih-sans);}
.cih-form input,.cih-form textarea,.cih-form select{width:100%;border:1px solid rgba(58,159,214,0.28);background:var(--cih-cream);border-radius:9px;padding:0.55rem 0.7rem;font-family:var(--cih-sans);font-size:0.84rem;color:var(--cih-ink);outline:none;transition:border-color .2s,box-shadow .2s;}
.cih-form input:focus,.cih-form textarea:focus,.cih-form select:focus{border-color:var(--cih-blue);box-shadow:0 0 0 3px rgba(58,159,214,0.15);}
.cih-form textarea{resize:vertical;min-height:64px;}
.cih-form .cih-form-row{display:flex;gap:0.5rem;}
.cih-form .cih-form-row>div{flex:1;}
.cih-form .cih-err{color:#c23b22;font-size:0.7rem;margin-top:0.3rem;font-family:var(--cih-sans);}
.cih-form-btns{display:flex;gap:0.5rem;margin-top:0.8rem;}
.cih-form-btns button{flex:1;font-family:var(--cih-sans);font-weight:600;font-size:0.82rem;border-radius:9px;padding:0.6rem;cursor:pointer;transition:filter .2s,background .2s,transform .15s;}
.cih-form-submit{border:none;color:#fff;background:linear-gradient(135deg,var(--cih-blue),var(--cih-blue-deep));box-shadow:0 4px 12px rgba(28,122,181,0.3);}
.cih-form-submit:hover{filter:brightness(1.07);transform:translateY(-1px);}
.cih-form-cancel{border:1px solid rgba(58,159,214,0.3);background:#fff;color:var(--cih-slate);}
.cih-form-cancel:hover{background:var(--cih-cream);}

/* Chips */
.ci-chips{display:flex;flex-wrap:wrap;gap:0.4rem;padding:0.35rem 1rem 0.55rem;background:#fff;}
.ci-chip{display:inline-flex;align-items:center;gap:0.3rem;font-family:var(--cih-sans);font-size:0.74rem;font-weight:600;letter-spacing:0.01em;
  color:var(--cih-blue-deep);background:var(--cih-blue-pale);border:1px solid rgba(58,159,214,0.28);border-radius:50px;
  padding:0.42rem 0.8rem;cursor:pointer;transition:background .2s,color .2s,border-color .2s,transform .15s,box-shadow .2s;}
.ci-chip:hover{background:var(--cih-blue);color:#fff;border-color:var(--cih-blue);transform:translateY(-1px);box-shadow:0 5px 14px rgba(58,159,214,0.28);}

/* Footer */
.ci-foot{display:flex;align-items:center;gap:0.5rem;padding:0.7rem 0.75rem;background:#fff;border-top:1px solid rgba(58,159,214,0.14);}
.ci-foot input{flex:1;border:1px solid rgba(58,159,214,0.25);background:var(--cih-cream);border-radius:50px;padding:0.68rem 0.95rem;font-family:var(--cih-sans);font-size:0.86rem;color:var(--cih-ink);outline:none;transition:border-color .2s,box-shadow .2s;}
.ci-foot input:focus{border-color:var(--cih-blue);box-shadow:0 0 0 3px rgba(58,159,214,0.15);}
.ci-send{width:42px;height:42px;border-radius:50%;border:none;background:linear-gradient(135deg,var(--cih-blue-deep),var(--cih-navy));color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:filter .2s,transform .2s;}
.ci-send:hover{filter:brightness(1.1);transform:scale(1.06);}
.ci-send:active{transform:scale(.96);}
.ci-send:disabled{opacity:0.4;cursor:not-allowed;transform:none;filter:none;}
.ci-disclaimer{font-size:0.62rem;text-align:center;color:rgba(13,17,23,0.4);padding:0 1rem 0.55rem;background:#fff;letter-spacing:0.02em;font-family:var(--cih-sans);}
.ci-disclaimer a{color:rgba(13,17,23,0.55);}

/* Mobile full-screen */
@media(max-width:559px){
  #ci-help-launcher{bottom:16px;right:16px;}
  #ci-help-nudge{bottom:74px;right:16px;left:16px;max-width:none;}
  #ci-help-panel{bottom:0;right:0;left:0;top:0;width:100%;max-width:100%;height:100%;height:100dvh;border-radius:0;border:none;}
}

@media(prefers-reduced-motion:reduce){
  #ci-help-launcher,#ci-help-panel,.ci-msg,.ci-send,.ci-chip,.ci-pulse,.ci-typing span,
  .ci-head-avatar::after,.ci-head-status .ci-online,#ci-help-nudge,.cih-action,.cih-form{
    animation:none!important;transition:none!important;}
}
