.ha-ai {
  --ha-navy: #082f5f;
  --ha-navy-deep: #06264d;
  --ha-teal: #168b9b;
  --ha-ink: #102f52;
  --ha-muted: #68788b;
  --ha-line: #dce4eb;
  --ha-bg: #f5f8fa;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 99998;
  font-family: "Avenir Next", "SF Pro Text", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: var(--ha-ink);
}

.ha-ai *, .ha-ai *::before, .ha-ai *::after { box-sizing: border-box; }

.ha-ai__launcher {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 3px;
  background: var(--ha-navy);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  box-shadow: 0 13px 32px rgba(6, 38, 77, .24);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.ha-ai__launcher:hover { background: var(--ha-navy-deep); transform: translateY(-2px); box-shadow: 0 17px 38px rgba(6, 38, 77, .3); }
.ha-ai__launcher:focus-visible, .ha-ai button:focus-visible, .ha-ai textarea:focus-visible { outline: 3px solid rgba(22, 139, 155, .35); outline-offset: 3px; }
.ha-ai__launcher svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ha-ai--open .ha-ai__launcher { opacity: 0; pointer-events: none; }

.ha-ai__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto auto auto;
  width: min(390px, calc(100vw - 40px));
  height: min(650px, calc(100vh - 40px));
  max-height: 650px;
  overflow: hidden;
  border: 1px solid rgba(8, 47, 95, .13);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 25px 70px rgba(7, 35, 67, .25);
  transform-origin: bottom right;
  animation: ha-ai-in .2s ease-out;
}

.ha-ai__panel[hidden] { display: none; }

@keyframes ha-ai-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ha-ai__header {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 11px;
  min-height: 78px;
  padding: 14px 14px 14px 18px;
  background: var(--ha-navy);
  color: #fff;
}

.ha-ai__brand {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .28);
  color: #fff;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: .08em;
}

.ha-ai__header h2 { margin: 0; color: inherit; font-size: 17px; font-weight: 650; line-height: 1.25; }
.ha-ai__header p { margin: 4px 0 0; color: rgba(255, 255, 255, .76); font-size: 12px; line-height: 1.3; }
.ha-ai__header p span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: #5bd1b3; }

.ha-ai__close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 26px;
  font-weight: 300;
  cursor: pointer;
}
.ha-ai__close:hover { background: rgba(255, 255, 255, .1); }

.ha-ai__messages {
  overflow-y: auto;
  padding: 20px 16px 12px;
  background: linear-gradient(180deg, #f7fafb 0%, #fff 26%);
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.ha-ai__message {
  width: fit-content;
  max-width: 86%;
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: 5px 14px 14px 14px;
  background: #edf2f5;
  color: #283e55;
  font-size: 14px;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
}

.ha-ai__message[dir="rtl"],
.ha-ai__form textarea[dir="rtl"] {
  font-family: "SF Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  line-height: 1.82;
  letter-spacing: 0;
  text-align: right;
}

.ha-ai__message--user {
  margin-left: auto;
  border-radius: 14px 5px 14px 14px;
  background: var(--ha-navy);
  color: #fff;
}
.ha-ai__message--pending { color: var(--ha-muted); font-style: italic; }
.ha-ai__message--error { border: 1px solid #ead9d5; background: #fff7f5; }
.ha-ai__message a { color: var(--ha-teal); font-weight: 650; }

.ha-ai__suggestions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 16px 12px;
  background: #fff;
  scrollbar-width: none;
}
.ha-ai__suggestions::-webkit-scrollbar { display: none; }
.ha-ai__suggestions button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--ha-line);
  border-radius: 999px;
  background: #fff;
  color: var(--ha-ink);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.ha-ai__suggestions button:hover { border-color: var(--ha-teal); color: var(--ha-teal); }

.ha-ai__form {
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: end;
  gap: 9px;
  padding: 12px 14px;
  border-top: 1px solid var(--ha-line);
  background: #fff;
}

.ha-ai__form textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 112px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid #cfd9e1;
  border-radius: 4px;
  background: #fff;
  color: var(--ha-ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
}
.ha-ai__form textarea::placeholder { color: #8290a0; }

.ha-ai__send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 4px;
  background: var(--ha-teal);
  color: #fff;
  cursor: pointer;
}
.ha-ai__send:hover { background: #117887; }
.ha-ai__send:disabled { cursor: wait; opacity: .55; }
.ha-ai__send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ha-ai__footer {
  padding: 0 15px 11px;
  background: #fff;
  color: #83909d;
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
}

@media (max-width: 600px) {
  .ha-ai { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
  .ha-ai__launcher { min-height: 50px; padding: 0 15px; }
  .ha-ai__panel {
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    width: auto;
    height: min(680px, calc(100dvh - 20px));
    max-height: none;
    border-radius: 7px;
  }
  .ha-ai__header { min-height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .ha-ai__panel { animation: none; }
  .ha-ai__launcher { transition: none; }
}


.ha-ai__lead {
  padding: 0 16px 12px;
  background: #fff;
}
.ha-ai__lead-toggle,
.ha-ai__lead-submit {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  background: #08a6a6;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.ha-ai__lead-form {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #dce5ea;
  border-radius: 10px;
  background: #f8fbfc;
  max-height: 310px;
  overflow-y: auto;
}
.ha-ai__lead-title {
  margin: 0 0 10px;
  color: #102c45;
  font-weight: 750;
}
.ha-ai__lead-form label {
  display: block;
  margin: 8px 0;
  color: #233746;
  font-size: 13px;
  font-weight: 600;
}
.ha-ai__lead-form input:not([type="checkbox"]),
.ha-ai__lead-form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  border: 1px solid #cbd8df;
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: #142633;
  font: inherit;
  box-sizing: border-box;
}
.ha-ai__consent {
  display: flex !important;
  gap: 8px;
  align-items: flex-start;
  font-weight: 400 !important;
  line-height: 1.45;
}
.ha-ai__consent input { margin-top: 3px; }
.ha-ai__website {
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
}
.ha-ai__lead-status {
  margin: 9px 0 0;
  color: #244457;
  font-size: 13px;
  line-height: 1.5;
}
.ha-ai__footer a { color: inherit; text-decoration: underline; }

/* Multilingual corner chat — 0.7.0 */
.ha-ai__launcher{width:54px;height:54px;min-height:54px;padding:0!important;justify-content:center;border-radius:50%;}
.ha-ai__launcher>span{display:none;}
.ha-ai__languages{position:absolute;bottom:66px;right:0;width:230px;padding:12px;background:#fff;border:1px solid var(--ha-line);border-radius:12px;box-shadow:0 15px 45px rgba(6,38,77,.22);}
.ha-ai__languages[hidden]{display:none;}
.ha-ai__languages h3{margin:3px 6px 10px;font-size:14px;color:var(--ha-ink);}
.ha-ai__languages button{display:flex;align-items:center;gap:12px;width:100%;min-height:44px;padding:9px 10px;border:0;border-radius:7px;background:#fff;color:var(--ha-ink);font:inherit;font-size:14px;text-align:left;cursor:pointer;}
.ha-ai__languages button:hover,.ha-ai__languages button:focus-visible{background:#eef7f8;}
.ha-ai__flag{font-size:23px;line-height:1;}
.ha-ai__change-language{border:0;background:transparent;color:inherit;font:inherit;font-size:12px;cursor:pointer;text-decoration:underline;text-underline-offset:3px;padding:4px 0;}
.ha-ai__panel{display:flex;flex-direction:column;height:min(650px,calc(100dvh - 40px));}
.ha-ai__messages{flex:1;min-height:70px;}
.ha-ai__header,.ha-ai__form,.ha-ai__footer,.ha-ai__lead,.ha-ai__suggestions{flex-shrink:0;}
.ha-ai [hidden]{display:none!important;}
.ha-ai__form textarea{font-size:16px;}
.ha-ai__footer{color:#647588;}
.ha-ai button:disabled{opacity:.55;cursor:wait;}
@media(max-width:600px){.ha-ai__panel{height:min(650px,calc(100dvh - 20px));}.ha-ai__lead-form{max-height:180px;}.ha-ai__languages{max-width:calc(100vw - 24px);}}

/* Assistant discovery — 0.7.2 */
.ha-ai__launcher{width:auto;padding:0 17px!important;gap:10px;border-radius:27px;font-size:13px;}
.ha-ai__launcher>span{display:inline;white-space:nowrap;}
.ha-ai__intro{position:absolute;right:0;bottom:66px;display:flex;align-items:flex-start;width:280px;max-width:calc(100vw - 32px);padding:12px 10px 12px 14px;border:1px solid var(--ha-line);border-radius:10px;background:#fff;box-shadow:0 12px 35px rgba(6,38,77,.18);}
.ha-ai__intro:after{content:'';position:absolute;bottom:-6px;right:24px;width:10px;height:10px;transform:rotate(45deg);background:#fff;border-right:1px solid var(--ha-line);border-bottom:1px solid var(--ha-line);}
.ha-ai__intro-action{flex:1;border:0;padding:0;background:transparent;color:var(--ha-ink);font:inherit;font-size:13px;line-height:1.55;text-align:left;cursor:pointer;}
.ha-ai__intro-close{flex-shrink:0;display:grid;place-items:center;width:30px;height:30px;margin:-3px -3px 0 5px;border:0;border-radius:50%;background:transparent;color:var(--ha-muted);font:inherit;font-size:22px;cursor:pointer;}
.ha-ai__intro-close:hover{background:#eef3f7;}
@media(max-width:600px){.ha-ai__launcher{font-size:12px;padding:0 13px!important;gap:8px;}.ha-ai__intro{width:260px;}.ha-ai__intro-close{width:40px;height:40px;margin-top:-6px;}}

.ha-ai .ha-ai__launcher>span{font-size:13px!important;}
.ha-ai .ha-ai__launcher>span::after{content:none!important;display:none!important;}
@media(max-width:600px){.ha-ai .ha-ai__launcher>span{font-size:12px!important;}}
