.ha-chat {
  --ha-navy: #102638;
  --ha-gold: #f6be1a;
  --ha-green: #2d8d62;
  --ha-line: rgba(16, 38, 56, 0.14);
  bottom: 18px;
  position: fixed;
  right: 18px;
  z-index: 80;
}

.ha-chat-launcher {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent),
    var(--ha-navy);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 18px 45px rgba(16, 38, 56, 0.32);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  gap: 10px;
  min-height: 50px;
  padding: 8px 16px 8px 8px;
}

.ha-chat-icon {
  align-items: center;
  background: #fff;
  border-radius: 50%;
  color: var(--ha-navy);
  display: inline-flex;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.ha-chat-icon img {
  border-radius: 50%;
  height: 28px;
  object-fit: cover;
  width: 28px;
}

.ha-chat-help {
  font-size: 0.92rem;
  font-weight: 800;
}

.ha-chat-panel {
  backdrop-filter: blur(16px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 248, 0.98));
  border: 1px solid var(--ha-line);
  border-radius: 8px;
  bottom: 62px;
  box-shadow: 0 26px 70px rgba(16, 38, 56, 0.25);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: min(620px, calc(100vh - 100px));
  overflow: hidden;
  position: absolute;
  right: 0;
  width: min(390px, calc(100vw - 28px));
}

.ha-chat-panel[hidden] {
  display: none !important;
}

.ha-chat-header {
  align-items: center;
  background:
    radial-gradient(circle at top left, rgba(246, 190, 26, 0.2), transparent 38%),
    linear-gradient(135deg, #102638, #173d54);
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 14px 15px;
}

.ha-chat-header strong,
.ha-chat-header small {
  display: block;
}

.ha-chat-header small {
  align-items: center;
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  font-size: 0.78rem;
  gap: 6px;
  margin-top: 3px;
}

.ha-chat-header small span {
  background: var(--ha-green);
  border-radius: 50%;
  height: 8px;
  width: 8px;
}

.ha-chat-close {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  height: 34px;
  width: 34px;
}

.ha-chat-log {
  align-content: start;
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding: 16px 14px;
  scrollbar-color: rgba(16, 38, 56, 0.45) rgba(16, 38, 56, 0.08);
  scrollbar-width: thin;
}

.ha-chat-log::-webkit-scrollbar {
  width: 10px;
}

.ha-chat-log::-webkit-scrollbar-track {
  background: rgba(16, 38, 56, 0.08);
  border-radius: 999px;
}

.ha-chat-log::-webkit-scrollbar-thumb {
  background: rgba(16, 38, 56, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
}

.ha-chat-message {
  align-items: end;
  display: flex;
  gap: 8px;
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 86%;
}

.ha-chat-message.assistant {
  color: #102638;
  justify-self: start;
  max-width: 92%;
}

.ha-chat-message.user {
  color: #fff;
  justify-self: end;
}

.ha-chat-bubble-text {
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(16, 38, 56, 0.08);
  display: block;
  overflow-wrap: anywhere;
  padding: 11px 13px;
}

.ha-chat-message.assistant .ha-chat-bubble-text {
  background: #eef4f8;
  border: 1px solid rgba(16, 38, 56, 0.08);
  color: #102638;
}

.ha-chat-message.user .ha-chat-bubble-text {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent),
    var(--ha-navy);
  color: #fff;
}

.ha-chat-avatar {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(16, 38, 56, 0.12);
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(16, 38, 56, 0.12);
  color: var(--ha-navy);
  display: inline-flex;
  flex: 0 0 30px;
  font-size: 0.68rem;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  overflow: hidden;
  width: 30px;
}

.ha-chat-avatar img {
  height: 24px;
  object-fit: contain;
  width: 24px;
}

.ha-chat-message.typing {
  color: #5f7080;
  font-style: italic;
}

.ha-chat-progress {
  display: grid;
  gap: 8px;
  min-width: 210px;
}

.ha-chat-progress span {
  color: #102638;
  font-style: normal;
  font-weight: 800;
}

.ha-chat-progress::after {
  background: linear-gradient(90deg, var(--ha-gold), var(--ha-green), var(--ha-navy));
  border-radius: 999px;
  content: "";
  display: block;
  height: 3px;
  transform-origin: left center;
  animation: haChatProgress 1.8s ease-in-out infinite;
}

.ha-chat-progress i {
  background: var(--ha-green);
  border-radius: 50%;
  display: inline-block;
  height: 5px;
  margin-right: 4px;
  opacity: 0.35;
  width: 5px;
  animation: haChatDot 1.2s ease-in-out infinite;
}

.ha-chat-progress i:nth-child(3) {
  animation-delay: 0.15s;
}

.ha-chat-progress i:nth-child(4) {
  animation-delay: 0.3s;
}

.ha-chat-suggestions {
  background: rgba(255, 255, 255, 0.72);
  border-top: 1px solid var(--ha-line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
}

.ha-chat-suggestions button {
  background: #f5f8f6;
  border: 1px solid var(--ha-line);
  border-radius: 999px;
  color: #102638;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 8px 10px;
}

.chat-quote-card {
  background: #fff;
  border: 1px solid rgba(45, 141, 98, 0.24);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(16, 38, 56, 0.12);
  display: grid;
  gap: 12px;
  justify-self: stretch;
  margin: 2px 0 4px 38px;
  padding: 13px;
}

.quote-card-header {
  display: grid;
  gap: 5px;
}

.badge-success {
  align-items: center;
  background: rgba(45, 141, 98, 0.12);
  border: 1px solid rgba(45, 141, 98, 0.22);
  border-radius: 999px;
  color: #1f6f4c;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 900;
  justify-self: start;
  padding: 5px 9px;
}

.badge-success::before {
  content: "✓";
  margin-right: 5px;
}

.quote-price {
  color: var(--ha-navy);
  font-size: 1.65rem;
  line-height: 1;
  margin: 3px 0 0;
}

.quote-summary {
  color: #5f7080;
  font-size: 0.88rem;
  font-weight: 800;
  margin: 0;
}

.quote-card-actions {
  display: grid;
  gap: 8px;
}

.btn-download-pdf,
.btn-view-quote {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.86rem;
  font-weight: 900;
  justify-content: center;
  min-height: 40px;
  text-decoration: none;
}

.btn-download-pdf {
  background: var(--ha-navy);
  color: #fff;
}

.btn-download-pdf::before {
  content: "PDF";
  background: var(--ha-gold);
  border-radius: 5px;
  color: var(--ha-navy);
  font-size: 0.68rem;
  margin-right: 8px;
  padding: 3px 5px;
}

.btn-view-quote {
  background: #f5f8f6;
  border: 1px solid var(--ha-line);
  color: var(--ha-navy);
}

.ha-chat-form {
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid var(--ha-line);
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 44px;
  padding: 12px;
}

.ha-chat-form input {
  border: 1px solid var(--ha-line);
  border-radius: 999px;
  font: inherit;
  min-width: 0;
  padding: 11px 13px;
}

.ha-chat-form input:focus {
  border-color: rgba(246, 190, 26, 0.85);
  box-shadow: 0 0 0 4px rgba(246, 190, 26, 0.16);
  outline: none;
}

.ha-chat-form button {
  background: var(--ha-gold);
  border: 0;
  border-radius: 50%;
  color: var(--ha-navy);
  cursor: pointer;
  font-weight: 900;
}

.ha-chat-form button:disabled,
.ha-chat-form input:disabled {
  cursor: wait;
  opacity: 0.65;
}

@media (max-width: 600px) {
  .ha-chat {
    bottom: 12px;
    right: 12px;
  }

  .ha-chat-panel {
    border-radius: 8px 8px 0 0;
    bottom: -12px;
    height: min(68vh, 560px);
    position: fixed;
    right: 0;
    width: 100vw;
  }

  .ha-chat-help {
    display: none;
  }
}

@keyframes haChatProgress {
  0% {
    transform: scaleX(0.18);
    opacity: 0.65;
  }
  50% {
    transform: scaleX(0.88);
    opacity: 1;
  }
  100% {
    transform: scaleX(0.28);
    opacity: 0.75;
  }
}

@keyframes haChatDot {
  0%, 100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}
