/* ── ICOMM Chatbot Widget ── */

#icomm-chat {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  font-family: "Hanken Grotesk", sans-serif;
  font-size: 0.9375rem;
}

/* Bubble toggle button */
#chat-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #1452a3;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(20, 82, 163, 0.4);
  transition: background 0.2s, transform 0.15s;
  margin-left: auto;
}

#chat-bubble:hover {
  background: #0e3d7a;
  transform: scale(1.06);
}

#chat-bubble:focus-visible {
  outline: 3px solid #1452a3;
  outline-offset: 3px;
}

/* Panel */
#chat-panel[hidden] { display: none; }
#chat-panel {
  display: flex;
  flex-direction: column;
  width: 360px;
  height: 480px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  margin-bottom: 0.75rem;
  animation: chat-slide-up 0.22s ease;
}

@keyframes chat-slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: #1452a3;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}

#chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 4px;
  opacity: 0.85;
  transition: opacity 0.15s;
}

#chat-close:hover {
  opacity: 1;
}

#chat-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
}

/* Messages area */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  background: #f9f8f5;
  scroll-behavior: smooth;
}

.chat-msg {
  max-width: 82%;
  padding: 0.625rem 0.875rem;
  border-radius: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg--user {
  align-self: flex-end;
  background: #1452a3;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg--assistant {
  align-self: flex-start;
  background: #fff;
  color: #1a1a2e;
  border: 1px solid #e5e0d4;
  border-bottom-left-radius: 4px;
}

.chat-msg--assistant a {
  color: #1452a3;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-msg--assistant a:hover {
  color: #0e3d7a;
}

/* Input form */
#chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #e5e0d4;
  background: #fff;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  border: 1px solid #d0cbc0;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: #f9f8f5;
  color: #1a1a2e;
  outline: none;
  transition: border-color 0.15s;
}

#chat-input:focus {
  border-color: #1452a3;
  background: #fff;
}

#chat-input:disabled {
  opacity: 0.6;
}

#chat-form button[type="submit"] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: #1452a3;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

#chat-form button[type="submit"]:hover {
  background: #0e3d7a;
}

#chat-form button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chat-form button[type="submit"]:focus-visible {
  outline: 3px solid #1452a3;
  outline-offset: 2px;
}

/* Mobile */
@media (max-width: 480px) {
  #icomm-chat {
    bottom: 1rem;
    right: 1rem;
  }

  #chat-panel {
    width: calc(100vw - 2rem);
    height: calc(100svh - 5.5rem);
    border-radius: 14px;
  }
}
