/* Mia Widget — CallPulse AI Business Development Assistant
   Brand blue: #0066FF | Header: #1a1a2e | Distinctive, premium feel
   ----------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --mia-blue: #0066FF;
  --mia-blue-dark: #0052CC;
  --mia-blue-light: #E6F0FF;
  --mia-header-bg: #1a1a2e;
  --mia-header-text: #ffffff;
  --mia-text-primary: #1a1a2e;
  --mia-text-secondary: #6B7280;
  --mia-user-bubble: #0066FF;
  --mia-mia-bubble: #ffffff;
  --mia-border: #E5E7EB;
  --mia-radius-panel: 16px;
  --mia-shadow: 0 8px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  --mia-shadow-fab: 0 4px 20px rgba(0, 102, 255, 0.45), 0 2px 6px rgba(0, 102, 255, 0.25);
  --mia-shadow-toast: 0 4px 24px rgba(0, 0, 0, 0.14);
  --mia-fab-size: 56px;
  --mia-panel-w: 380px;
  --mia-panel-h: 520px;
  --mia-toast-w: 320px;
}

/* ── FAB Button ───────────────────────────────────────────── */
#mia-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: var(--mia-fab-size);
  height: var(--mia-fab-size);
  border-radius: 50%;
  background: var(--mia-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--mia-shadow-fab);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.18s ease,
              background 0.18s ease;
  outline: none;
}

#mia-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 102, 255, 0.55), 0 3px 10px rgba(0, 102, 255, 0.3);
  background: var(--mia-blue-dark);
}

#mia-fab:active {
  transform: scale(0.96);
}

#mia-fab .mia-fab-icon {
  width: 28px;
  height: 28px;
}

/* Pulsing ring when alert badge present */
#mia-fab.has-alert::after {
  content: '';
  position: absolute;
  top: -6px;
  right: -6px;
  width: calc(var(--mia-fab-size) + 12px);
  height: calc(var(--mia-fab-size) + 12px);
  border-radius: 50%;
  border: 2px solid var(--mia-blue);
  animation: mia-pulse-ring 2s ease-out infinite;
  pointer-events: none;
}

@keyframes mia-pulse-ring {
  0%   { transform: scale(0.95); opacity: 0.9; }
  50%  { transform: scale(1.08); opacity: 0.4; }
  100% { transform: scale(1.18); opacity: 0; }
}

/* Alert badge */
#mia-alert-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #FF3B5C;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  align-items: center;
  justify-content: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  line-height: 1;
}

/* ── Chat Panel ──────────────────────────────────────────── */
#mia-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9998;
  width: var(--mia-panel-w);
  height: var(--mia-panel-h);
  background: #fff;
  border-radius: var(--mia-radius-panel);
  box-shadow: var(--mia-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: mia-panel-enter 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#mia-panel.is-open {
  display: flex;
}

@keyframes mia-panel-enter {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── Panel Header ────────────────────────────────────────── */
#mia-panel-header {
  background: var(--mia-header-bg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#mia-panel-header .mia-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--mia-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

#mia-panel-header .mia-avatar svg {
  width: 22px;
  height: 22px;
}

#mia-header-text {
  flex: 1;
  min-width: 0;
}

#mia-header-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--mia-header-text);
  line-height: 1.3;
  margin: 0;
}

#mia-header-sub {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  margin: 2px 0 0;
  line-height: 1.3;
}

#mia-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#mia-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* ── Chat Area ───────────────────────────────────────────── */
#mia-chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Scrollbar */
#mia-chat::-webkit-scrollbar {
  width: 4px;
}
#mia-chat::-webkit-scrollbar-track {
  background: transparent;
}
#mia-chat::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

/* ── Bubbles ─────────────────────────────────────────────── */
.mia-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: mia-bubble-enter 0.22s ease-out forwards;
  opacity: 0;
}

@keyframes mia-bubble-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* User bubble — right */
.mia-bubble-user {
  align-self: flex-end;
  background: var(--mia-user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Mia bubble — left, white card */
.mia-bubble-mia {
  align-self: flex-start;
  background: var(--mia-mia-bubble);
  color: var(--mia-text-primary);
  border: 1px solid var(--mia-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.mia-bubble-mia .mia-bubble-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--mia-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.mia-bubble-mia .mia-bubble-avatar svg {
  width: 14px;
  height: 14px;
}

.mia-bubble-mia .mia-bubble-text {
  flex: 1;
}

/* Mia greeting (first message) */
.mia-bubble-mia.is-greeting {
  background: linear-gradient(135deg, #f0f5ff 0%, #ffffff 100%);
  border-color: var(--mia-blue-light);
}

/* Timestamps */
.mia-timestamp {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  color: var(--mia-text-secondary);
  margin-top: 4px;
  opacity: 0.6;
}

/* ── Typing Indicator ─────────────────────────────────────── */
#mia-typing {
  display: none;
  align-self: flex-start;
  background: var(--mia-mia-bubble);
  border: 1px solid var(--mia-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 10px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

#mia-typing.is-visible {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mia-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mia-text-secondary);
  animation: mia-bounce 1.2s ease-in-out infinite;
}

.mia-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.mia-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes mia-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* ── Input Bar ────────────────────────────────────────────── */
#mia-input-bar {
  border-top: 1px solid var(--mia-border);
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fafbfc;
  flex-shrink: 0;
}

#mia-input {
  flex: 1;
  border: 1.5px solid var(--mia-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  color: var(--mia-text-primary);
  background: #fff;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 42px;
  line-height: 1.5;
  transition: border-color 0.15s;
  field-sizing: content;
}

#mia-input::placeholder {
  color: var(--mia-text-secondary);
}

#mia-input:focus {
  border-color: var(--mia-blue);
}

#mia-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--mia-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
  outline: none;
}

#mia-send-btn:hover {
  background: var(--mia-blue-dark);
}

#mia-send-btn:active {
  transform: scale(0.93);
}

#mia-send-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  transform: none;
}

#mia-send-btn svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

/* ── Toast Notification ──────────────────────────────────── */
#mia-toast {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 9997;
  width: var(--mia-toast-w);
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--mia-shadow-toast);
  padding: 14px 16px;
  cursor: pointer;
  border-left: 4px solid var(--mia-blue);
  display: none;
  animation: mia-toast-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  overflow: hidden;
}

#mia-toast.is-visible {
  display: block;
}

@keyframes mia-toast-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#mia-toast-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--mia-blue);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

#mia-toast-headline {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--mia-text-primary);
  line-height: 1.4;
}

#mia-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--mia-blue);
  width: 100%;
  transform-origin: left;
  animation: mia-toast-shrink 8s linear forwards;
}

@keyframes mia-toast-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Responsive — small screens ─────────────────────────── */
@media (max-width: 480px) {
  :root {
    --mia-panel-w: calc(100vw - 32px);
    --mia-panel-h: 60vh;
  }

  #mia-fab {
    bottom: 16px;
    right: 16px;
  }

  #mia-panel {
    bottom: 84px;
    right: 16px;
    left: 16px;
    width: auto;
  }

  #mia-toast {
    right: 16px;
    left: 16px;
    width: auto;
  }
}