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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f0f;
  color: #e4e4e4;
  height: 100vh;
  overflow: hidden;
}

/* ─── Login ──────────────────────────────────────────── */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #0a0a1a, #1a1a3e);
}

.login-card {
  background: #1e1e2e;
  padding: 40px;
  border-radius: 16px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #0084ff, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo p {
  color: #888;
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1.5px solid #333;
  background: #2a2a3e;
  color: #e4e4e4;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #0084ff;
}

.btn-login {
  width: 100%;
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #0084ff, #a855f7);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s;
}

.btn-login:hover {
  opacity: 0.9;
}

.error-msg {
  color: #ff6b6b;
  font-size: 13px;
  text-align: center;
  margin-top: 14px;
}

/* ─── Chat layout ────────────────────────────────────── */

.chat-layout {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────── */

.sidebar {
  width: 260px;
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #2a2a3e;
}

.sidebar-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid #2a2a3e;
}

.sidebar-header h2 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, #0084ff, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-section-title {
  padding: 16px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #555;
}

#room-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
}

.room-item {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  margin: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  gap: 10px;
  transition: background 0.15s;
}

.room-item:hover {
  background: #2a2a3e;
}

.room-item.active {
  background: rgba(0, 132, 255, 0.15);
}

.room-icon {
  color: #555;
  font-size: 15px;
  width: 18px;
  text-align: center;
}

.room-item.active .room-icon {
  color: #0084ff;
}

.room-name {
  font-size: 14px;
  color: #bbb;
}

.room-item.active .room-name {
  color: #0084ff;
  font-weight: 600;
}

/* Online users */

.online-section {
  border-top: 1px solid #2a2a3e;
}

#online-list {
  list-style: none;
  max-height: 130px;
  overflow-y: auto;
  padding-bottom: 4px;
}

.online-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  font-size: 13px;
  color: #999;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

/* Sidebar footer */

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #2a2a3e;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.current-user {
  font-size: 13px;
  color: #bbb;
}

.btn-logout {
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid #333;
  background: transparent;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-logout:hover {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

/* ─── Chat area ──────────────────────────────────────── */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0f0f1a;
  min-width: 0;
}

.chat-header {
  padding: 15px 24px;
  border-bottom: 1px solid #2a2a3e;
  background: #1a1a2e;
  flex-shrink: 0;
}

.chat-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #e4e4e4;
}

/* Messages */

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 72%;
  animation: fadeUp 0.18s ease;
}

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

.message-mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-theirs {
  align-self: flex-start;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-mine  .bubble-wrap { align-items: flex-end; }
.message-theirs .bubble-wrap { align-items: flex-start; }

.sender-name {
  font-size: 11px;
  color: #555;
  padding: 0 4px;
}

.bubble {
  padding: 9px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
  max-width: 100%;
}

.message-mine .bubble {
  background: #0084ff;
  color: white;
  border-bottom-right-radius: 4px;
}

.message-theirs .bubble {
  background: #2a2a3e;
  color: #e4e4e4;
  border-bottom-left-radius: 4px;
}

.timestamp {
  font-size: 11px;
  color: #444;
  padding: 0 4px;
}

/* Typing indicator */

.typing-area {
  min-height: 22px;
  padding: 2px 24px;
  flex-shrink: 0;
}

#typing-indicator {
  font-size: 12px;
  color: #666;
  font-style: italic;
  display: none;
}

/* Input area */

.input-area {
  padding: 10px 20px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  padding: 11px 18px;
  border-radius: 22px;
  border: 1.5px solid #2a2a3e;
  background: #1e1e2e;
  color: #e4e4e4;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  overflow-y: hidden;
  line-height: 1.4;
  max-height: 120px;
  transition: border-color 0.2s;
}

#message-input:focus {
  border-color: #0084ff;
}

#message-input::placeholder {
  color: #555;
}

#send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0084ff, #a855f7);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.1s;
}

#send-btn:hover  { opacity: 0.9; }
#send-btn:active { transform: scale(0.93); }

/* Scrollbars */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2e2e40; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #3e3e55; }

/* ─── Image upload button ─────────────────────────────── */

#image-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid #2a2a3e;
  background: #1e1e2e;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}

#image-btn:hover {
  border-color: #0084ff;
  color: #0084ff;
}

/* ─── Image messages ──────────────────────────────────── */

.chat-image {
  display: block;
  max-width: 240px;
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: 14px;
  cursor: zoom-in;
  transition: filter 0.15s;
  object-fit: cover;
}

.message-mine .chat-image  { border-bottom-right-radius: 4px; }
.message-theirs .chat-image { border-bottom-left-radius: 4px; }

.chat-image:hover { filter: brightness(0.88); }

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

.btn-img-action,
.btn-img-delete {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  border: 1px solid #2a2a3e;
  background: #1a1a2e;
  color: #888;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}

.btn-img-action:hover {
  color: #0084ff;
  border-color: #0084ff;
}

.btn-img-delete { color: #666; }
.btn-img-delete:hover {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

/* ─── Lightbox ────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden { display: none; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  cursor: pointer;
}

#lightbox-img {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  object-fit: contain;
}

.lightbox-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
}

.lightbox-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(30, 30, 46, 0.92);
  border: 1px solid #3a3a5e;
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.lightbox-btn:hover {
  background: rgba(50, 50, 80, 0.98);
  color: white;
}
