/* =========================================
   MotoCoders AI Chatbot — chatbot.css
   Version 1.0.0
   ========================================= */

/* Import fonts */
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* ── CSS Variables ── */
:root {
  --mc-primary:       #F47C20;
  --mc-primary-dark:  #d4630f;
  --mc-primary-light: #FF9A45;
  --mc-primary-glow:  rgba(244, 124, 32, 0.3);
  --mc-dark:          #0a0e14;
  --mc-surface:       #111720;
  --mc-surface2:      #181f2c;
  --mc-border:        rgba(244, 124, 32, 0.18);
  --mc-text:          #e8eaf0;
  --mc-muted:         #6b7280;
  --mc-radius:        18px;
  --mc-side:          right;
}

/* ── Launcher Button ── */
#mc-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mc-primary), var(--mc-primary-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px var(--mc-primary-glow);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease;
  z-index: 999998;
  animation: mc-pulse 3s ease-in-out infinite;
  padding: 0;
}

#mc-chat-launcher.mc-position-left {
  right: auto;
  left: 28px;
}

#mc-chat-launcher:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 8px var(--mc-primary-glow), 0 12px 40px rgba(244,124,32,0.5);
}

@keyframes mc-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--mc-primary-glow), 0 8px 32px rgba(244,124,32,0.35); }
  50%       { box-shadow: 0 0 0 10px rgba(244,124,32,0), 0 8px 32px rgba(244,124,32,0.35); }
}

#mc-chat-launcher .mc-chat-icon  { display: flex; }
#mc-chat-launcher .mc-close-icon { display: none; }
#mc-chat-launcher.mc-open .mc-chat-icon  { display: none; }
#mc-chat-launcher.mc-open .mc-close-icon { display: flex; }

/* Notification dot */
.mc-notif-badge {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2.5px solid #fff;
  font-size: 9px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
  pointer-events: none;
}

/* ── Chat Window ── */
#mc-chat-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 390px;
  height: 580px;
  max-height: calc(100vh - 130px);
  background: var(--mc-surface);
  border-radius: var(--mc-radius);
  border: 1px solid var(--mc-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999997;
  box-shadow:
    0 0 0 1px rgba(244,124,32,0.06),
    0 32px 80px rgba(0,0,0,0.55),
    0 0 80px rgba(244,124,32,0.07);
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1),
              opacity 0.25s ease;
  font-family: 'DM Sans', -apple-system, sans-serif;
}

#mc-chat-window.mc-position-left {
  right: auto;
  left: 28px;
  transform-origin: bottom left;
}

#mc-chat-window.mc-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
.mc-header {
  background: linear-gradient(135deg, #141c28 0%, #1a2236 100%);
  border-bottom: 1px solid var(--mc-border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  flex-shrink: 0;
}

.mc-header::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--mc-primary), transparent);
  opacity: 0.6;
}

.mc-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mc-primary), var(--mc-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -1px;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--mc-primary-glow);
  position: relative;
}

.mc-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--mc-surface);
}

.mc-header-info { flex: 1; min-width: 0; }

.mc-header-name {
  font-family: 'Space Mono', monospace;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--mc-text);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mc-header-status {
  font-size: 11px;
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.mc-status-dot {
  width: 6px; height: 6px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
  animation: mc-blink 2s ease-in-out infinite;
}

@keyframes mc-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

.mc-header-brand {
  font-family: 'Space Mono', monospace;
  font-size: 8.5px;
  color: var(--mc-primary);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.75;
  flex-shrink: 0;
}

/* ── Messages Area ── */
.mc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  min-height: 0;
}

.mc-messages::-webkit-scrollbar { width: 3px; }
.mc-messages::-webkit-scrollbar-track { background: transparent; }
.mc-messages::-webkit-scrollbar-thumb { background: rgba(244,124,32,0.25); border-radius: 2px; }

/* ── Message Bubbles ── */
.mc-msg {
  display: flex;
  gap: 9px;
  animation: mc-msg-in 0.3s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

@keyframes mc-msg-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.mc-msg.mc-user { flex-direction: row-reverse; }

.mc-msg-avatar {
  width: 27px; height: 27px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
  align-self: flex-end;
  margin-bottom: 2px;
}

.mc-msg-avatar.mc-bot {
  background: linear-gradient(135deg, var(--mc-primary), var(--mc-primary-dark));
  color: #fff;
  box-shadow: 0 0 10px var(--mc-primary-glow);
}

.mc-msg-avatar.mc-user-av {
  background: #1a2540;
  color: var(--mc-muted);
  border: 1px solid rgba(255,255,255,0.08);
}

.mc-bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 15px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}

.mc-msg.mc-bot .mc-bubble {
  background: var(--mc-surface);
  color: var(--mc-text);
  border: 1px solid rgba(244,124,32,0.1);
  border-bottom-left-radius: 4px;
}

.mc-msg.mc-user .mc-bubble {
  background: linear-gradient(135deg, #1e3a6e, #1a2f5a);
  color: var(--mc-text);
  border: 1px solid rgba(100,140,255,0.18);
  border-bottom-right-radius: 4px;
}

/* Markdown inside bubbles */
.mc-bubble strong    { color: var(--mc-primary-light); font-weight: 600; }
.mc-bubble em        { font-style: italic; opacity: 0.85; }
.mc-bubble a         { color: var(--mc-primary); text-decoration: none; }
.mc-bubble a:hover   { text-decoration: underline; }
.mc-bubble code      { background: rgba(244,124,32,0.1); border: 1px solid rgba(244,124,32,0.18);
                        border-radius: 4px; padding: 1px 5px; font-size: 11px;
                        font-family: 'Space Mono', monospace; color: var(--mc-primary-light); }
.mc-bubble ul        { padding-left: 18px; margin: 5px 0; }
.mc-bubble ol        { padding-left: 18px; margin: 5px 0; }
.mc-bubble li        { margin: 3px 0; }
.mc-bubble br + br   { display: block; margin: 4px 0; }

/* ── Typing Indicator ── */
.mc-typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}

.mc-typing-dot {
  width: 7px; height: 7px;
  background: var(--mc-primary);
  border-radius: 50%;
  animation: mc-bounce 1.2s ease-in-out infinite;
}
.mc-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.mc-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes mc-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-7px); opacity: 1; }
}

/* ── Quick Replies ── */
.mc-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 0 2px;
  padding-left: 36px;
}

.mc-quick-reply {
  background: transparent;
  border: 1px solid var(--mc-border);
  color: var(--mc-primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mc-quick-reply:hover {
  background: rgba(244,124,32,0.1);
  border-color: var(--mc-primary);
  transform: translateY(-1px);
}

/* ── Input Area ── */
.mc-input-area {
  padding: 12px 14px;
  background: var(--mc-surface2);
  border-top: 1px solid var(--mc-border);
  display: flex;
  align-items: flex-end;
  gap: 9px;
  flex-shrink: 0;
}

#mc-user-input {
  flex: 1;
  background: var(--mc-dark);
  border: 1px solid rgba(244,124,32,0.15);
  border-radius: 12px;
  padding: 9px 13px;
  color: var(--mc-text);
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: 13.5px;
  resize: none;
  min-height: 40px;
  max-height: 110px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

#mc-user-input::placeholder { color: var(--mc-muted); }
#mc-user-input:focus         { border-color: rgba(244,124,32,0.4); }

#mc-send-btn {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--mc-primary), var(--mc-primary-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s;
  box-shadow: 0 4px 14px var(--mc-primary-glow);
}

#mc-send-btn:hover   { transform: scale(1.1); box-shadow: 0 6px 18px rgba(244,124,32,0.5); }
#mc-send-btn:active  { transform: scale(0.94); }
#mc-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Footer ── */
.mc-footer {
  padding: 7px 14px 9px;
  background: var(--mc-surface2);
  text-align: center;
  font-size: 10.5px;
  color: var(--mc-muted);
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.mc-footer a { color: var(--mc-primary); text-decoration: none; opacity: 0.8; }
.mc-footer a:hover { opacity: 1; }

/* ── Mobile ── */
@media (max-width: 480px) {
  #mc-chat-window {
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    transform-origin: bottom center !important;
  }
  #mc-chat-launcher         { bottom: 20px; }
  #mc-chat-launcher         { right: 16px; }
  #mc-chat-launcher.mc-position-left { left: 16px; right: auto; }
}
