/* Vasiley VPN support widget v3.0 */
#vasiley-chat-widget {
  --chat-primary: #1a5f4a;
  --chat-primary-hover: #144a3a;
  --chat-bg: #ffffff;
  --chat-bot-bg: #f0f7f4;
  --chat-user-bg: #1a5f4a;
  --chat-text: #1a1a1a;
  --chat-muted: #666666;
  --chat-border: #e0e8e4;
  --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  --chat-radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  z-index: 99999;
  position: fixed;
  bottom: 24px;
  right: 24px;
  box-sizing: border-box;
}

#vasiley-chat-widget *,
#vasiley-chat-widget *::before,
#vasiley-chat-widget *::after {
  box-sizing: border-box;
}

/* Floating button */
#vasiley-chat-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26, 95, 74, 0.4);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

#vasiley-chat-btn:hover {
  background: var(--chat-primary-hover);
  transform: scale(1.06);
  box-shadow: 0 6px 24px rgba(26, 95, 74, 0.5);
}

#vasiley-chat-btn svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

#vasiley-chat-btn .chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

/* Chat window */
#vasiley-chat-window {
  display: none;
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--chat-border);
}

#vasiley-chat-window.open {
  display: flex;
  animation: chatSlideUp 0.25s ease;
}

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

/* Header */
.chat-header {
  background: var(--chat-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

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

.chat-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.chat-header-info span {
  font-size: 12px;
  opacity: 0.85;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
}

.chat-header-actions button {
  background: transparent;
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: background 0.15s, opacity 0.15s;
}

.chat-header-actions button:hover {
  background: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

.chat-header-actions svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Language switcher */
.chat-lang-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: #f8faf9;
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-lang-bar button {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--chat-muted);
  transition: all 0.15s;
}

.chat-lang-bar button.active {
  background: var(--chat-primary);
  color: #fff;
  border-color: var(--chat-primary);
}

.chat-lang-bar button:hover:not(.active) {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafcfa;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  word-wrap: break-word;
  animation: msgFade 0.2s ease;
}

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

.chat-msg.bot {
  align-self: flex-start;
  background: var(--chat-bot-bg);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--chat-user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

.chat-msg.bot a {
  color: var(--chat-primary);
}

/* Quick replies */
.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 10px;
  flex-shrink: 0;
  background: #fafcfa;
}

.chat-quick button {
  padding: 7px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: var(--chat-text);
  transition: all 0.15s;
  white-space: nowrap;
}

.chat-quick button:hover {
  background: var(--chat-primary);
  color: #fff;
  border-color: var(--chat-primary);
}

/* Input area */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--chat-border);
  background: #fff;
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  background: #f8faf9;
}

.chat-input-area input:focus {
  border-color: var(--chat-primary);
  background: #fff;
}

.chat-input-area button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--chat-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.chat-input-area button:hover {
  background: var(--chat-primary-hover);
}

.chat-input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-input-area svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  background: var(--chat-bot-bg);
  padding: 12px 16px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  background: #88a899;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Mobile adjustments */
@media (max-width: 480px) {
  #vasiley-chat-widget {
    bottom: 16px;
    right: 16px;
  }

  #vasiley-chat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 72px;
    right: 0;
  }

  #vasiley-chat-btn {
    width: 56px;
    height: 56px;
  }
}

/* Hide default mobile call button overlap if needed */
@media (max-width: 768px) {
  #vasiley-chat-widget {
    bottom: max(80px, calc(16px + env(safe-area-inset-bottom)));
  }
}

@media (prefers-reduced-motion: reduce) {
  #vasiley-chat-window.open,
  .chat-msg,
  .chat-typing span {
    animation: none;
  }
}
