/* ============================================================
   Mercurio Sanctus — Widget de chat pro
   Integre aux 4 themes du site itagold.net
   ============================================================ */

/* --- Variables par defaut (theme medieval / dore) --- */
#mercurio-widget {
  --mc-bg: #080c1a;
  --mc-bg-glass: rgba(8,12,26,0.96);
  --mc-bg-header: linear-gradient(135deg, #0e1428 0%, #141c32 100%);
  --mc-bg-input: #0a0e1e;
  --mc-bg-user: rgba(201,168,76,0.08);
  --mc-bg-bot: rgba(20,28,50,0.6);
  --mc-accent: #c9a84c;
  --mc-accent-bright: #e8c96d;
  --mc-accent-dim: rgba(201,168,76,0.3);
  --mc-accent-glow: rgba(201,168,76,0.15);
  --mc-text: #f5f2ea;
  --mc-text-muted: #a8a090;
  --mc-text-dim: #6a6454;
  --mc-border: rgba(201,168,76,0.12);
  --mc-border-hover: rgba(201,168,76,0.3);
  --mc-danger: #c46a5a;
  --mc-font-title: 'Cinzel', serif;
  --mc-font-body: 'Inter', sans-serif;
  --mc-radius: 16px;
  --mc-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 1px rgba(201,168,76,0.1);
}

/* --- Cyber Neon --- */
[data-theme="cyber"] #mercurio-widget {
  --mc-bg: #050510;
  --mc-bg-glass: rgba(5,5,16,0.96);
  --mc-bg-header: linear-gradient(135deg, #0c0c24 0%, #12123a 100%);
  --mc-bg-input: #08081c;
  --mc-bg-user: rgba(0,240,255,0.06);
  --mc-bg-bot: rgba(12,12,36,0.6);
  --mc-accent: #00f0ff;
  --mc-accent-bright: #40ffff;
  --mc-accent-dim: rgba(0,240,255,0.3);
  --mc-accent-glow: rgba(0,240,255,0.12);
  --mc-text: #e0f8ff;
  --mc-text-muted: #608898;
  --mc-text-dim: #304858;
  --mc-border: rgba(0,240,255,0.1);
  --mc-border-hover: rgba(0,240,255,0.3);
  --mc-font-title: 'Orbitron', sans-serif;
  --mc-font-body: 'Rajdhani', sans-serif;
  --mc-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 1px rgba(0,240,255,0.15);
}

/* --- Hacker --- */
[data-theme="hacker"] #mercurio-widget {
  --mc-bg: #000000;
  --mc-bg-glass: rgba(0,0,0,0.96);
  --mc-bg-header: linear-gradient(135deg, #0a100a 0%, #0f180f 100%);
  --mc-bg-input: #050805;
  --mc-bg-user: rgba(0,255,65,0.05);
  --mc-bg-bot: rgba(10,16,10,0.6);
  --mc-accent: #00ff41;
  --mc-accent-bright: #33ff77;
  --mc-accent-dim: rgba(0,255,65,0.3);
  --mc-accent-glow: rgba(0,255,65,0.12);
  --mc-text: #b0ffb0;
  --mc-text-muted: #408040;
  --mc-text-dim: #205020;
  --mc-border: rgba(0,255,65,0.1);
  --mc-border-hover: rgba(0,255,65,0.3);
  --mc-font-title: 'Fira Code', monospace;
  --mc-font-body: 'Share Tech Mono', monospace;
  --mc-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 1px rgba(0,255,65,0.15);
}

/* --- Holographique --- */
[data-theme="holo"] #mercurio-widget {
  --mc-bg: #0a0a14;
  --mc-bg-glass: rgba(10,10,20,0.94);
  --mc-bg-header: linear-gradient(135deg, #14142a 0%, #1c1c3a 100%);
  --mc-bg-input: #0e0e1c;
  --mc-bg-user: rgba(200,160,255,0.06);
  --mc-bg-bot: rgba(20,20,40,0.5);
  --mc-accent: #c8a0ff;
  --mc-accent-bright: #e0c0ff;
  --mc-accent-dim: rgba(200,160,255,0.3);
  --mc-accent-glow: rgba(200,160,255,0.12);
  --mc-text: #f0eeff;
  --mc-text-muted: #7870a0;
  --mc-text-dim: #484060;
  --mc-border: rgba(200,160,255,0.1);
  --mc-border-hover: rgba(200,160,255,0.3);
  --mc-font-title: 'Space Grotesk', sans-serif;
  --mc-font-body: 'DM Sans', sans-serif;
  --mc-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 1px rgba(200,160,255,0.15);
}

/* ============================================================
   Widget container
   ============================================================ */
#mercurio-widget {
  position: fixed;
  bottom: 24px;
  right: 28px;
  z-index: 160;
  font-family: var(--mc-font-body);
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   Fenetre de chat
   ============================================================ */
#mercurio-chat {
  display: none;
  position: absolute;
  bottom: 0;
  right: 0;
  width: 400px;
  height: 540px;
  background: var(--mc-bg-glass);
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  box-shadow: var(--mc-shadow);
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
}
#mercurio-chat.mc-visible {
  display: flex;
  animation: mcOpen 0.28s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes mcOpen {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Header --- */
.mc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--mc-bg-header);
  border-bottom: 1px solid var(--mc-border);
  flex-shrink: 0;
}
.mc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--mc-accent-dim);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 1.5px solid var(--mc-accent-dim);
}
.mc-header-info { flex: 1; min-width: 0; }
.mc-header-name {
  font-family: var(--mc-font-title);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--mc-accent);
  letter-spacing: 0.04em;
  line-height: 1.2;
}
.mc-header-status {
  font-size: 0.68rem;
  color: var(--mc-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.mc-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80;
  animation: mcPulse 2s ease-in-out infinite;
}
@keyframes mcPulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
.mc-header-actions { display: flex; gap: 2px; }
.mc-hdr-btn {
  background: none; border: none;
  color: var(--mc-text-dim);
  width: 30px; height: 30px; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; transition: all 0.2s;
}
.mc-hdr-btn:hover { color: var(--mc-accent); background: var(--mc-accent-glow); }
.mc-switch-btn { width: auto !important; gap: 4px; padding: 2px 8px; font-size: 0.65rem !important; }
.mc-switch-icon { font-size: 0.85rem; }
.mc-switch-label { font-size: 0.6rem; opacity: 0.8; white-space: nowrap; }
/* Mercuria switch block */
.mc-mercuria-switch {
  display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 10px;
}
.mc-sexy-toggle {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,68,102,0.06); border: 1.5px solid rgba(255,68,102,0.2);
  color: #cc6680; padding: 8px 18px; border-radius: 24px;
  font-size: 0.8rem; font-family: var(--mc-font-body); cursor: pointer; transition: all 0.25s;
}
.mc-sexy-toggle span { font-weight: 600; letter-spacing: 0.02em; }
.mc-sexy-toggle:hover { border-color: rgba(255,68,102,0.5); color: #ff4466; background: rgba(255,68,102,0.12); transform: scale(1.04); }
.mc-sexy-toggle.mc-sexy-on { background: rgba(255,68,102,0.2); color: #ff4466; border-color: rgba(255,68,102,0.5); box-shadow: 0 0 16px rgba(255,68,102,0.15); }
.mc-sexy-toggle.mc-sexy-on:hover { background: rgba(255,68,102,0.3); color: #ff6688; }
.mc-mercuria-desc { font-size: 0.62rem; color: #885566; font-style: italic; }

/* Mercuria mode — header rose */
.mc-mercuria .mc-header { background: linear-gradient(135deg, #1a0a14 0%, #2a1020 100%); border-bottom-color: rgba(255,68,102,0.15); }
.mc-mercuria .mc-avatar { background: rgba(255,68,102,0.2); border-color: rgba(255,68,102,0.3); }
.mc-mercuria .mc-header-name { color: #ff6688; }
.mc-mercuria .mc-header-status { color: #cc6680; }
.mc-mercuria .mc-status-dot.mc-status-hot { background: #ff4466; }

/* Voice button */
.mc-voice-btn {
  position: absolute; top: 4px; right: 30px;
  background: rgba(255,68,102,0.1); border: 1px solid rgba(255,68,102,0.2);
  color: #ff6688; width: 22px; height: 22px;
  border-radius: 5px; cursor: pointer; font-size: 0.6rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: all 0.15s;
}
.mc-msg-bubble:hover .mc-voice-btn { opacity: 0.7; }
.mc-voice-btn:hover { opacity: 1 !important; color: #ff4466; border-color: rgba(255,68,102,0.4); background: rgba(255,68,102,0.2); }

/* Lang toggle button */
.mc-lang-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,68,102,0.1); border: 1.5px solid rgba(255,68,102,0.25);
  color: #ff6688; font-size: 0.7rem; font-weight: 800; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.25s; font-family: sans-serif;
}
.mc-lang-btn:hover { background: rgba(255,68,102,0.2); border-color: rgba(255,68,102,0.5); transform: scale(1.06); }

/* Mic button */
.mc-mic-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,68,102,0.1); border: 1.5px solid rgba(255,68,102,0.25);
  color: #ff6688; font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.25s;
}
.mc-mic-btn:hover { background: rgba(255,68,102,0.2); border-color: rgba(255,68,102,0.5); color: #ff4466; transform: scale(1.06); }
.mc-mic-btn.mc-mic-on {
  background: rgba(255,68,102,0.3); border-color: #ff4466; color: #ff4466;
  animation: mcMicPulse 1s ease-in-out infinite;
}
@keyframes mcMicPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,68,102,0.3); } 50% { box-shadow: 0 0 12px 4px rgba(255,68,102,0.2); } }

/* --- Messages --- */
.mc-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 20px;
  scrollbar-width: thin; scrollbar-color: var(--mc-accent-dim) transparent;
}
.mc-messages::-webkit-scrollbar { width: 4px; }
.mc-messages::-webkit-scrollbar-track { background: transparent; }
.mc-messages::-webkit-scrollbar-thumb { background: var(--mc-accent-dim); border-radius: 2px; }

/* Welcome */
.mc-welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  padding: 32px 20px; gap: 12px; flex: 1;
}
.mc-welcome-symbol { font-size: 2.4rem; opacity: 0.7; }
.mc-welcome-symbol img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; object-position: top; }
.mc-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; object-position: top; }
.mc-welcome-title {
  font-family: var(--mc-font-title); font-size: 0.92rem;
  color: var(--mc-accent); letter-spacing: 0.06em;
}
.mc-welcome-text { font-size: 0.78rem; color: var(--mc-text-muted); max-width: 260px; line-height: 1.55; }
.mc-quick-btns { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.mc-quick-btn {
  background: var(--mc-accent-glow); border: 1px solid var(--mc-border);
  color: var(--mc-text-muted); padding: 5px 12px; border-radius: 20px;
  font-size: 0.72rem; font-family: var(--mc-font-body); cursor: pointer; transition: all 0.2s;
}
.mc-quick-btn:hover { border-color: var(--mc-accent-dim); color: var(--mc-accent); background: var(--mc-accent-dim); }

/* Message bubble */
.mc-msg { max-width: 85%; position: relative; display: flex; flex-direction: column; gap: 2px; }
.mc-msg-user { align-self: flex-end; }
.mc-msg-bot { align-self: flex-start; flex-direction: row !important; align-items: flex-start; gap: 8px; }
.mc-msg-bot-avatar { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; flex-shrink: 0; margin-top: 2px; }
.mc-msg-bot-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.mc-msg-bot .mc-msg-inner { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mc-msg-bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 0.82rem;
  line-height: 1.6; word-wrap: break-word; position: relative;
}
.mc-msg-user .mc-msg-bubble {
  background: var(--mc-bg-user); border: 1px solid var(--mc-border);
  color: var(--mc-text); border-bottom-right-radius: 4px;
}
.mc-msg-bot .mc-msg-bubble {
  background: var(--mc-bg-bot); border: 1px solid var(--mc-border);
  color: var(--mc-text); border-bottom-left-radius: 4px;
}
.mc-msg-time { font-size: 0.6rem; color: var(--mc-text-dim); padding: 0 4px; }
.mc-msg-user .mc-msg-time { text-align: right; }

/* Copy button */
.mc-copy-btn {
  position: absolute; top: 4px; right: 4px;
  background: var(--mc-bg); border: 1px solid var(--mc-border);
  color: var(--mc-text-dim); width: 22px; height: 22px;
  border-radius: 5px; cursor: pointer; font-size: 0.6rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: all 0.15s;
}
.mc-msg-bubble:hover .mc-copy-btn { opacity: 0.7; }
.mc-copy-btn:hover { opacity: 1 !important; color: var(--mc-accent); border-color: var(--mc-accent-dim); }

/* Typing */
.mc-typing-wrap {
  align-self: flex-start; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--mc-bg-bot);
  border: 1px solid var(--mc-border); border-radius: 14px; border-bottom-left-radius: 4px;
}
.mc-typing-dots { display: flex; gap: 3px; }
.mc-typing-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--mc-accent-dim); animation: mcBounce 1.4s ease-in-out infinite;
}
.mc-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.mc-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes mcBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%         { transform: translateY(-4px); opacity: 1; }
}
.mc-typing-text { font-size: 0.7rem; color: var(--mc-text-dim); font-style: italic; }

/* --- Input --- */
.mc-input-area {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px; background: var(--mc-bg-input);
  border-top: 1px solid var(--mc-border); flex-shrink: 0;
}
#mercurio-input {
  flex: 1; background: var(--mc-bg-glass); border: 1px solid var(--mc-border);
  border-radius: 12px; padding: 9px 14px; color: var(--mc-text);
  font-family: var(--mc-font-body); font-size: 0.82rem;
  resize: none; min-height: 40px; max-height: 100px;
  outline: none; transition: border-color 0.2s; line-height: 1.45;
}
#mercurio-input:focus { border-color: var(--mc-accent-dim); }
#mercurio-input::placeholder { color: var(--mc-text-dim); }
#mercurio-send {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--mc-accent); border: none; color: var(--mc-bg);
  font-size: 1rem; cursor: pointer; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; transition: all 0.2s;
}
#mercurio-send:hover { filter: brightness(1.15); transform: scale(1.04); }
#mercurio-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
#mercurio-send svg { width: 18px; height: 18px; fill: currentColor; }

/* Markdown */
.mc-msg-bot .mc-msg-bubble strong { color: var(--mc-accent-bright); font-weight: 600; }
.mc-msg-bot .mc-msg-bubble em { font-style: italic; }
.mc-msg-bot .mc-msg-bubble code {
  background: rgba(255,255,255,0.06); padding: 1px 5px;
  border-radius: 4px; font-family: 'Fira Code', monospace; font-size: 0.78em;
}
.mc-msg-bot .mc-msg-bubble pre {
  background: rgba(0,0,0,0.35); border: 1px solid var(--mc-border);
  border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 6px 0; font-size: 0.76em;
}
.mc-msg-bot .mc-msg-bubble pre code { background: none; padding: 0; }
.mc-msg-bot .mc-msg-bubble ul, .mc-msg-bot .mc-msg-bubble ol { margin: 4px 0; padding-left: 18px; }
.mc-msg-bot .mc-msg-bubble li { margin: 2px 0; }

/* Overlay */
.mc-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px); display: flex; align-items: center;
  justify-content: center; z-index: 10; border-radius: var(--mc-radius);
  animation: mcFadeIn 0.15s ease;
}
@keyframes mcFadeIn { from { opacity: 0; } to { opacity: 1; } }
.mc-overlay-box {
  background: var(--mc-bg); border: 1px solid var(--mc-border);
  border-radius: 14px; padding: 20px 24px; text-align: center; max-width: 250px;
}
.mc-overlay-box p { color: var(--mc-text); font-size: 0.82rem; margin-bottom: 14px; line-height: 1.5; }
.mc-overlay-btns { display: flex; gap: 8px; justify-content: center; }
.mc-overlay-btns button {
  padding: 7px 20px; border-radius: 10px; border: 1px solid var(--mc-border);
  cursor: pointer; font-size: 0.76rem; font-family: var(--mc-font-body); transition: all 0.2s;
}
.mc-btn-confirm { background: var(--mc-accent); color: var(--mc-bg); border-color: var(--mc-accent) !important; font-weight: 600; }
.mc-btn-confirm:hover { filter: brightness(1.1); }
.mc-btn-cancel { background: transparent; color: var(--mc-text-muted); }
.mc-btn-cancel:hover { border-color: var(--mc-accent-dim); color: var(--mc-text); }

/* ═══ Chat Tabs (Guilde / IA) ═══ */

/* Image button */
/* Responsive */
@media (max-width: 480px) {
  #mercurio-widget { right: 0; bottom: 0; left: 0; }
  #mercurio-chat { width: 100vw; height: 80vh; right: 0; border-radius: 16px 16px 0 0; }
}
