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

:root {
  --bg: #050816;
  --bg-soft: #0b1020;
  --card: rgba(15, 23, 42, 0.82);
  --card-solid: #0f172a;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(96, 165, 250, 0.5);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --blue: #2563eb;
  --blue-light: #60a5fa;
  --blue-dark: #1d4ed8;
  --green: #22c55e;
  --danger: #ef4444;
  --bubble-me: linear-gradient(135deg, #2563eb, #7c3aed);
  --bubble-them: #1e293b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

body {
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.28), transparent 35%),
    radial-gradient(circle at bottom right, rgba(124, 58, 237, 0.22), transparent 35%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: none;
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card h1 {
  font-size: 42px;
  letter-spacing: -1.5px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #93c5fd, #a78bfa, #f8fafc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 26px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 6px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 22px;
}

.tab {
  padding: 12px;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.tab.active {
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  color: white;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.35);
}

form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  outline: none;
  background: rgba(2, 6, 23, 0.65);
  color: var(--text);
  padding: 15px 16px;
  border-radius: 16px;
}

input::placeholder {
  color: var(--muted-2);
}

input:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.12);
}

button {
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  color: white;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.35);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#message {
  min-height: 22px;
  color: #93c5fd;
  margin-top: 16px;
  font-size: 14px;
}

.dashboard {
  width: 100%;
  max-width: 1180px;
  min-height: 720px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.dashboard-header {
  height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 18px;
}

.dashboard-header h2 {
  font-size: 25px;
  letter-spacing: -0.7px;
}

#profileName {
  color: var(--blue-light);
  font-weight: 800;
  margin-top: 4px;
}

#userEmail {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

#logoutBtn {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.25);
  box-shadow: none;
}

.chat-layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
  height: calc(720px - 116px);
}

.users-panel,
.chat-panel {
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
}

.users-panel {
  padding: 18px;
  overflow-y: auto;
}

.users-panel h3 {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  margin-bottom: 12px;
}

.sidebar-title {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.user-item,
.chat-preview {
  padding: 14px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.user-item:hover,
.chat-preview:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(96, 165, 250, 0.35);
  transform: translateY(-1px);
}

.chat-preview.active {
  border-color: var(--border-strong);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.22), rgba(124, 58, 237, 0.18));
}

.chat-preview-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.user-name,
.chat-preview-name {
  color: var(--text);
  font-weight: 800;
}

.user-email,
.chat-preview-message {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.chat-preview-message {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  color: white;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-panel {
  display: flex;
  flex-direction: column;
}

.chat-header {
  min-height: 72px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.chat-header h3,
#selectedUserName {
  font-size: 21px;
  letter-spacing: -0.5px;
}

.messages-list {
  flex: 1;
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.empty-chat {
  color: var(--muted);
  text-align: center;
  margin: auto;
}

.message {
  max-width: min(72%, 560px);
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.45;
  word-break: break-word;
  animation: popIn 0.16s ease;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(5px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.sent {
  align-self: flex-end;
  background: var(--bubble-me);
  color: white;
  border-bottom-right-radius: 5px;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.22);
}

.message.received {
  align-self: flex-start;
  background: var(--bubble-them);
  color: white;
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  font-size: 11px;
  opacity: 0.75;
  margin-top: 6px;
}

.message-time,
.read-status {
  font-size: 11px;
}

.message-form {
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.35);
}

.message-form input {
  flex: 1;
}

.message-form button {
  width: 96px;
}

.hidden {
  display: none !important;
}

@media (max-width: 850px) {
  .page {
    padding: 10px;
  }

  .dashboard {
    min-height: 100vh;
    border-radius: 20px;
    padding: 14px;
  }

  .dashboard-header {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .users-panel {
    max-height: 300px;
  }

  .chat-panel {
    min-height: 560px;
  }

  .message {
    max-width: 86%;
  }
}