/* ── MediaGear Chatbot — Front-end CSS v1.0.0 ─────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --mgc-blue:      #1877F2;
  --mgc-blue-dark: #0e5fd8;
  --mgc-blue-glow: rgba(24,119,242,0.35);
  --mgc-blue-soft: rgba(24,119,242,0.12);
  --mgc-bg:        #0d0d0d;
  --mgc-surface:   #181818;
  --mgc-border:    #252525;
  --mgc-text:      #e8e8e8;
  --mgc-muted:     #888;
  --mgc-green:     #22c55e;
  --mgc-radius:    20px;
}

#mgc-root * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'DM Sans', sans-serif; }

/* ── Widget wrapper — TEST MODE (vasakul, vähemnähtav) ──────── */
#mgc-widget {
  position: fixed !important;
  bottom: 28px !important;
  left: 28px !important;
  right: auto !important;
  top: auto !important;
  z-index: 2147483647 !important; /* Max possible z-index */
  opacity: 0.45;
  transition: opacity 0.25s;
  pointer-events: auto !important;
  display: block !important;
}
#mgc-widget:hover {
  opacity: 1;
}

/* ── Test mode silt ─────────────────────────────────────────── */
#mgc-widget::after {
  content: 'TEST';
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #888;
  font-family: monospace;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Toggle button ──────────────────────────────────────────── */
#mgc-toggle {
  width: 50px; height: 50px; /* TEST MODE: natuke väiksem */
  border-radius: 50%;
  background: #1a1a1a;
  border: 1.5px solid #444;  /* TEST MODE: hall ääris */
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative; overflow: visible;
}
#mgc-toggle:hover {
  transform: scale(1.07);
  box-shadow: 0 4px 16px rgba(24,119,242,0.3), 0 2px 8px rgba(0,0,0,0.3);
  border-color: var(--mgc-blue);
}
#mgc-toggle svg path, #mgc-toggle svg polyline { stroke: #888; } /* TEST MODE: hall ikoon */
#mgc-toggle:hover svg path,
#mgc-toggle:hover svg polyline { stroke: var(--mgc-blue); }

#mgc-badge {
  position: absolute; top: -3px; right: -3px;
  width: 12px; height: 12px;
  background: #555; /* TEST MODE: hall badge */
  border-radius: 50%; border: 2px solid #fff;
}
@keyframes mgc-pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.18); opacity: 0.8; }
}

/* ── Chat window ────────────────────────────────────────────── */
#mgc-window {
  position: absolute; bottom: 74px; left: 0; right: auto;
  width: 380px; height: 560px;
  background: var(--mgc-bg);
  border-radius: var(--mgc-radius);
  border: 1px solid #222;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7), 0 0 0 1px var(--mgc-blue-soft);
  display: flex; flex-direction: column; overflow: hidden;
  animation: mgc-slideup 0.25s cubic-bezier(0.16,1,0.3,1);
}
@keyframes mgc-slideup {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
#mgc-window.mgc-hidden { display: none; }

/* ── Header ─────────────────────────────────────────────────── */
.mgc-header {
  background: linear-gradient(135deg, #111 0%, #161616 100%);
  border-bottom: 1px solid #1e1e1e;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
}
.mgc-avatar-wrap {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: #ffffff;
  display: flex; align-items: flex-end; justify-content: flex-end;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
  padding: 0;
  position: relative;
}
/* Default MG text avatar when no image uploaded */
.mgc-avatar-wrap .mgc-avatar-initials {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--mgc-blue);
  line-height: 1;
  letter-spacing: -0.5px;
}
.mgc-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.mgc-header-info { flex: 1; min-width: 0; }
.mgc-bot-name {
  font-family: 'Sora', sans-serif; font-size: 14px; font-weight: 600;
  color: #fff; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mgc-status {
  font-size: 12px; color: var(--mgc-green);
  display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
.mgc-status-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--mgc-green);
  animation: mgc-pulse 2s infinite;
}
#mgc-close {
  background: none; border: none; color: #666; cursor: pointer;
  padding: 4px 6px; border-radius: 6px; font-size: 18px; line-height: 1; transition: all 0.15s;
}
#mgc-close:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Messages ───────────────────────────────────────────────── */
#mgc-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: #222 transparent;
}
#mgc-messages::-webkit-scrollbar { width: 4px; }
#mgc-messages::-webkit-scrollbar-thumb { background: #222; border-radius: 4px; }

.mgc-msg {
  max-width: 88%; font-size: 13.5px; line-height: 1.55;
  animation: mgc-fadein 0.2s ease;
}
@keyframes mgc-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mgc-msg.assistant { align-self: flex-start; }
.mgc-msg.user      { align-self: flex-end; }

.mgc-bubble {
  padding: 10px 14px; border-radius: 16px; word-break: break-word;
}
.mgc-msg.assistant .mgc-bubble {
  background: var(--mgc-surface); color: var(--mgc-text);
  border: 1px solid var(--mgc-border); border-bottom-left-radius: 4px;
}
.mgc-msg.user .mgc-bubble {
  background: linear-gradient(135deg, var(--mgc-blue), var(--mgc-blue-dark));
  color: #fff; border-bottom-right-radius: 4px;
}
.mgc-bubble a { color: #60a5fa; }
.mgc-msg.user .mgc-bubble a { color: #bfdbfe; }

/* ── Typing indicator ───────────────────────────────────────── */
#mgc-typing {
  align-self: flex-start;
  display: flex; align-items: center; gap: 5px;
  padding: 10px 14px;
  background: var(--mgc-surface); border: 1px solid var(--mgc-border);
  border-radius: 16px; border-bottom-left-radius: 4px;
  width: fit-content;
}
#mgc-typing.mgc-hidden { display: none; }
.mgc-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--mgc-blue); animation: mgc-bounce 1.2s infinite;
}
.mgc-dot:nth-child(2) { animation-delay: 0.15s; }
.mgc-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes mgc-bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.5; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* ── Suggestions ────────────────────────────────────────────── */
#mgc-suggestions {
  padding: 0 16px 12px;
  display: flex; gap: 7px; flex-wrap: wrap;
}
#mgc-suggestions.mgc-hidden { display: none; }
.mgc-chip {
  background: var(--mgc-surface); border: 1px solid #2a2a2a;
  color: #bbb; font-size: 11.5px; padding: 5px 10px; border-radius: 20px;
  cursor: pointer; transition: all 0.15s; font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.mgc-chip:hover { background: var(--mgc-blue); border-color: var(--mgc-blue); color: #fff; }

/* ── Input area ─────────────────────────────────────────────── */
#mgc-input-area {
  padding: 12px 14px; border-top: 1px solid #1a1a1a;
  background: var(--mgc-bg); display: flex; gap: 10px; align-items: flex-end;
}
#mgc-input {
  flex: 1; background: #161616; border: 1px solid var(--mgc-border);
  border-radius: 12px; color: var(--mgc-text); font-size: 13.5px;
  padding: 10px 14px; outline: none; resize: none;
  font-family: 'DM Sans', sans-serif; line-height: 1.4; max-height: 100px;
  transition: border-color 0.15s;
}
#mgc-input:focus      { border-color: var(--mgc-blue); }
#mgc-input::placeholder { color: #444; }

#mgc-send {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--mgc-blue), var(--mgc-blue-dark));
  border: none; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}
#mgc-send:hover   { opacity: 0.9; transform: scale(1.05); }
#mgc-send:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }

/* ── Footer ─────────────────────────────────────────────────── */
#mgc-footer {
  text-align: center; font-size: 10.5px; color: #333;
  padding: 5px 0 9px; font-family: 'DM Sans', sans-serif;
}
#mgc-footer a { color: var(--mgc-blue); text-decoration: none; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 440px) {
  #mgc-window { width: calc(100vw - 24px); left: -14px; }
  #mgc-widget { bottom: 16px; left: 16px; }
}
