/* ==========================================================================
   VICTOR AI AGENT — Vrise SEO Panel Floating AI Guide
   Position: Bottom-Left (Левый нижний угол сайта vrise.ru)
   Aesthetics: Deep Space Cyberpunk / Glassmorphism matching Mike & app.vrise.ru
   ========================================================================== */

#victor-agent-root,
#mark-agent-root {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 10000;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ==================== Launcher Trigger Button ==================== */
.victor-launcher-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#victor-agent-root.is-open .victor-launcher-wrap,
#mark-agent-root.is-open .victor-launcher-wrap {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

.victor-launcher-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.94) 0%, rgba(17, 24, 39, 0.96) 100%);
  border: 1.5px solid rgba(6, 182, 212, 0.55);
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(6, 182, 212, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  color: #ffffff;
  user-select: none;
}

.victor-launcher-btn:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(56, 189, 248, 0.85);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6), 0 0 26px rgba(6, 182, 212, 0.55);
}

.victor-launcher-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #06b6d4;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.6);
  flex-shrink: 0;
  background: #0f172a;
}

.victor-launcher-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.victor-launcher-halo {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(6, 182, 212, 0.4);
  animation: victorHaloPulse 2.4s infinite cubic-bezier(0.4, 0, 0.6, 1);
  pointer-events: none;
}

@keyframes victorHaloPulse {
  0% { transform: scale(0.96); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(0.96); opacity: 0; }
}

.victor-launcher-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.victor-launcher-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.01em;
}

.victor-launcher-role {
  font-size: 0.72rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.victor-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: victorBlink 2s infinite ease-in-out;
}

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

/* Teaser / Greeting speech bubble */
.victor-teaser-bubble {
  position: absolute;
  left: 0;
  bottom: calc(100% + 14px);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96) 0%, rgba(30, 27, 75, 0.95) 100%);
  border: 1px solid rgba(6, 182, 212, 0.5);
  border-radius: 16px;
  padding: 10px 14px 10px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 20px rgba(6, 182, 212, 0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  width: 260px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #e2e8f0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  animation: victorFloatIn 0.4s ease-out;
  transition: all 0.3s ease;
}

.victor-teaser-bubble:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.8);
}

.victor-teaser-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 28px;
  width: 12px;
  height: 12px;
  background: rgba(15, 23, 42, 0.96);
  border-right: 1px solid rgba(6, 182, 212, 0.5);
  border-bottom: 1px solid rgba(6, 182, 212, 0.5);
  transform: rotate(45deg);
}

.victor-teaser-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  line-height: 1;
}
.victor-teaser-close:hover { color: #f8fafc; }

@keyframes victorFloatIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== Main Chat Window ==================== */
.victor-window {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 610px;
  max-height: calc(100vh - 48px);
  background: linear-gradient(165deg, rgba(11, 15, 25, 0.97) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 1.5px solid rgba(99, 102, 241, 0.35);
  border-radius: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 35px rgba(6, 182, 212, 0.22);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.victor-window.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header */
.victor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.4) 100%);
  border-bottom: 1px solid rgba(99, 102, 241, 0.25);
  gap: 10px;
}

.victor-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.victor-header-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e1b4b 0%, #0e1e38 100%);
  border: 1.5px solid rgba(6, 182, 212, 0.55);
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
  overflow: hidden;
  flex-shrink: 0;
}

.victor-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.victor-header-meta {
  display: flex;
  flex-direction: column;
}

.victor-header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.victor-header-badge {
  display: none !important;
}

.victor-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.victor-header-demo-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #06b6d4;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s;
}

.victor-header-demo-link:hover {
  background: rgba(6, 182, 212, 0.22);
  color: #38bdf8;
  border-color: rgba(6, 182, 212, 0.7);
  transform: translateY(-1px);
}

.victor-header-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.victor-header-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Chat Messages Stream */
.victor-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.victor-messages::-webkit-scrollbar {
  width: 6px;
}
.victor-messages::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.3);
}
.victor-messages::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 3px;
}
.victor-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(6, 182, 212, 0.5);
}

/* Message Rows */
.victor-msg-row {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: victorFadeUp 0.25s ease-out;
}

@keyframes victorFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.victor-msg-row.victor {
  align-self: flex-start;
}

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

.victor-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
}

.victor-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.victor-user-avatar {
  background: rgba(51, 65, 85, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.victor-msg-body {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 44px);
}

.victor-msg-row.user .victor-msg-body {
  align-items: flex-end;
}

.victor-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding: 0 4px;
}

.victor-msg-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
}

.victor-msg-row.user .victor-msg-sender {
  color: #a5b4fc;
}

.victor-msg-time {
  font-size: 0.65rem;
  color: #64748b;
}

.victor-msg-bubble {
  border-radius: 16px;
  padding: 12px 15px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #f1f5f9;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  word-break: break-word;
}

.victor-msg-row.victor .victor-msg-bubble {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.94) 0%, rgba(20, 27, 45, 0.92) 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-top-left-radius: 4px;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4), 0 0 1px 1px rgba(99, 102, 241, 0.15);
}

.victor-msg-row.user .victor-msg-bubble {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.92) 0%, rgba(99, 102, 241, 0.88) 100%);
  border: 1px solid rgba(165, 180, 252, 0.35);
  border-top-right-radius: 4px;
  color: #ffffff;
}

/* Markdown formatting inside bubbles */
.victor-msg-bubble p {
  margin: 0 0 8px 0;
}
.victor-msg-bubble p:last-child {
  margin-bottom: 0;
}
.victor-msg-bubble ul, .victor-msg-bubble ol {
  margin: 6px 0 8px 16px;
  padding: 0;
}
.victor-msg-bubble li {
  margin-bottom: 4px;
}
.victor-msg-bubble strong {
  color: #ffffff;
  font-weight: 700;
}
.victor-msg-bubble a {
  color: #38bdf8;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.victor-msg-bubble a:hover {
  color: #7dd3fc;
}

/* CTA Card inside message */
.victor-cta-card {
  margin-top: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12) 0%, rgba(99, 102, 241, 0.14) 100%);
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.victor-cta-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
}
.victor-cta-card-desc {
  font-size: 0.76rem;
  color: #cbd5e1;
  line-height: 1.4;
}
.victor-cta-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
  transition: all 0.2s;
}
.victor-cta-card-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.5);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
}

/* Typing Indicator */
.victor-typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
}
.victor-typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 14px;
}
.victor-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  animation: victorDotBounce 1.4s infinite ease-in-out both;
}
.victor-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.victor-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes victorDotBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.victor-typing-text {
  font-size: 0.74rem;
  color: #94a3b8;
  font-style: italic;
}

/* Quick Suggestion Chips - removed per user request */
.victor-chips-wrap {
  display: none !important;
}
.victor-chips-label {
  display: none !important;
}
.victor-chips-list {
  display: none !important;
}
.victor-chip-btn {
  display: none !important;
}

/* Input Area */
.victor-input-area {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.85);
  border-top: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}

.victor-input {
  flex: 1;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.86rem;
  color: #f8fafc;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.victor-input:focus {
  border-color: rgba(6, 182, 212, 0.6);
  background: rgba(30, 41, 59, 0.85);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
}

.victor-input::placeholder {
  color: #64748b;
  font-size: 0.82rem;
}

.victor-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.victor-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.5);
  border-color: rgba(255, 255, 255, 0.4);
}

.victor-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ==================== Responsive ==================== */
@media (max-width: 640px) {
  #victor-agent-root,
  #mark-agent-root {
    left: 12px;
    bottom: 16px;
    max-width: calc(100vw - 24px);
  }
  .victor-window {
    position: fixed;
    top: auto;
    bottom: 12px;
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
    left: 8px;
    right: 8px;
    width: auto;
    max-width: calc(100vw - 16px);
    height: 84dvh;
    height: 84vh;
    max-height: 84dvh;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.85), 0 0 25px rgba(6, 182, 212, 0.25);
  }
  .victor-header {
    padding: 12px 14px;
    gap: 8px;
    flex-shrink: 0;
  }
  .victor-header-profile {
    gap: 8px;
  }
  .victor-header-avatar {
    width: 36px;
    height: 36px;
  }
  .victor-header-title {
    font-size: 0.9rem;
  }
  .victor-header-demo-link {
    padding: 4px 8px;
    font-size: 0.7rem;
  }
  .victor-header-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    background: rgba(255, 255, 255, 0.08);
  }
  .victor-teaser-bubble {
    width: calc(100vw - 48px);
    max-width: 260px;
  }
  .victor-launcher-info {
    display: none;
  }
  .victor-launcher-btn {
    padding: 6px;
  }
}
