/* Сброс стилей */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Общие стили */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

/* Контейнер чата */
.container {
  max-width: 420px;
  margin: 20px auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 90vh;
  position: relative; /* ← Важно для позиционирования подписки */
}

/* Шапка */
header {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  padding: 15px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

header h1 {
  font-size: 1.8rem;
  margin-bottom: 5px;
}

header p {
  font-size: 0.9rem;
  opacity: 0.9;
}

header p span {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #4caf50;
  border-radius: 50%;
  margin-left: 5px;
}

/* Область сообщений — занимает всё пространство до поля ввода */
.chat-box {
  flex: 1;
  padding: 15px;
  background: #f9f9fb;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-bottom: 80px; /* ← Отступ снизу, чтобы не перекрывалось подпиской и инпутом */
}

/* Сообщения */
.message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message.user {
  background: #4caf50;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.message.bot {
  background: #e3f2fd;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

/* Поле ввода — фиксированное внизу */
.input-area {
  display: flex;
  gap: 10px;
  padding: 15px;
  background: white;
  border-top: 1px solid #eee;
  position: absolute; /* ← Фиксируем внизу */
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  flex-shrink: 0;
}

#userInput {
  flex: 1;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 25px;
  font-size: 1rem;
  outline: none;
}

#userInput:focus {
  border-color: #4caf50;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

button {
  padding: 10px 20px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.3s;
}

button:hover {
  background: #d32f2f;
}

/* Секция подписки — фиксированная над полем ввода */
#subscribeSection {
  padding: 15px;
  text-align: center;
  background: #fff8e1;
  border-top: 1px dashed #ffd54f;
  border-bottom: 1px dashed #ffd54f;
  position: absolute; /* ← Ключевое изменение */
  bottom: 65px; /* ← Выше поля ввода (~65px = высота input-area) */
  left: 0;
  right: 0;
  z-index: 6;
  display: none; /* ← Ты оставляешь как есть */
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#subscribeSection h3 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 8px;
}

#subscribeSection p {
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 12px;
}

#subscribeSection button {
  background: #4caf50;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(76, 175, 80, 0.3);
}

#subscribeSection button:hover {
  background: #388e3c;
}

/* Подвал — фиксированный под полем ввода */
.bottom-links,
footer {
  text-align: center;
  font-size: 0.8rem;
  color: #666;
  padding: 10px;
  background: #f5f5f5;
  border-top: 1px solid #eee;
  position: absolute;
  bottom: -45px; /* ← Под input-area */
  left: 0;
  right: 0;
  z-index: 4;
  margin: 0;
}

.bottom-links a {
  color: #0066cc;
  text-decoration: none;
  margin: 0 8px;
}

.bottom-links a:hover {
  text-decoration: underline;
}

/* Модальное окно */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  text-align: center;
}

.modal-content h3 {
  margin-bottom: 20px;
  color: #333;
}

.modal-content input {
  width: 100%;
  padding: 12px;
  margin: 10px 0;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
}

.modal-content button {
  margin-top: 15px;
  width: 100%;
  padding: 12px;
  font-size: 1.1rem;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.modal-content button:hover {
  background: #d32f2f;
}

.modal-content p {
  margin-top: 15px;
  font-size: 0.9rem;
  color: #555;
}

.modal-content p a {
  color: #0066cc;
  text-decoration: none;
}

.modal-content p a:hover {
  text-decoration: underline;
}