:root {
  --background-light: #e8f6ff;
  --background-dark: #9cd6ff;
  --bg-primary: #e8f6ff;
  --bg-secondary: #d0ecff;
  --bg-card: #f4faff;
  --text-primary: #0d2a3d;
  --text-secondary: #4a7a9b;
  --accent: #1a7abf;
  --accent-hover: #155f96;
  --border: #b8dcf5;
  --border-light: #d4edfc;

  --admin1-bg: #fff8e1;
  --admin1-border: #f5c842;
  --admin1-name: #b8860b;

  --admin2-bg: #e6fff4;
  --admin2-border: #34c47a;
  --admin2-name: #1a7a4a;
}

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

body {
  background: linear-gradient(
    to bottom,
    var(--background-light),
    var(--background-dark)
  );
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  height: 80vh;
  width: 100%;
  max-width: 860px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0px 12px 35px rgba(0, 120, 200, 0.2);
}

/* Header */
.header {
  padding: 14px 24px;
  border-bottom: 2px solid var(--background-dark);
  background: var(--bg-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 50, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 300px;
  box-shadow: 0 8px 32px rgba(0, 80, 140, 0.18);
  transform: translateY(-8px);
  transition: transform 0.2s ease;
}

.modal-overlay.visible .modal {
  transform: translateY(0);
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.modal-input {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 14px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 122, 191, 0.12);
}

.modal-btn {
  padding: 9px 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-btn:hover {
  background: var(--accent-hover);
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--background-dark);
  border-radius: 3px;
}

/* Forum-style message — same for all */
.message {
  display: flex;
  flex-direction: column;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-light);
  animation: fadeIn 0.25s ease-out;
  background: var(--bg-card);
  transition: background 0.15s ease;
}

.message:hover {
  background: #eaf5ff;
}

.message:first-child {
  border-top: none;
}

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

/* Admin message override */
.password-row {
  display: none;
  flex-direction: column;
}

.password-row.visible {
  display: flex;
}

.modal-error {
  font-size: 12px;
  color: #c0392b;
  min-height: 16px;
}

.message.message-admin1 {
  background: var(--admin1-bg);
  border-left: 3px solid var(--admin1-border);
}
.message.message-admin1:hover {
  background: #fff3c4;
}
.message.message-admin1 .message-username {
  color: var(--admin1-name);
}

.message.message-admin2 {
  background: var(--admin2-bg);
  border-left: 3px solid var(--admin2-border);
}
.message.message-admin2:hover {
  background: #d4f7e8;
}
.message.message-admin2 .message-username {
  color: var(--admin2-name);
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.message-username {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-secondary);
}

.message-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Error */
#errorContainer {
  padding: 0 24px;
}

.error {
  padding: 10px 14px;
  background: rgba(220, 60, 60, 0.08);
  border: 1px solid rgba(220, 60, 60, 0.25);
  border-radius: 4px;
  color: #c0392b;
  font-size: 13px;
  margin: 8px 0;
}

/* Input */
.input-section {
  padding: 16px 24px;
  border-top: 2px solid var(--background-dark);
  background: var(--bg-secondary);
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.message-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 14px;
  resize: none;
  height: 42px;
  min-height: 42px;
  max-height: 120px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  line-height: 1.5;
}

.message-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 122, 191, 0.12);
}

.message-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.send-btn {
  height: 42px;
  padding: 0 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
  text-transform: uppercase;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Chat Image */
.chat-image {
  width: 50%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin-top: 5px;
}

/* Mobile */
@media (max-width: 600px) {
  .container {
    max-width: 100%;
    border: none;
  }

  .message {
    padding: 12px 16px;
  }

  .input-section {
    padding: 12px 16px;
  }
}
