/* ═══════════════════════════════════════════════════════════════════════════
   ADWA VPS — SUPPORT CHAT INTERFACE (public/css/chat.css)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Chat Floating Trigger Button ───────────────────────────────────────── */
.chat-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background-color: var(--text-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  z-index: 9990;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-default);
  transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease;
}

.chat-toggle:hover {
  transform: scale(1.06);
}

.chat-toggle.has-unread::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background-color: var(--status-error);
  border-radius: 50%;
  border: 2px solid var(--bg-canvas);
}

/* ─── Chat Drawer Window ─────────────────────────────────────────────────── */
.chat-drawer {
  position: fixed;
  bottom: 5.25rem;
  right: 1.5rem;
  width: min(380px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 7rem));
  background-color: var(--bg-modal);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  z-index: 9991;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: chatSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-drawer.open {
  display: flex;
}

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

/* ─── Chat Header ────────────────────────────────────────────────────────── */
.chat-header {
  padding: 0.85rem 1rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.chat-header-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.chat-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.chat-header-titles {
  min-width: 0;
}

.chat-header-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
  margin-top: 0.15rem;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.chat-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  text-decoration: none;
}

.chat-action-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
}

/* ─── Chat Body ──────────────────────────────────────────────────────────── */
.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-canvas);
}

/* ─── Intro / Pre-Chat Screen ────────────────────────────────────────────── */
.chat-intro {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-intro-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
}

.chat-intro-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.chat-intro-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 1.25rem;
}

.chat-quick-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.chat-topic-btn {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-pill);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chat-topic-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.chat-intro-form {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-intro-tg-note {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
}

.chat-intro-tg-note a {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: underline;
}

/* ─── Messages View Container ────────────────────────────────────────────── */
.chat-messages-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

/* ─── Message Row & Bubble ───────────────────────────────────────────────── */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 84%;
  animation: fadeIn 0.15s ease-out;
}

.chat-msg.admin {
  align-self: flex-start;
}

.chat-msg.user {
  align-self: flex-end;
}

.chat-msg.system {
  align-self: center;
  max-width: 95%;
  text-align: center;
}

.chat-msg-sender {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
  padding: 0 0.15rem;
}

.chat-bubble {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  line-height: 1.45;
  word-break: break-word;
}

.chat-msg.admin .chat-bubble {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 2px;
}

.chat-msg.user .chat-bubble {
  background-color: var(--text-primary);
  color: var(--text-inverse);
  border-bottom-right-radius: 2px;
}

.chat-msg.system .chat-bubble {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.76rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill);
}

.chat-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  padding: 0 0.2rem;
  font-family: var(--font-mono);
}

.chat-msg.user .chat-time {
  text-align: right;
}

/* ─── Telegram Bridge Footer Notice ──────────────────────────────────────── */
.telegram-bridge-banner {
  padding: 0.45rem 0.85rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.73rem;
  color: var(--text-muted);
}

.telegram-bridge-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.telegram-bridge-link:hover {
  text-decoration: underline;
}

/* ─── Input Footer ───────────────────────────────────────────────────────── */
.chat-footer {
  padding: 0.75rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.chat-input:focus {
  border-color: var(--border-focus);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  background-color: var(--text-primary);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  opacity: 0.85;
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

@media (max-width: 480px) {
  .chat-drawer {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
    z-index: 10001;
  }
}