/* ============================================================
   ТЕМА: Ретро / Matrix
   Эстетика: CRT-монитор, зелёный фосфор, scanlines
   Шрифты: Share Tech Mono (всё моно, как настоящий терминал)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

:root {
  --bg-base:        #000000;
  --bg-panel:       #020a02;
  --bg-header:      #000000;
  --bg-input:       #001a00;
  --bg-user-msg:    #003300;
  --bg-bot-msg:     #001a00;

  --accent:         #00ff41;
  --accent-glow:    rgba(0, 255, 65, 0.3);
  --accent-dim:     rgba(0, 255, 65, 0.08);
  --accent-mid:     #00cc33;

  --text-primary:   #00ff41;
  --text-secondary: #00aa2a;
  --text-muted:     #004d10;
  --text-user:      #00ff41;

  --border:         rgba(0, 255, 65, 0.12);
  --border-active:  rgba(0, 255, 65, 0.5);

  --status-online:  #00ff41;
  --status-error:   #ff3300;

  --radius-msg:     2px;
  --radius-input:   2px;

  --shadow-panel:   0 0 40px rgba(0,255,65,0.08), 0 0 80px rgba(0,255,65,0.04);
  --shadow-msg:     0 0 8px rgba(0,255,65,0.15);
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  font-family: 'Share Tech Mono', monospace;
  color: var(--text-primary);
  -webkit-font-smoothing: none; /* специально — пиксельный текст */
  cursor: default;
}

/* CRT scanlines эффект поверх всего */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Мерцание экрана — как старый монитор */
@keyframes flicker {
  0%, 98%, 100% { opacity: 1; }
  99% { opacity: 0.97; }
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 780px;
  margin: 0 auto;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  position: relative;
  box-shadow: var(--shadow-panel);
  animation: bootUp 0.6s steps(4) forwards, flicker 8s ease-in-out infinite 1s;
}

/* Загрузка как boot sequence */
@keyframes bootUp {
  0%  { opacity: 0; clip-path: inset(50% 0); }
  50% { opacity: 0.7; clip-path: inset(10% 0); }
  100%{ opacity: 1; clip-path: inset(0); }
}

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

/* Бегущая строка сверху */
.chat-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: scanLine 4s linear infinite;
}

@keyframes scanLine {
  0%   { transform: scaleX(0); transform-origin: left; }
  50%  { transform: scaleX(1); transform-origin: left; }
  51%  { transform: scaleX(1); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

.bot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 2px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow), inset 0 0 12px rgba(0,255,65,0.05);
  animation: avatarGlow 2s ease-in-out infinite;
}

@keyframes avatarGlow {
  0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
  50% { box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(0,255,65,0.1); }
}

.header-info h2 {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
}

/* Эффект печатания для заголовка */
.header-info h2::after {
  content: '_';
  animation: cursor 1s step-end infinite;
}

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

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

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 0; /* квадрат вместо круга */
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pixelBlink 1s step-end infinite;
}

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

#statusText {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
}

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

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

.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 90%;
  animation: msgAppear 0.2s steps(3) forwards;
}

@keyframes msgAppear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.message-avatar {
  width: 30px;
  height: 30px;
  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);
  border-left: 2px solid var(--accent);
}

.user-message { align-self: flex-end; flex-direction: row-reverse; }
.user-message .message-content {
  background: var(--bg-user-msg);
  border: 1px solid var(--border-active);
  border-right: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(0,255,65,0.1);
}

.message-content {
  padding: 10px 14px;
  border-radius: var(--radius-msg);
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  text-shadow: 0 0 6px rgba(0,255,65,0.4);
}

.message-content a {
  color: var(--accent);
  text-decoration: underline;
  text-shadow: 0 0 8px var(--accent);
}

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

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

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 0;
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent);
  animation: matrixBounce 1s step-end 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 matrixBounce {
  0%, 60%, 100% { opacity: 0.2; transform: scaleY(1); }
  30% { opacity: 1; transform: scaleY(1.8); }
}

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

#messageInput {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 10px 14px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.1s, box-shadow 0.1s;
  text-shadow: 0 0 6px rgba(0,255,65,0.5);
}

#messageInput::placeholder { color: var(--text-muted); text-shadow: none; }
#messageInput:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 12px rgba(0,255,65,0.15), inset 0 0 8px rgba(0,255,65,0.04);
}

#sendButton {
  width: 44px;
  height: 44px;
  border-radius: 0;
  border: 1px solid var(--accent);
  cursor: pointer;
  font-size: 18px;
  background: transparent;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 8px rgba(0,255,65,0.2);
  text-shadow: 0 0 8px var(--accent);
}

#sendButton:hover {
  background: var(--accent-dim);
  box-shadow: 0 0 20px rgba(0,255,65,0.4);
}

#sendButton:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  box-shadow: none;
}

@media (max-width: 600px) {
  .chat-container { border: none; }
  .message { max-width: 95%; }
}
