:root {
  color-scheme: light;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --bg: #002f67;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #0f172a;
  --muted: #6b7280;
  --border: #e2e8f0;
  --shadow: 0 20px 100px rgba(15, 23, 42, 0.1), 0 10px 40px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Контейнер для центрирования чата */
.page-container {
  width: 100%;
  max-width: 480px;
  height: 90vh; /* Высота чата относительно окна */
  max-height: 1024px; /* ? */
  min-height: 600px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.kaluga {
  width: 100%;
  display: flex;
  justify-content: center;
}

.kaluga-image {
  width: 25%;
}

.page-title {
  background: #fff;
  width: 100%;
  height: 64px;
  display: flex;
  justify-content: space-between;
  border-radius: 32px;
  font-weight: 700;
  text-align: center;
  padding: 6px;
}

.page-title-logo {
  width: 52px;
}

.page-title-title {
  display: flex;
  align-content: center;
  flex-wrap: wrap;
}

/* Чат */
.chat-widget {
  background: var(--card);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  height: 100%;
  overflow: hidden;
  position: relative;
  border: 1px solid #fff;
}

.chat-header {
  padding: 20px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.chat-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.chat-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: #f8fafc;
  /* Тонкий паттерн на фоне */
  background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
  background-size: 24px 24px;
  scroll-behavior: smooth;
}

.chat-messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  animation: fadeIn 0.3s ease;
}

.message-user {
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
  flex-shrink: 0;
}

.message-user .avatar {
  background: var(--text);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.bubble {
  background: #fff;
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
  max-width: 85%;
  line-height: 1.5;
  font-size: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  border: 1px solid rgba(226, 232, 240, 0.6);
}

.message-user .bubble {
  background: var(--primary);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.bubble p { margin: 0; }

.bubble span {
  display: block;
  font-size: 11px;
  margin-top: 6px;
  opacity: 0.6;
  text-align: right;
}

/* Анимация набора текста */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  width: fit-content;
  margin-left: 44px; /* отступ под аватарку */
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 16px;
  background: #fff;
  border-top: 1px solid var(--border);
}

.chat-input input {
  flex: 1;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
}

.chat-input input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-input button {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-input button:hover {
  background: var(--primary-dark);
}
.chat-input button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hidden {
  visibility: hidden;
}

@media (max-width: 600px) {
  .page-container {
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }
  body { padding: 0; }
  .chat-widget { border-radius: 0; border: none; }
}
