/* === Global font === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

/* === Light theme variables === */
:root {
  --bg: #f4f6f9;
  --text: #333;
  --card-bg: #fff;
  --border: #e0e0e0;

  --bubble-me-bg: #2563eb;
  --bubble-me-text: #fff;
  --bubble-other-bg: #eef2f7;
  --bubble-other-text: #111827;

  --composer-bg: #fff;
  --composer-border: #ddd;
  --emoji-panel-bg: #fff;

  --link: #0077ff;
  --link-hover: #005fcc;
  --success: #28a745;
  --error: #dc3545;
}

/* === Dark theme overrides === */
html.dark-mode {
  --bg: #121212;
  --text: #f0f0f0;
  --card-bg: #1e1e1e;
  --border: #333;

  --bubble-me-bg: #3b82f6;
  --bubble-me-text: #fff;
  --bubble-other-bg: #2c2c2c;
  --bubble-other-text: #f0f0f0;

  --composer-bg: #1e1e1e;
  --composer-border: #444;
  --emoji-panel-bg: #1e1e1e;

  --link: #60a5fa;
  --link-hover: #3b82f6;
}

/* === Base === */
body {
  font-family: 'Inter', sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--text);
}

/* === Wrapper === */
.chat-wrap {
  max-width: 800px;
  margin: 20px auto;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 20px;
}

/* === Navigation === */
.nav {
  margin-bottom: 20px;
  text-align: right;
}

.nav a {
  margin-left: 15px;
  text-decoration: none;
  font-weight: 500;
  color: var(--link);
}

.nav a:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

/* === Chat layout === */
.chat {
  display: flex;
  flex-direction: column;
  height: 70vh;
}

/* === Messages === */
#chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  margin-bottom: 15px;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.45;
  word-wrap: break-word;
}

/* Me (right) */
.msg.me {
  align-self: flex-end;
  background: var(--bubble-me-bg);
  color: var(--bubble-me-text);
  border-bottom-right-radius: 6px;
}

.msg.me .time {
  align-self: flex-end;
}

/* Others (left) */
.msg.other {
  align-self: flex-start;
  background: var(--bubble-other-bg);
  color: var(--bubble-other-text);
  border-bottom-left-radius: 6px;
}

.msg.other .username {
  font-weight: 600;
  margin-bottom: 2px;
}

/* Timestamps */
.msg .time {
  font-size: 0.75rem;
  margin-top: 2px;
  display: block;
}

html:not(.dark-mode) .msg .time {
  color: #555; /* visible in light theme */
}

html.dark-mode .msg .time {
  color: rgba(255,255,255,0.7); /* soft white in dark theme */
}

/* === Composer === */
.composer {
  display: flex;
  gap: 8px;
}

.composer input[type="text"] {
  flex: 1;
  padding: 10px;
  font-size: 0.95rem;
  border: 1px solid var(--composer-border);
  border-radius: 8px;
  background: var(--composer-bg);
  color: var(--text);
}

#emoji-btn, #send-btn {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

#emoji-btn {
  background: #f0f0f0;
}

#emoji-btn:hover {
  background: #e0e0e0;
}

#send-btn {
  background: var(--link);
  color: #fff;
}

#send-btn:hover {
  background: var(--link-hover);
}

/* === Emoji panel === */
#emoji-panel {
  display: none;
  position: absolute;
  bottom: 60px;
  right: 20px;
  background: var(--emoji-panel-bg);
  border: 1px solid var(--composer-border);
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 220px;
  z-index: 1000;
}

#emoji-panel span {
  cursor: pointer;
  font-size: 1.2rem;
}

/* === Forms === */
form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

form input[type="text"],
form input[type="email"],
form input[type="password"] {
  padding: 12px;
  border: 1px solid var(--composer-border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--composer-bg);
  color: var(--text);
}

form button {
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  background: var(--link);
  color: #fff;
  transition: background 0.2s;
}

form button:hover {
  background: var(--link-hover);
}

.chat-wrap h1 {
  text-align: center;
  margin-bottom: 20px;
}

.chat-wrap p {
  text-align: center;
}

.chat-wrap a {
  color: var(--link);
  text-decoration: none;
}

.chat-wrap a:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

.success {
  color: var(--success);
  text-align: center;
  margin-bottom: 15px;
}

.error {
  color: var(--error);
  text-align: center;
  margin-bottom: 15px;
}

/* === Theme toggle switch === */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  margin-right: 10px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0;
  right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 4px; bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--link);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0;
}

/* === Responsive === */
@media (max-width: 600px) {
  .chat-wrap {
    margin: 0;
    border-radius: 0;
    height: 100vh;
    box-shadow: none;
    padding: 30px;
    max-width: 100%;
  }

  .chat {
    height: calc(100vh - 100px);
  }

  #chat-box {
    font-size: 1rem;
  }

  .composer input[type="text"] {
    font-size: 1rem;
  }
}

/* === Chat layout with sidebar === */
.chat-layout {
  display: flex;
  gap: 20px;
}

.chat-section {
  flex: 3;
  display: flex;
  flex-direction: column;
}

.online-panel {
  flex: 1;
  border-left: 1px solid var(--border);
  padding-left: 15px;
}

.online-panel h2 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.online-user {
  margin-bottom: 6px;
  font-weight: 500;
  cursor: pointer;
}

.online-user:hover {
  text-decoration: underline;
}

/* === Context menu === */
.context-menu {
  position: absolute;
  display: none;
  list-style: none;
  margin: 0;
  padding: 5px 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 2000;
  min-width: 180px;
}

.context-menu li {
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text);
}

.context-menu li:hover {
  background: var(--bubble-other-bg);
}

/* === Profile cards === */
.profile-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
  line-height: 1.6;
}

.profile-card p {
  margin: 8px 0;
}

.profile-actions {
  text-align: center;
  margin-top: 20px;
}

.profile-actions .btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--link);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s;
}

.profile-actions .btn:hover {
  background: var(--link-hover);
}

/* === Inbox === */
.inbox-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  padding: 10px;
}

.inbox-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  color: var(--text);
}

.inbox-item:hover {
  background: var(--bubble-other-bg);
}

.inbox-count {
  background: #dc3545; /* red badge */
  color: #fff;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 12px;
}

.nav-inbox {
  position: relative;
}

.nav-inbox .inbox-count {
  margin-left: 6px;
  background: #dc3545;
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 12px;
  vertical-align: middle;
}

/* === Preview bubbles on account page === */
.preview-bubbles {
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-bubbles .msg {
  max-width: 70%;
}

.preview-bubbles .preview-me {
  align-self: flex-end; /* your bubble on right */
}

.preview-bubbles .preview-other {
  align-self: flex-start; /* others on left */
}

/* === User Colour Picker === */
.color-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
  gap: 12px;
  margin: 10px 0 20px;
  max-width: 300px; /* keeps it from stretching too wide */
}

.color-picker input[type="radio"] {
  display: none; /* hide default radio buttons */
}

.color-swatch {
  display: inline-block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #ccc;
  cursor: pointer;
  transition: transform 0.2s, border 0.2s;
}

.color-picker input[type="radio"]:checked + .color-swatch {
  border: 3px solid var(--link); /* highlight chosen colour */
  transform: scale(1.15);
}
