/* ============================================================
   ТЕМА: Светлый минимализм
   Эстетика: editorial, воздушный, как страница книги
   Шрифты: Fraunces (заголовок) + DM Sans (текст)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,300;0,600;1,300&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --bg-base:        #faf9f7;
  --bg-panel:       #ffffff;
  --bg-header:      #faf9f7;
  --bg-input:       #f4f2ee;
  --bg-user-msg:    #2481da;
  --bg-bot-msg:     #f4f2ee;

  --accent:         #c8622a;
  --accent-glow:    rgba(200, 98, 42, 0.15);
  --accent-dim:     rgba(200, 98, 42, 0.08);

  --text-primary:   #1a1a1a;
  --text-secondary: #6b6560;
  --text-muted:     #b5b0aa;
  --text-user:      #faf9f7;

  --border:         rgba(0,0,0,0.07);
  --border-active:  rgba(200, 98, 42, 0.35);

  --status-online:  #4a9e6b;
  --status-error:   #d94f4f;

  --radius-msg:     4px;
  --radius-input:   4px;

  --shadow-panel:   0 1px 0 rgba(0,0,0,0.05), 4px 0 0 rgba(0,0,0,0.02), -4px 0 0 rgba(0,0,0,0.02);
  --shadow-msg:     none;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-base);
  font-family: 'DM Sans', sans-serif;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* Тонкие вертикальные линии — как колонки в журнале */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent calc(100% / 12 - 1px),
    rgba(0,0,0,0.03) calc(100% / 12 - 1px),
    rgba(0,0,0,0.03) calc(100% / 12)
  );
  pointer-events: none;
  z-index: 0;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  position: relative;
  z-index: 1;
  animation: fadeUp 0.4s ease forwards;
}

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

/* ── Шапка ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 32px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.header-info h2 {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-online);
  animation: blink 2.5s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#statusText {
  font-size: 11px;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Сообщения ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.message {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 82%;
  animation: msgIn 0.25s ease forwards;
}

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

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.bot-message { align-self: flex-start; }

.bot-message .message-content {
  background: var(--bg-bot-msg);
  border: 1px solid var(--border);
}

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

.user-message .message-content {
  background: var(--bg-user-msg);
  color: var(--text-user);
}

.message-content {
  padding: 14px 18px;
  border-radius: var(--radius-msg);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.7;
  word-break: break-word;
}

.message-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
  font-weight: 300;
  letter-spacing: 0.5px;
}

/* ── Typing ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bg-bot-msg);
  border: 1px solid var(--border);
  border-radius: var(--radius-msg);
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Ввод ── */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 32px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#messageInput {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--border);
  border-radius: 0;
  padding: 10px 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

#messageInput::placeholder { color: var(--text-muted); }
#messageInput:focus { border-bottom-color: var(--accent); }

#sendButton {
  width: 38px;
  height: 38px;
  border-radius: 2px;
  border: 1.5px solid var(--text-primary);
  cursor: pointer;
  font-size: 16px;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

#sendButton:hover {
  background: var(--text-primary);
  color: var(--bg-panel);
}

#sendButton:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .chat-messages, .chat-input-area { padding-left: 16px; padding-right: 16px; }
  .chat-header { padding: 16px; }
  .message { max-width: 92%; }
}
