:root {
  --font-family-base: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-accent: #3b82f6;
  --color-accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --color-danger: #ef4444;
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
  --shadow-colored: 0 8px 24px rgba(59, 130, 246, 0.2);
  --radius-md: 14px;
  --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --color-surface: #1e293b;
  --color-border: #475569;
  --color-text: #f1f5f9;
  --color-text-muted: #cbd5e1;
  --color-accent: #60a5fa;
  --color-accent-gradient: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
  --color-danger: #f87171;
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.7);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.8);
  --shadow-colored: 0 8px 24px rgba(96, 165, 250, 0.4);
}

/* ========================================
   ЧАТ — ПЛАВАЮЩАЯ КНОПКА (FAB)
   ======================================== */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-accent-gradient);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-colored);
}
.chat-fab__icon {
  font-size: 24px;
  line-height: 1;
}
.chat-fab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ========================================
   ЧАТ — ПАНЕЛЬ (slide-in как корзина)
   ======================================== */
.chat {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1100;
  pointer-events: none;
  font-family: var(--font-family-base);
  color: var(--color-text);
}
.chat * { box-sizing: border-box; }
.chat[hidden] {
  display: none;
}
.chat:not([hidden]) {
  display: block;
}
.chat--visible {
  pointer-events: auto;
}
.chat__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity var(--transition-base);
}
.chat--visible .chat__backdrop {
  opacity: 1;
}
.chat__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: clamp(300px, 85vw, 420px);
  height: 100%;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-base);
  box-shadow: var(--shadow-xl);
}
.chat--visible .chat__panel {
  transform: translateX(0);
}
.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.chat__header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.chat__social-links {
  display: flex;
  flex-direction: column;
  padding: 12px 20px;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.chat__social-text {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  margin: 0;
  line-height: 1.4;
}
.chat__social-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.chat__social-btn {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 12px;
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  line-height: 1.2;
}
.chat__social-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}
.chat__social-btn:active {
  transform: translateY(0);
}
.chat__social-btn--tg {
  background: #2AABEE;
}
.chat__social-btn--vk {
  background: #0077FF;
}
.chat__close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.chat__close:hover {
  color: var(--color-text);
}
.chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat__empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
  margin: auto;
  padding: 40px 20px;
}
.chat__guest-form {
  padding: 16px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-surface);
}
.chat__guest-text {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 10px;
  text-align: center;
}
.chat__guest-row {
  display: flex;
  gap: 8px;
}
.chat__guest-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-family-base);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition-fast);
}
.chat__guest-input:focus {
  outline: none;
  border-color: var(--color-accent);
}
.chat__guest-btn {
  padding: 10px 20px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
  white-space: nowrap;
}
.chat__guest-btn:hover {
  opacity: 0.9;
}
.chat__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}
#chatInput {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-family-base);
  resize: none;
  max-height: 120px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition-fast);
}
#chatInput:focus {
  outline: none;
  border-color: var(--color-accent);
}
.chat__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-accent-gradient);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}
.chat__send:hover {
  transform: scale(1.08);
}
.chat__msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.chat__msg--user {
  align-self: flex-end;
  background: var(--color-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat__msg--admin {
  align-self: flex-start;
  background: var(--color-border);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}
[data-theme="dark"] .chat__msg--admin {
  background: rgba(255, 255, 255, 0.1);
}
.chat__msg-text {
  white-space: pre-wrap;
}
.chat__msg-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}
.chat__msg-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.chat__msg-btn {
  flex: 1;
  text-align: center;
  padding: 6px 10px;
  border-radius: 8px;
  color: #fff !important;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 500;
  transition: opacity var(--transition-fast);
}
.chat__msg-btn:hover {
  opacity: 0.9;
}
.chat__msg-btn--tg {
  background: #2AABEE;
}
.chat__msg-btn--vk {
  background: #0077FF;
}
.chat__attach {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
  line-height: 1;
}
.chat__attach:hover {
  opacity: 1;
}
.chat__msg-img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  margin-top: 6px;
  cursor: pointer;
  display: block;
}
@media (max-width: 768px) {
  .chat-fab {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
  .chat-fab__icon {
    font-size: 20px;
  }
  .chat__panel {
    width: 100vw;
  }
}
