/* ============================================
   HUBI.CSS — HUBI Chat Widget
   ============================================ */

.hubi-trigger {
  position: fixed; z-index: 200; cursor: pointer;
  width: 110px; height: 110px; border-radius: 50%;
  background: var(--navy); border: 3px solid var(--green);
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: box-shadow .3s ease;
}
.hubi-trigger.visible { opacity: 1; pointer-events: auto }
.hubi-trigger.docked {
  right: 16px; top: calc(50% - 55px);
  animation: hubiBob 3s ease-in-out infinite;
}
.hubi-trigger.docked:hover {
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
  animation-play-state: paused; transform: scale(1.08);
}
@keyframes hubiBob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
.hubi-trigger.fly-loop {
  right: 16px; top: calc(50% - 55px);
  animation: hubiRocketLand 4s cubic-bezier(.2,0,.2,1) forwards;
}
@keyframes hubiRocketLand {
  0% { opacity: 0; transform: translateY(-90vh) scale(.4) }
  12% { opacity: 1 }
  70% { transform: translateY(-2vh) scale(.98) }
  85% { transform: translateY(4px) scale(1.02) }
  100% { opacity: 1; transform: translateY(0) scale(1) }
}
.hubi-trigger .hubi-avatar {
  width: 90px; height: 90px; border-radius: 50%;
  object-fit: cover; pointer-events: none; user-select: none;
}
.hubi-badge {
  position: absolute; top: -4px; right: -4px;
  background: #c0392b; color: #fff; font-size: 13px; font-weight: 700;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif;
  opacity: 0; transform: scale(0);
  transition: opacity .3s ease, transform .3s ease;
  border: 2px solid var(--navy);
}
.hubi-badge.show { opacity: 1; transform: scale(1) }
.hubi-tooltip {
  position: absolute; right: 120px; top: 50%; transform: translateY(-50%);
  background: var(--green); color: #fff;
  font-family: 'Poppins', sans-serif; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .4s ease;
}
.hubi-tooltip::after {
  content: ''; position: absolute; right: -6px; top: 50%;
  transform: translateY(-50%); border: 6px solid transparent; border-left-color: var(--green);
}
.hubi-trigger.visible .hubi-tooltip { animation: tooltipFadeIn .6s ease 3.5s forwards }
.hubi-trigger.visible.docked .hubi-tooltip { opacity: 1; animation: flagWave 2.5s ease-in-out infinite }
@keyframes tooltipFadeIn { 0% { opacity: 0 } 100% { opacity: 1 } }
@keyframes flagWave {
  0%,100% { transform: translateY(-50%) rotate(0) scaleX(1) }
  25% { transform: translateY(-52%) rotate(-.8deg) scaleX(1.03) }
  50% { transform: translateY(-48%) rotate(.5deg) scaleX(.97) }
  75% { transform: translateY(-51%) rotate(-.3deg) scaleX(1.01) }
}

/* CHAT WINDOW */
.hubi-window {
  position: fixed; top: 50%; right: 120px;
  transform: translateY(-50%) scale(.95); z-index: 201;
  width: 380px; max-height: 520px; background: #fff;
  border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,.2);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.hubi-window.open { opacity: 1; transform: translateY(-50%) scale(1); pointer-events: auto }
.hubi-header { background: var(--navy); padding: 16px 20px; display: flex; align-items: center; gap: 12px; flex-shrink: 0 }
.hubi-header-avatar { width: 36px; height: 36px; flex-shrink: 0 }
.hubi-header-info { flex: 1 }
.hubi-header-name { color: #fff; font-family: 'Poppins', sans-serif; font-size: 15px; font-weight: 700 }
.hubi-header-status { color: var(--green); font-size: 11px; font-family: 'Poppins', sans-serif; font-weight: 500 }
.hubi-close {
  background: none; border: none; color: rgba(255,255,255,.6);
  font-size: 22px; cursor: pointer; padding: 4px 8px; transition: color .2s ease;
}
.hubi-close:hover { color: #fff }
.hubi-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 280px; max-height: 360px;
}
.hubi-msg {
  max-width: 85%; padding: 10px 14px; border-radius: 10px;
  font-size: 14px; line-height: 1.6; font-family: 'Raleway', sans-serif;
}
.hubi-msg.bot { background: var(--navy-light); color: var(--gray-text); align-self: flex-start; border-bottom-left-radius: 2px }
.hubi-msg.user { background: var(--navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 2px }
.hubi-msg.typing { color: var(--gray-muted); font-style: italic }
.hubi-input-area { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: #fafafa }
.hubi-input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-family: 'Raleway', sans-serif; font-size: 14px;
  color: var(--gray-text); outline: none; resize: none;
  min-height: 40px; max-height: 80px; transition: border-color .2s ease;
}
.hubi-input:focus { border-color: var(--navy) }
.hubi-send {
  background: var(--green); border: none; border-radius: 8px;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s ease; flex-shrink: 0;
}
.hubi-send:hover { background: var(--green-dark) }
.hubi-send:disabled { background: var(--border); cursor: not-allowed }
.hubi-send svg { width: 18px; height: 18px; fill: #fff }
.hubi-mic {
  background: var(--navy); border: none; border-radius: 8px;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s ease; flex-shrink: 0;
}
.hubi-mic:hover { background: #162d54 }
.hubi-mic.recording { background: #e74c3c; animation: micPulse 1s ease-in-out infinite }
.hubi-mic svg { width: 18px; height: 18px; fill: #fff }
@keyframes micPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(231,76,60,.4) } 50% { box-shadow: 0 0 0 8px rgba(231,76,60,0) } }

/* MOBILE */
@media(max-width:480px) {
  .hubi-window {
    width: calc(100vw - 16px); right: 8px;
    top: auto; bottom: 8px; transform: none; max-height: 70vh;
  }
  .hubi-window.open { transform: none }
  .hubi-trigger { width: 64px !important; height: 64px !important; top: auto !important; bottom: 80px !important; right: -6px !important }
  .hubi-avatar { width: 52px !important; height: 52px !important }
  .hubi-tooltip { display: none !important }
  .hubi-badge { width: 18px; height: 18px; font-size: 10px; top: -4px; right: -4px }
}
