/* ═══════════════════════════════════════════════════════════════
   Chat Support Widget — MC Виан B2B Portal
   ═══════════════════════════════════════════════════════════════ */

/* ── Floating Button ─────────────────────────────────────── */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 126, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 126, 255, 0.5);
}
.chat-fab.is-open .chat-fab__icon-open { display: none; }
.chat-fab.is-open .chat-fab__icon-close { display: flex; }
.chat-fab__icon-close { display: none; }

/* ── Chat Panel ──────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9998;
  width: 380px;
  max-height: calc(100vh - 140px);
  background: var(--color-surface);
  border-radius: var(--radius-xl, 16px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border-light);
}
.chat-panel.is-open {
  display: flex;
  animation: chatSlideUp 0.25s ease forwards;
}

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ──────────────────────────────────────────────── */
.chat-panel__header {
  padding: 16px 20px;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-panel__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.chat-panel__title {
  font-weight: 600;
  font-size: 1rem;
}
.chat-panel__subtitle {
  font-size: 0.8125rem;
  opacity: 0.85;
}

/* ── Body ────────────────────────────────────────────────── */
.chat-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;
  max-height: 400px;
  background: var(--color-bg);
}

/* ── Messages ────────────────────────────────────────────── */
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  animation: chatFadeIn 0.2s ease;
}
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-bottom-left-radius: 4px;
  color: var(--color-text);
}
.chat-msg--user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── FAQ Buttons ─────────────────────────────────────────── */
.chat-faq {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-faq__btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.4;
}
.chat-faq__btn:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ── Operator ────────────────────────────────────────────── */
.chat-operator-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--color-success);
  background: #e6f9ed;
  color: var(--color-success);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 4px;
}
.chat-operator-btn:hover {
  background: var(--color-success);
  color: #fff;
}

/* ── Footer Input ────────────────────────────────────────── */
.chat-panel__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-light);
  background: var(--color-surface);
  display: none;
}
.chat-panel__footer.is-visible {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-panel__input {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.875rem;
  outline: none;
  background: var(--color-bg);
  transition: border-color 0.2s;
}
.chat-panel__input:focus {
  border-color: var(--color-primary);
}
.chat-panel__send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
  flex-shrink: 0;
}
.chat-panel__send:hover {
  background: var(--color-primary-dark);
}

/* ── Typing Indicator ────────────────────────────────────── */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: chatBounce 1.2s ease infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Back to menu ────────────────────────────────────────── */
.chat-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  align-self: flex-start;
}
.chat-back-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── History & Full-page links ──────────────────────────── */
.chat-history-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md, 8px);
  border: 1px dashed var(--color-border-light, #e0e0e0);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
  margin-top: 4px;
}
.chat-history-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chat-open-full {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: var(--radius-md, 8px);
  background: var(--color-primary-light, #e8f0fe);
  transition: background 0.2s;
}
.chat-open-full:hover {
  background: #d0e3ff;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-panel {
    right: 8px;
    left: 8px;
    bottom: 80px;
    width: auto;
  }
  .chat-fab {
    bottom: 16px;
    right: 16px;
  }
}
