/* ===========================================
   🧩 БАЗОВЫЕ НАСТРОЙКИ
   =========================================== */
:root {
  --btn-bg: #b5f5cc;
  --btn-bg-hover: #94e6b6;
  --btn-bg-disabled: #596959;
  --btn-color: #166b4d;
  --btn-color-hover: #ffffff;
  --btn-color-disabled: #84a996;
  --btn-x: #ff7155;
  --btn-y: #c4f0c5;

  --radius: 8px;
  --shadow-sm: 0 3px 8px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 6px 14px rgb(0 0 0 / 0.12);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  max-width: 800px;
  margin: 20px auto;
  padding: 15px;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
  letter-spacing: 0.02em;
}

/* ===========================================
   🏷️ ТЕКСТ И ЗАГОЛОВКИ
   =========================================== */
h1 {
  font-size: 2.5rem;
  color: #222;
  text-align: center;
  margin-bottom: 30px;
  font-weight: 700;
  transition: color 0.3s ease;
}

/* ===========================================
   🧾 ФОРМЫ
   =========================================== */
form#messageForm {
  background: #fff;
  padding: 30px 25px;
  border-radius: 10px;
  box-shadow: 0 6px 12px rgb(0 0 0 / 0.1);
  margin-bottom: 40px;
}

label {
  display: block;
  font-weight: 600;
  margin: 15px 0 8px;
  color: #444;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 14px 18px;
  margin-bottom: 15px;
  border: 1.8px solid #ddd;
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1.4;
  resize: vertical;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  box-sizing: border-box;
}

input[type="text"]:focus,
textarea:focus {
  border-color: #5b9bd5;
  outline: none;
  box-shadow: 0 0 8px 2px #5b9bd5aa;
}

/* ===========================================
   🎨 КНОПКИ
   =========================================== */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--btn-bg);
  color: var(--btn-color);
  border: none;
  border-radius: var(--radius);
  padding: 14px 30px;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.15s ease;
}

button:hover:not(:disabled) { transform: scale(1.05); }

button:disabled {
  background-color: var(--btn-bg-disabled);
  color: var(--btn-color-disabled);
  cursor: not-allowed;
}

/* Кнопки без фона */
.button-plain,
button.no-bg,
#pollToggleBtn,
.commentsToggleBtn,
.comment button,
#commentsToggle {
  background: none;
  border: none;
  color: var(--btn-color);
  padding: 8px 15px;
  cursor: pointer;
  user-select: none;
  transition: color 0.3s ease, transform 0.15s ease;
}

.button-plain:hover:not(:disabled),
#pollToggleBtn:hover:not(:disabled),
.commentsToggleBtn:hover:not(:disabled),
.comment button:hover:not(:disabled),
#commentsToggle:hover:not(:disabled) {
  transform: scale(1.03);
}

.button-plain:disabled,
#pollToggleBtn:disabled,
.commentsToggleBtn:disabled,
.comment button:disabled,
#commentsToggle:disabled {
  color: var(--btn-color-disabled);
  cursor: not-allowed;
}

/* ===========================================
   💬 СООБЩЕНИЯ И КОММЕНТАРИИ
   =========================================== */
.message,
.comment {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 18px 15px;
  margin-bottom: 20px;
  word-break: break-word;
  transition: box-shadow 0.3s ease;
}

.message:hover,
.comment:hover {
  box-shadow: var(--shadow-lg);
}

/* Вложенные комментарии */
.comment {
  border-left: 3px solid #ccc;
  background-color: #f9f9f9;
  margin: 6px 0 4px;
  padding-left: 12px;
}

.comment .comment {
  margin-left: 8px;
  margin-top: 8px;
  margin-bottom: 4px;
  background-color: #f2f2f2;
  border-left-color: #bbb;
}

.comment .comment .comment {
  margin-left: 8px;
  margin-top: 6px;
  margin-bottom: 3px;
  background-color: #e9e9e9;
  border-left-color: #aaa;
}

/* Метаданные */
.message-time,
.comment-time {
  color: #999;
  font-size: 0.9rem;
  margin-top: 6px;
  font-style: italic;
  user-select: none;
}

/* Кнопка скрытия / открытия ветки */
.toggle-replies-btn {
  font-size: 0.8rem;
  color: #555;
  background: none;
  border: none;
  margin: 4px 0;
  cursor: pointer;
  user-select: none;
}

/* ===========================================
   👍 ЛАЙКИ / ДИЗЛАЙКИ
   =========================================== */
.likesDislikes {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
  user-select: none;
}

.likesDislikes button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  padding: 6px 14px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s ease;
}

.likesDislikes button:hover { transform: scale(1.15); }

.likesDislikes button.liked { color: #3a7d44; font-weight: 700; }
.likesDislikes button.disliked { color: #dc3545; font-weight: 700; }

/* ===========================================
   🗳️ ОПРОСЫ
   =========================================== */
#addPollOptionBtn {
  font-weight: 700;
  font-size: 1.4rem;
  padding: 8px 15px;
  margin: 5px 0 15px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.poll-options button {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: var(--radius);
  margin: 8px 0;
  padding: 12px 15px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s ease, transform 0.15s ease;
}

.poll-options button:hover:not(:disabled) { transform: scale(1.05); }

.pollResults div {
  color: var(--btn-color);
  font-weight: 600;
  padding: 4px 0;
  margin-bottom: 6px;
  border-radius: var(--radius);
  transition: background-color 0.3s ease;
}

.pollBarContainer {
  width: 95%;
  border-radius: 4px;
  overflow: hidden;
  height: 5px;
  margin-top: 4px;
}

.pollBar {
  height: 100%;
  background-color: #c4f0c5;
  width: 0%;
  min-width: 1%;
  transition: width 0.5s ease;
}

/* ===========================================
   🔁 ПАГИНАЦИЯ
   =========================================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin: 30px 0;
}

.pagination button {
  padding: 10px 20px;
  font-size: 1.1rem;
  border-radius: 10px;
}

.pagination span {
  font-weight: 600;
  font-size: 1.2rem;
  user-select: none;
}

#pageIndicator { margin: 0 10px; }

/* ===========================================
   ⚙️ ФУТЕР ФОРМЫ
   =========================================== */
.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.left-controls {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 15px;
}

.left-controls input[type="text"] {
  flex: 1;
  min-width: 250px;
  font-size: 1rem;
  padding: 14px 18px;
}

.right-controls {
  display: flex;
  align-items: center;
}

/* ===========================================
   🌗 ТЕМЫ
   =========================================== */
#themeToggleBtn {
  position: relative;
  background: none;
  border: none;
  font-size: 24px;
  padding: 10px 15px;
  cursor: pointer;
  user-select: none;
  z-index: 1001;
}

.dark-theme body {
  background-color: #121212;
  color: #e0e0e0;

  --btn-bg: #2f5233;
  --btn-bg-hover: #3c8c46;
  --btn-bg-disabled: #445a44;
  --btn-color: #e6f6e6;
  --btn-color-hover: #ffffff;
  --btn-color-disabled: #9bb79b;
  --btn-x: #d86149;
  --btn-y: #4b6f4b;
}

.dark-theme body h1 { color: #ccc; }
.dark-theme body form#messageForm {
  background: #1e1e1e;
  box-shadow: 0 6px 12px rgb(255 255 255 / 0.05);
}
.dark-theme body label { color: #aaa; }
.dark-theme body input[type="text"],
.dark-theme body textarea {
  background-color: #2c2c2c;
  border: 1.8px solid #555;
  color: #ddd;
}
.dark-theme body .message,
.dark-theme body .comment {
  background: #1e1e1e;
  color: #ccc;
  box-shadow: 0 3px 8px rgb(255 255 255 / 0.05);
}
.dark-theme body .comment { background-color: #262626; border-left-color: #444; }
.dark-theme body .comment .comment { background-color: #303030; border-left-color: #555; }
.dark-theme body .comment .comment .comment { background-color: #3a3a3a; border-left-color: #666; }
.dark-theme body .toggle-replies-btn { color: #999; }
.dark-theme body .message-time,
.dark-theme body .comment-time { color: #666; }
.dark-theme body #commentsToggle { color: #52b758; }
.dark-theme body #commentsToggle:hover { color: #3a7d44; }
.dark-theme body #themeToggleBtn { color: #f0f0f0; }

/* ===========================================
   🔔 УВЕДОМЛЕНИЯ
   =========================================== */
#topControls {
  position: fixed;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
}

#notificationsBell {
  position: relative;
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
  outline: none;
  user-select: none;
}

#notificationsBell:hover { transform: scale(1.1); }

#notificationsCount {
  position: absolute;
  top: 4px;
  right: 10px;
  background: var(--btn-x);
  color: white;
  border-radius: 50%;
  padding: 2px 6px;
  font-size: 0.8rem;
  font-weight: bold;
  display: none;
}

/* Контейнер уведомлений */
#notificationsContainer {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 400px;
  max-height: 365px;
  background: transparent;
  border: none;
  border-radius: 6px;
  box-shadow: none;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.15s ease;
  transform-origin: top right;
  z-index: 1000;
}

/* Уведомление */
#notificationsContainer .notification {
  position: relative;
  display: block;
  width: calc(100% - 20px);
  margin: 6px 10px;
  box-sizing: border-box;
  text-align: center;
  padding: 14px 20px;
  border-radius: var(--radius);
  background-color: var(--btn-bg);
  color: var(--btn-color);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 1.1rem;
  transition: background-color 0.25s ease, transform 0.15s ease, color 0.25s ease;
}

#notificationsContainer .notification:hover { font-size: 1.13rem; }

/* Кнопка удаления / универсальная иконка */
.icon-btn,
.close-btn,
#notificationsContainer .notification .remove-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  background-color: var(--btn-x);
  color: white;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.25s ease;
  user-select: none;
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10001;
}

.icon-btn:hover,
.close-btn:hover,
#notificationsContainer .notification .remove-btn:hover { transform: scale(1.1); }

/* Пустое состояние */
#notificationsContainer.empty {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 100px;
  font-weight: 600;
  color: #555;
  text-align: right;
  padding-right: 10px;
}

/* Кнопка очистки */
#notificationsContainer .clear-all-btn {
  position: absolute;
  top: -10px;
  right: 10px;
  background: none;
  color: var(--btn-color);
  border: none;
  font-weight: 600;
  font-size: 1rem;
  padding: 8px 15px;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
  transition: color 0.3s ease, transform 0.15s ease;
}

#notificationsContainer .clear-all-btn:hover { transform: scale(1.03); }
#notificationsContainer .clear-all-btn:disabled {
  color: var(--btn-color-disabled);
  cursor: not-allowed;
}

#notificationsContainer .notifications-list { margin-top: 20px; }

/* Скроллбары */
.notifications-list,
.message-popup-overlay {
  scrollbar-width: auto;
  scrollbar-color: auto;
}

.notifications-list::-webkit-scrollbar,
.message-popup-overlay::-webkit-scrollbar { width: 8px; }

.notifications-list::-webkit-scrollbar-track,
.message-popup-overlay::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }

.notifications-list::-webkit-scrollbar-thumb,
.message-popup-overlay::-webkit-scrollbar-thumb { background-color: #c1c1c1; border-radius: 4px; border: none; }

.notifications-list::-webkit-scrollbar-thumb:hover,
.message-popup-overlay::-webkit-scrollbar-thumb:hover { background-color: #a8a8a8; }

.dark-theme body .notifications-list,
.dark-theme body .message-popup-overlay {
  scrollbar-width: thin;
  scrollbar-color: #555 #1e1e1e;
}

.dark-theme body .notifications-list::-webkit-scrollbar,
.dark-theme body .message-popup-overlay::-webkit-scrollbar { width: 8px; }

.dark-theme body .notifications-list::-webkit-scrollbar-track,
.dark-theme body .message-popup-overlay::-webkit-scrollbar-track { background: #1e1e1e; border-radius: 4px; }

.dark-theme body .notifications-list::-webkit-scrollbar-thumb,
.dark-theme body .message-popup-overlay::-webkit-scrollbar-thumb { background-color: #555; border-radius: 4px; border: none; }

.dark-theme body .notifications-list::-webkit-scrollbar-thumb:hover,
.dark-theme body .message-popup-overlay::-webkit-scrollbar-thumb:hover { background-color: #777; }

.dark-theme body #notificationsContainer .notification {
  background-color: var(--btn-bg);
  color: var(--btn-color);
}

/* ===========================================
   🪟 ВСПЛЫВАЮЩЕЕ ОКНО СООБЩЕНИЯ
   =========================================== */
.message-popup-overlay {
  position: fixed;
  right: 10px;
  bottom: 20px;
  width: 800px;
  max-width: 95%;
  max-height: calc(100vh - 480px);
  background: transparent;
  display: block;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
  overflow-y: auto;
  padding-right: 10px;
  box-sizing: border-box;
}

.message-popup {
  background: none;
  width: min(800px, 100%);
  padding: 0;
  border-radius: 1px;
  z-index: 10000;
}

.message-popup .message {
  margin: 0;
  box-shadow: var(--shadow-lg);
}

/* ===========================================
   🔹 ПРОЧЕЕ
   =========================================== */
.comments-count { color: #007bff; }

.messages-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.search-wrapper {
  display: flex;
  align-items: center;
  position: relative;
}

#searchInput {
  padding: 6px 30px 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s;
  margin-bottom: 0;
}

#searchInput:focus {
  outline: none;
  border-color: #8bc34a;
}

#clearSearchBtn {
  position: absolute;
  right: -17px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: #888;
  display: none;
}

#clearSearchBtn:hover { color: #333; }

#pollCreation { display: none; margin-top: 10px; }

.notification-time {
  font-size: 0.85rem;
  color: #777;
  font-style: italic;
  user-select: none;
}

.dark-theme body .notification-time { color: #ccc; }

/* ===========================================
   ✨ АНИМАЦИИ
   =========================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.comment.highlight-comment {
  background-color: transparent;
  transition: background-color 0.5s ease;
}

.comment.highlight-comment.active {
  background-color: var(--btn-y) !important;
  transition: background-color 0.5s ease;
  position: relative;
  z-index: 2;
}

.highlight-n { color: var(--btn-x); }

.message-text,
.comment-text {
  font-size: 1.2rem;
  line-height: 1.45;
}

.messages-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    /* Даем место для текста */
    padding: 0 12px;
    min-width: 60px;

    height: 36px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 6px;

    background: var(--btn);
    color: rgb(0, 123, 255);
    border: none;
    cursor: pointer;

    white-space: nowrap;
}

.messages-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.subtitle {
  font-size: 1.3rem;
  font-weight: 500;
  color: #444;
  text-align: center;
  margin-top: -10px;
  margin-bottom: 25px;
  letter-spacing: 0.01em;
  opacity: 0.9;
}

/* Тёмная тема */
.dark-theme body .subtitle {
  color: #bbb;
  opacity: 0.95;
}
