/* ============================================================
   CyberAI Course Chatbot — Floating Widget Styles
   Responsive: Desktop + Mobile
   ============================================================ */

/* --- Floating Toggle Button --- */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
  box-shadow: 0 4px 20px rgba(0, 212, 170, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 212, 170, 0.55);
}
.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}
.chatbot-toggle .chatbot-close-icon { display: none; }
.chatbot-toggle.open .chatbot-open-icon { display: none; }
.chatbot-toggle.open .chatbot-close-icon { display: block; }

/* Notification badge on toggle */
.chatbot-toggle .chatbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff4757;
  border: 2px solid #0a0e17;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.chatbot-toggle.open .chatbot-badge { display: none; }

/* --- Chat Window --- */
.chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9998;
  width: 400px;
  max-height: 560px;
  border-radius: 16px;
  background: #0f1724;
  border: 1px solid rgba(0, 212, 170, 0.2);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.chatbot-window.open {
  display: flex;
  animation: chatbot-slide-up 0.25s ease-out;
}
@keyframes chatbot-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Header --- */
.chatbot-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #0f1724 0%, #141d2e 100%);
  border-bottom: 1px solid rgba(0, 212, 170, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.chatbot-header-info {
  flex: 1;
  min-width: 0;
}
.chatbot-header-title {
  font-size: 15px;
  font-weight: 600;
  color: #e8ecf1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chatbot-header-subtitle {
  font-size: 12px;
  color: #7a8ba7;
  margin-top: 1px;
}
.chatbot-remaining {
  font-size: 11px;
  color: #00d4aa;
  background: rgba(0, 212, 170, 0.1);
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.chatbot-remaining.low {
  color: #ffa502;
  background: rgba(255, 165, 2, 0.1);
}
.chatbot-remaining.zero {
  color: #ff4757;
  background: rgba(255, 71, 87, 0.1);
}

/* --- Clear Chat Button --- */
.chatbot-clear-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #7a8ba7;
  cursor: pointer;
  padding: 5px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.chatbot-clear-btn:hover {
  color: #ff4757;
  border-color: rgba(255, 71, 87, 0.3);
  background: rgba(255, 71, 87, 0.08);
}

/* --- Messages Area --- */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 360px;
}
.chatbot-messages::-webkit-scrollbar { width: 5px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

/* Message bubbles */
.chatbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chatbot-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
  color: #0a0e17;
  border-bottom-right-radius: 4px;
}
.chatbot-msg.assistant {
  align-self: flex-start;
  background: #1a2332;
  color: #d1d9e6;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}
.chatbot-msg.assistant a {
  color: #00d4aa;
  text-decoration: underline;
  text-decoration-color: rgba(0, 212, 170, 0.4);
  word-break: break-all;
}
.chatbot-msg.assistant a:hover {
  color: #00f5c4;
  text-decoration-color: #00f5c4;
}
.chatbot-msg.assistant strong {
  color: #e8ecf1;
  font-weight: 600;
}

/* Typing indicator */
.chatbot-typing {
  align-self: flex-start;
  display: none;
  padding: 10px 14px;
  background: #1a2332;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}
.chatbot-typing.active { display: flex; gap: 4px; align-items: center; }
.chatbot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7a8ba7;
  animation: chatbot-dot 1.2s infinite;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatbot-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Welcome message */
.chatbot-welcome {
  text-align: center;
  padding: 20px 10px;
  color: #7a8ba7;
  font-size: 13px;
  line-height: 1.6;
}
.chatbot-welcome strong {
  color: #00d4aa;
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
}
.chatbot-welcome .chatbot-examples {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chatbot-welcome .chatbot-example-btn {
  background: rgba(0, 212, 170, 0.08);
  border: 1px solid rgba(0, 212, 170, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  color: #a0b0c4;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.chatbot-welcome .chatbot-example-btn:hover {
  background: rgba(0, 212, 170, 0.15);
  color: #e8ecf1;
}

/* --- Input Area --- */
.chatbot-input-area {
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: #0f1724;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chatbot-input {
  flex: 1;
  background: #1a2332;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 14px;
  color: #e8ecf1;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  outline: none;
  transition: border-color 0.15s;
}
.chatbot-input::placeholder { color: #4a5a72; }
.chatbot-input:focus { border-color: rgba(0, 212, 170, 0.4); }
.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chatbot-send:disabled { opacity: 0.4; cursor: not-allowed; }
.chatbot-send svg { width: 18px; height: 18px; fill: #0a0e17; }

/* --- Locked State (Not Enrolled) --- */
.chatbot-locked {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}
.chatbot-locked-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.chatbot-locked h3 {
  font-size: 18px;
  font-weight: 600;
  color: #e8ecf1;
  margin: 0 0 8px;
}
.chatbot-locked p {
  font-size: 13px;
  color: #7a8ba7;
  line-height: 1.6;
  margin: 0 0 6px;
}
.chatbot-locked .chatbot-features {
  margin: 16px 0;
  text-align: left;
  width: 100%;
}
.chatbot-locked .chatbot-feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12.5px;
  color: #a0b0c4;
}
.chatbot-locked .chatbot-feature-item span:first-child {
  color: #00d4aa;
  font-size: 14px;
}
.chatbot-enroll-btn {
  margin-top: 16px;
  padding: 12px 28px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
  color: #0a0e17;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.chatbot-enroll-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 212, 170, 0.3);
}

/* --- Rate Limited State --- */
.chatbot-rate-limited {
  text-align: center;
  padding: 12px 16px;
  background: rgba(255, 71, 87, 0.08);
  border-top: 1px solid rgba(255, 71, 87, 0.15);
  color: #ff6b7a;
  font-size: 13px;
  flex-shrink: 0;
}

/* --- Promo Section (for landing pages) --- */
.chatbot-promo {
  background: linear-gradient(135deg, #0f1724 0%, #141d2e 100%);
  border: 1px solid rgba(0, 212, 170, 0.15);
  border-radius: 16px;
  padding: 40px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.chatbot-promo::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(0, 212, 170, 0.04) 0%, transparent 60%);
  pointer-events: none;
}
.chatbot-promo-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(0, 212, 170, 0.1);
  color: #00d4aa;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.chatbot-promo h3 {
  font-size: 24px;
  font-weight: 700;
  color: #e8ecf1;
  margin: 0 0 8px;
}
.chatbot-promo p {
  font-size: 15px;
  color: #7a8ba7;
  line-height: 1.6;
  margin: 0 0 24px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}
.chatbot-promo-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 460px;
  margin: 0 auto 24px;
  text-align: left;
}
.chatbot-promo-feature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #a0b0c4;
}
.chatbot-promo-feature span:first-child { color: #00d4aa; }
.chatbot-promo-demo {
  background: #1a2332;
  border-radius: 12px;
  padding: 16px 20px;
  max-width: 380px;
  margin: 0 auto 20px;
  text-align: left;
}
.chatbot-promo-demo-msg {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 8px;
}
.chatbot-promo-demo-msg.user-demo {
  background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
  color: #0a0e17;
  margin-left: 40px;
  border-bottom-right-radius: 4px;
}
.chatbot-promo-demo-msg.bot-demo {
  background: #0f1724;
  color: #d1d9e6;
  margin-right: 40px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}

/* --- Promo Grid (landing page) --- */
.chatbot-promo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 800px;
  margin: 0 auto;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  .chatbot-toggle {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .chatbot-toggle svg { width: 24px; height: 24px; }

  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
  }
  .chatbot-messages { max-height: calc(100dvh - 200px); }

  .chatbot-promo-features { grid-template-columns: 1fr; }
  .chatbot-promo { padding: 28px 20px; }
  .chatbot-promo h3 { font-size: 20px; }
  .chatbot-promo-grid { grid-template-columns: 1fr; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .chatbot-window {
    width: 360px;
    bottom: 88px;
    right: 16px;
  }
}
