/* ==========================================================================
   MANDY AI TUTOR — Premium UI & Chat Widget
   ========================================================================== */

/* 1. Dashboard Banner */
.oe-mandy-banner {
  background: linear-gradient(135deg, #0056b3 0%, #0072ce 40%, #0284c7 75%, #06b6d4 100%);
  border-radius: 20px;
  padding: 24px 28px;
  margin: 0 0 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(0, 114, 206, 0.3), 0 8px 10px -6px rgba(0, 114, 206, 0.2);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.oe-mandy-banner::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.oe-mandy-banner-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  min-width: 0;
  z-index: 1;
}

.oe-mandy-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.4) 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.oe-mandy-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #ffffff;
}

.oe-mandy-status-dot {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 15px;
  height: 15px;
  background: #10b981;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.85; }
}

.oe-mandy-banner-info {
  flex: 1;
  min-width: 0;
}

.oe-mandy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.oe-mandy-title {
  margin: 0 0 6px 0;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.25;
  color: #ffffff;
  font-family: 'Montserrat', sans-serif;
  letter-spacing: -0.3px;
}

.oe-mandy-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.92);
  max-width: 580px;
  font-weight: 500;
}

.oe-mandy-banner-right {
  z-index: 1;
  flex-shrink: 0;
}

.oe-mandy-btn-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 30px;
  border: none;
  background: #ffffff;
  color: #0072ce;
  font-size: 0.95rem;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.oe-mandy-btn-cta:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  background: #f8fafc;
  color: #0056b3;
}

/* 2. Floating Pill in Unit Lessons */
.oe-mandy-floating-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #0072ce 0%, #0284c7 100%);
  color: #ffffff;
  padding: 8px 18px 8px 10px;
  border-radius: 40px;
  box-shadow: 0 8px 24px rgba(0, 114, 206, 0.4), 0 2px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  user-select: none;
}

.oe-mandy-floating-btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 30px rgba(0, 114, 206, 0.5);
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}

.oe-mandy-float-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  background: #ffffff;
}

/* 3. Modal / Drawer Chat Window */
.oe-mandy-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.oe-mandy-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.oe-mandy-chat-window {
  width: 420px;
  max-width: 100%;
  height: 640px;
  max-height: calc(100vh - 48px);
  background: var(--oe-card-bg, #ffffff);
  border-radius: 24px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.oe-mandy-modal-overlay.active .oe-mandy-chat-window {
  transform: translateY(0) scale(1);
}

/* Chat Header */
.oe-mandy-chat-header {
  background: linear-gradient(135deg, #0072ce 0%, #0284c7 100%);
  padding: 16px 20px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.oe-mandy-chat-header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.oe-mandy-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.oe-mandy-header-name {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
}

.oe-mandy-header-status {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.oe-mandy-header-status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
}

.oe-mandy-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.oe-mandy-btn-icon {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 0.85rem;
}

.oe-mandy-btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Context Subbar (If in a unit) */
.oe-mandy-unit-subbar {
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 16px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

[data-color-mode="dark"] .oe-mandy-unit-subbar {
  background: #1e293b;
  border-bottom-color: #334155;
  color: #94a3b8;
}

/* Chat Messages Thread */
.oe-mandy-messages-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--oe-body-bg, #f8fafc);
  scroll-behavior: smooth;
}

[data-color-mode="dark"] .oe-mandy-messages-thread {
  background: #0b1120;
}

/* Chat Bubble */
.oe-mandy-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
}

.oe-mandy-msg.assistant {
  align-self: flex-start;
}

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

.oe-mandy-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1.5px solid #0072ce;
  background: #ffffff;
}

.oe-mandy-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

.oe-mandy-msg.assistant .oe-mandy-bubble {
  background: var(--oe-card-bg, #ffffff);
  color: var(--oe-text-main, #0f172a);
  border: 1px solid var(--oe-border, #e2e8f0);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

[data-color-mode="dark"] .oe-mandy-msg.assistant .oe-mandy-bubble {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #334155;
}

.oe-mandy-msg.user .oe-mandy-bubble {
  background: #0072ce;
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 114, 206, 0.25);
}

.oe-mandy-bubble p {
  margin: 0 0 8px 0;
}
.oe-mandy-bubble p:last-child {
  margin-bottom: 0;
}
.oe-mandy-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
}
.oe-mandy-bubble li {
  margin-bottom: 4px;
}
.oe-mandy-bubble strong {
  font-weight: 800;
  color: #0072ce;
}
[data-color-mode="dark"] .oe-mandy-bubble strong {
  color: #38bdf8;
}
.oe-mandy-msg.user .oe-mandy-bubble strong {
  color: #ffffff;
}

/* Audio listen button on assistant bubbles */
.oe-mandy-bubble-tts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  background: rgba(0, 114, 206, 0.08);
  border: 1px solid rgba(0, 114, 206, 0.2);
  color: #0072ce;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.oe-mandy-bubble-tts:hover {
  background: #0072ce;
  color: #ffffff;
}

[data-color-mode="dark"] .oe-mandy-bubble-tts {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
  color: #38bdf8;
}
[data-color-mode="dark"] .oe-mandy-bubble-tts:hover {
  background: #38bdf8;
  color: #0f172a;
}

/* Typing Indicator */
.oe-mandy-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--oe-card-bg, #ffffff);
  border: 1px solid var(--oe-border, #e2e8f0);
  border-radius: 18px;
  border-top-left-radius: 4px;
  width: fit-content;
}
[data-color-mode="dark"] .oe-mandy-typing {
  background: #1e293b;
  border-color: #334155;
}

.oe-mandy-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}
.oe-mandy-dot:nth-child(2) { animation-delay: 0.2s; }
.oe-mandy-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Suggestions Chips - 2x2 responsive action grid */
.oe-mandy-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: var(--oe-card-bg, #ffffff);
  border-top: 1px solid var(--oe-border, #e2e8f0);
  flex-shrink: 0;
  box-sizing: border-box;
}

[data-color-mode="dark"] .oe-mandy-suggestions {
  background: #0f172a;
  border-top-color: #1e293b;
}

.oe-mandy-chip {
  flex: 1 1 calc(50% - 6px);
  min-width: 130px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.73rem;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  box-sizing: border-box;
}

.oe-mandy-chip:hover {
  background: #e0f2fe;
  border-color: #0072ce;
  color: #0072ce;
  transform: translateY(-1px);
}

[data-color-mode="dark"] .oe-mandy-chip {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}
[data-color-mode="dark"] .oe-mandy-chip:hover {
  background: #0369a1;
  border-color: #38bdf8;
  color: #ffffff;
}

/* Chat Input Bar */
.oe-mandy-chat-input-bar {
  padding: 12px 16px;
  background: var(--oe-card-bg, #ffffff);
  border-top: 1px solid var(--oe-border, #e2e8f0);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

[data-color-mode="dark"] .oe-mandy-chat-input-bar {
  background: #0f172a;
  border-top-color: #1e293b;
}

.oe-mandy-input {
  flex: 1;
  border: 1.5px solid var(--oe-border, #cbd5e1);
  background: var(--oe-body-bg, #f8fafc);
  color: var(--oe-text-main, #0f172a);
  border-radius: 16px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  outline: none;
  transition: border-color 0.2s ease;
}

.oe-mandy-input:focus {
  border-color: #0072ce;
  background: #ffffff;
}

[data-color-mode="dark"] .oe-mandy-input {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}
[data-color-mode="dark"] .oe-mandy-input:focus {
  border-color: #38bdf8;
  background: #1e293b;
}

.oe-mandy-btn-mic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

[data-color-mode="dark"] .oe-mandy-btn-mic {
  background: #1e293b;
  color: #94a3b8;
}

.oe-mandy-btn-mic:hover {
  background: #e2e8f0;
  color: #0284c7;
  transform: scale(1.05);
}

.oe-mandy-btn-mic.recording {
  background: #ef4444 !important;
  color: #ffffff !important;
  animation: mandyPulse 1.2s infinite ease-in-out;
}

@keyframes mandyPulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.oe-mandy-btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0072ce;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.oe-mandy-btn-send:hover {
  background: #0284c7;
  transform: scale(1.05);
}

.oe-mandy-btn-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .oe-mandy-banner {
    flex-direction: column;
    padding: 20px;
    text-align: center;
    gap: 16px;
  }
  .oe-mandy-banner-left {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .oe-mandy-desc {
    max-width: 100%;
  }
  .oe-mandy-banner-right {
    width: 100%;
  }
  .oe-mandy-btn-cta {
    width: 100%;
    justify-content: center;
  }
  .oe-mandy-modal-overlay {
    padding: 0;
  }
  .oe-mandy-chat-window {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .oe-mandy-suggestions {
    padding: 6px 10px;
    gap: 4px;
  }
  .oe-mandy-chip {
    flex: 1 1 calc(50% - 4px);
    font-size: 0.69rem;
    padding: 6px 6px;
    border-radius: 10px;
  }
  .oe-mandy-floating-btn {
    bottom: 74px; /* Above bottom navigation bar */
    right: 14px;
    padding: 6px 14px 6px 8px;
    font-size: 0.8rem;
  }
  .oe-mandy-float-avatar {
    width: 32px;
    height: 32px;
  }
}
