/* ===== CHIP AI CHAT WIDGET ===== */

.chip-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: #F47B20;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(244, 123, 32, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chip-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(244, 123, 32, 0.55);
}

.chip-launcher svg {
  width: 32px;
  height: 32px;
}

.chip-launcher .chip-close-icon { display: none; }
.chip-launcher.open .chip-open-icon { display: none; }
.chip-launcher.open .chip-close-icon { display: block; }

.chip-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #E53E3E;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

/* ===== CHAT PANEL ===== */

.chip-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-height: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
}

.chip-panel.open {
  display: flex;
  animation: chipSlideUp 0.25s ease-out;
}

@keyframes chipSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Header --- */

.chip-header {
  background: linear-gradient(135deg, #1B3F8F 0%, #15326e 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chip-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #F47B20;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chip-avatar svg {
  width: 24px;
  height: 24px;
}

.chip-header-text {
  flex: 1;
  min-width: 0;
}

.chip-header-name {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.chip-header-status {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75rem;
  margin-top: 2px;
}

.chip-header-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #48BB78;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* --- Messages --- */

.chip-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;
  max-height: 360px;
  background: #F7F8FC;
}

.chip-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chip-msg a {
  color: #1B3F8F;
  font-weight: 600;
  text-decoration: underline;
}

.chip-msg-bot {
  background: #fff;
  color: #2D3748;
  border: 1px solid #E2E8F0;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chip-msg-user {
  background: #1B3F8F;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chip-msg-user a {
  color: #F9D7B0;
}

.chip-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 10px 18px;
  display: none;
  gap: 4px;
  align-items: center;
}

.chip-typing.visible {
  display: flex;
}

.chip-typing span {
  width: 7px;
  height: 7px;
  background: #A0AEC0;
  border-radius: 50%;
  animation: chipDot 1.2s infinite;
}

.chip-typing span:nth-child(2) { animation-delay: 0.2s; }
.chip-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chipDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* --- Quick replies --- */

.chip-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  background: #F7F8FC;
}

.chip-quick-btn {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  color: #1B3F8F;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.chip-quick-btn:hover {
  background: #EBF0FF;
  border-color: #1B3F8F;
}

/* --- Input --- */

.chip-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #E2E8F0;
  background: #fff;
  flex-shrink: 0;
}

.chip-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.88rem;
  font-family: 'Inter', sans-serif;
  color: #2D3748;
  padding: 8px 0;
  background: transparent;
}

.chip-input::placeholder {
  color: #A0AEC0;
}

.chip-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #F47B20;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  padding: 0;
}

.chip-send:hover {
  background: #e06a10;
}

.chip-send:disabled {
  background: #CBD5E0;
  cursor: not-allowed;
}

.chip-send svg {
  width: 16px;
  height: 16px;
}

/* --- Powered by --- */

.chip-powered {
  text-align: center;
  padding: 6px;
  font-size: 0.65rem;
  color: #A0AEC0;
  background: #fff;
  border-top: 1px solid #F0F0F0;
}

/* ===== MOBILE ===== */

@media (max-width: 480px) {
  .chip-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 88px;
    max-height: calc(100vh - 120px);
  }

  .chip-launcher {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }

  .chip-launcher svg {
    width: 28px;
    height: 28px;
  }
}
