:root {
  --itp-primary: #38bdf8;
  --itp-primary-glow: rgba(56, 189, 248, 0.4);
  --itp-bg-panel: #0d1322;
  --itp-bg-header: #070b14;
  --itp-border: #1e293b;
  --itp-text: #f8fafc;
  --itp-text-muted: #94a3b8;
  --itp-bot-bubble: #172033;
  --itp-user-bubble: #0284c7;
  --itp-online: #10b981;
}

/* Floating Launcher */
.itp-chatbot-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
@media (max-width: 768px) {
  .itp-chatbot-root {
    bottom: 74px; /* Leaves clear margin above sticky mobile utility bars */
    right: 16px;
  }
}

.itp-launcher-btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--itp-primary-glow);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
.itp-launcher-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 28px rgba(56, 189, 248, 0.5);
}
.itp-launcher-btn:focus-visible {
  outline: 2px solid var(--itp-primary);
  outline-offset: 3px;
}
.itp-ping-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--itp-primary);
  animation: itpPing 2.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}
@keyframes itpPing {
  0% { transform: scale(0.95); opacity: 0.8; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.itp-icon-close { display: none; }
.itp-launcher-btn.is-active .itp-icon-msg { display: none; }
.itp-launcher-btn.is-active .itp-icon-close { display: block; }

/* Sliding Chat Panel Container */
.itp-chat-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 375px;
  height: 540px;
  max-height: calc(85vh - 80px);
  background: var(--itp-bg-panel);
  border: 1px solid var(--itp-border);
  border-radius: 18px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.65), 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
@media (max-width: 440px) {
  .itp-chat-panel {
    width: calc(100vw - 32px);
    right: -4px;
    height: 75vh;
  }
}
.itp-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.itp-panel-header {
  background: var(--itp-bg-header);
  border-bottom: 1px solid var(--itp-border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.itp-counselor-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}
.itp-counselor-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1e293b, #334155);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--itp-primary);
  user-select: none;
}
.itp-online-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: var(--itp-online);
  border: 2px solid var(--itp-bg-header);
  border-radius: 50%;
}
.itp-counselor-meta {
  display: flex;
  flex-direction: column;
}
.itp-counselor-name {
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
}
.itp-counselor-sub {
  color: var(--itp-text-muted);
  font-size: 0.72rem;
}
.itp-close-btn {
  background: transparent;
  border: none;
  color: var(--itp-text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.15s ease;
}
.itp-close-btn:hover { color: #fff; }
.itp-close-btn:focus-visible {
  outline: 2px solid var(--itp-primary);
  border-radius: 4px;
}

/* Quick Chips Carousel */
.itp-chips-carousel {
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--itp-border);
  scrollbar-width: none;
}
.itp-chips-carousel::-webkit-scrollbar { display: none; }
.itp-chip {
  background: #141e33;
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #cbd5e1;
  font-size: 0.74rem;
  padding: 5px 12px;
  border-radius: 9999px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.itp-chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--itp-primary);
  color: var(--itp-primary);
}

/* Messages Area - Resilient to Text Cutoffs */
.itp-messages-container {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.3) transparent;
}
.itp-bubble {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap; /* Maintains spacing and never clips multi-line text */
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}
.itp-bot-bubble {
  background: var(--itp-bot-bubble);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--itp-text);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.itp-user-bubble {
  background: var(--itp-user-bubble);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.itp-timestamp {
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 5px;
  text-align: right;
}

/* Typing Indicator Animation */
.itp-typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 6px;
  align-items: center;
}
.itp-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--itp-primary);
  border-radius: 50%;
  animation: itpBounce 1.2s infinite ease-in-out both;
}
.itp-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.itp-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes itpBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Bar */
.itp-chat-input-bar {
  padding: 12px 14px;
  background: var(--itp-bg-header);
  border-top: 1px solid var(--itp-border);
  display: flex;
  gap: 8px;
}
.itp-chat-input-bar input {
  flex: 1;
  background: #111827;
  border: 1px solid var(--itp-border);
  border-radius: 10px;
  color: #fff;
  padding: 10px 14px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.itp-chat-input-bar input:focus {
  border-color: var(--itp-primary);
}
.itp-send-btn {
  background: var(--itp-primary);
  border: none;
  border-radius: 10px;
  color: #070b14;
  padding: 0 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.1s;
}
.itp-send-btn:hover { opacity: 0.9; }
.itp-send-btn:active { transform: scale(0.96); }
.itp-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
