/* ─────────────────────────────────────────
   Alex AI Coach — Embedded Chat Widget
   Loaded on every course module page
   ───────────────────────────────────────── */

.alex-chat-wrap {
  background: linear-gradient(135deg, #001a4d 0%, #002868 100%);
  border-radius: 16px;
  overflow: hidden;
  margin: 40px 0;
  box-shadow: 0 8px 40px rgba(0,40,104,.35);
}

/* ── Header ──────────────────────────────── */
.alex-chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.alex-chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #b45309, #d97706);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(180,83,9,.5);
}

.alex-chat-title {
  flex: 1;
}

.alex-chat-title h3 {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  font-family: 'Manrope', sans-serif;
}

.alex-chat-title p {
  margin: 0;
  font-size: 13px;
  color: rgba(255,255,255,.6);
}

.alex-online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,.3);
  flex-shrink: 0;
}

/* ── Message area ─────────────────────────── */
.alex-chat-messages {
  padding: 20px 24px;
  min-height: 260px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.alex-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.alex-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.alex-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.2);
  border-radius: 4px;
}

/* ── Message bubbles ──────────────────────── */
.alex-msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 88%;
}

.alex-msg.alex {
  align-self: flex-start;
}

.alex-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.alex-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
}

.alex-msg.alex .alex-msg-bubble {
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.95);
  border-bottom-left-radius: 4px;
}

.alex-msg.user .alex-msg-bubble {
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.alex-msg-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.alex-msg.alex .alex-msg-icon {
  background: rgba(180,83,9,.4);
}

.alex-msg.user .alex-msg-icon {
  background: rgba(255,255,255,.15);
}

/* ── Typing indicator ─────────────────────── */
.alex-typing {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  align-self: flex-start;
}

.alex-typing-bubble {
  background: rgba(255,255,255,.1);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.alex-typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.6);
  animation: alex-bounce 1.2s infinite ease-in-out;
}

.alex-typing-bubble span:nth-child(2) { animation-delay: .2s; }
.alex-typing-bubble span:nth-child(3) { animation-delay: .4s; }

@keyframes alex-bounce {
  0%, 80%, 100% { transform: scale(.85); opacity: .5; }
  40%           { transform: scale(1.1); opacity: 1; }
}

/* ── Input area ───────────────────────────── */
.alex-chat-input-wrap {
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.alex-chat-input {
  flex: 1;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 12px;
  padding: 11px 16px;
  color: #fff;
  font-size: 14.5px;
  font-family: 'Manrope', sans-serif;
  resize: none;
  outline: none;
  transition: border-color .2s;
  line-height: 1.45;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
}

.alex-chat-input::placeholder {
  color: rgba(255,255,255,.35);
}

.alex-chat-input:focus {
  border-color: rgba(180,83,9,.6);
}

.alex-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, #b45309, #d97706);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .2s, transform .15s;
  color: #fff;
}

.alex-chat-send:hover {
  opacity: .9;
  transform: scale(1.04);
}

.alex-chat-send:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}

.alex-chat-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── Footer hint ──────────────────────────── */
.alex-chat-hint {
  padding: 0 24px 16px;
  font-size: 12px;
  color: rgba(255,255,255,.3);
  text-align: center;
}

/* ── Not-logged-in gate ───────────────────── */
.alex-auth-gate {
  padding: 40px 28px;
  text-align: center;
}

.alex-auth-gate p {
  color: rgba(255,255,255,.75);
  font-size: 15px;
  margin-bottom: 18px;
  line-height: 1.5;
}

.alex-auth-btn {
  display: inline-block;
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: 9px;
  text-decoration: none;
  transition: opacity .2s;
}

.alex-auth-btn:hover {
  opacity: .88;
}

/* ── Cleared / reset button ───────────────── */
.alex-clear-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.3);
  font-size: 12px;
  cursor: pointer;
  padding: 0 4px;
  transition: color .2s;
  white-space: nowrap;
}

.alex-clear-btn:hover {
  color: rgba(255,255,255,.6);
}

/* ── Floating drawer container ───────────── */
/* bottom: 88px — clears the 68px fixed slide-nav bar + breathing room */
#alex-drawer {
  position: fixed;
  bottom: 88px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

/* ── Drawer panel (the chat UI) ──────────── */
.alex-drawer-panel {
  width: 380px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,40,104,.4);
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease;
  pointer-events: all;
}

.alex-drawer-panel.open {
  max-height: 560px;
  opacity: 1;
}

.alex-drawer-panel .alex-chat-wrap {
  margin: 0;
  border-radius: 16px;
}

/* ── Toggle pill button ───────────────────── */
.alex-drawer-toggle {
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Manrope', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(180,83,9,.45);
  transition: transform .2s, box-shadow .2s;
  pointer-events: all;
}

.alex-drawer-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(180,83,9,.55);
}

.alex-drawer-toggle.hidden {
  display: none;
}

/* ── Close button inside panel header ────── */
.alex-drawer-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.45);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color .2s;
  flex-shrink: 0;
}

.alex-drawer-close:hover {
  color: rgba(255,255,255,.9);
}

/* ── Green presence dot ───────────────────── */
.alex-float-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(34,197,94,.3);
  flex-shrink: 0;
}
