/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background: #f5f6fa;
  color: #333;
}

/* Navigation */
.nav {
  background: white;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-weight: 600;
  font-size: 20px;
  color: #4f46e5;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Logo */
.brand-logo {
  height: 32px;
  width: 32px;
  object-fit: contain;
}

.tab-button {
  background: none;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  color: #4b5563;
  font-size: 15px;
  border-radius: 6px;
  transition: background 0.2s;
}

.tab-button:hover,
.tab-button.active {
  background: #eef2ff;
  color: #3730a3;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.logout-link {
  color: #ef4444;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background 0.2s;
}

.logout-link:hover {
  background: #ffe4e6;
}

/* General buttons */
.primary-btn {
  background: #6366f1;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: #4f46e5;
}

/* Disabled state for buttons */
.disabled-btn {
  opacity: 0.6;
  cursor: not-allowed;
}

.secondary-btn {
  background: #e5e7eb;
  color: #111827;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.secondary-btn:hover {
  background: #d1d5db;
}

/* Top bar and filters */
.top-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 12px;
}

/* Home layout: feed + right sidebar (like the reference UI) */
.home-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: start;
}
.home-sidebar {
  position: sticky;
  top: 84px;
}
.sidebar-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.sidebar-card h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}
.sidebar-card ul {
  margin: 10px 0 0 18px;
}
.sidebar-note {
  margin-top: 10px;
  font-size: 12px;
  color: #6b7280;
}
.sidebar-card--safety {
  border: 2px solid #f59e0b;
}
.link-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.link-list a {
  color: #4f46e5;
  text-decoration: none;
}
.link-list a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .home-grid {
    grid-template-columns: 1fr;
  }
  .home-sidebar {
    position: static;
    top: auto;
  }
}

.top-bar input,
.top-bar select {
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 16px 12px;
}

.tag-filter {
  padding: 6px 12px;
  border-radius: 999px;
  background: #e5e7eb;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  transition: background 0.2s;
}

.tag-filter:hover,
.tag-filter.active {
  background: #6366f1;
  color: white;
}

/* Posts */
.posts-container {
  padding: 0 12px 24px 12px;
}

.post-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

/* Resources section on the home page */
.resources-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin: 12px;
}
.resources-card h3 {
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}
.resources-card p {
  margin-bottom: 8px;
}
.resources-card ul {
  list-style: disc;
  padding-left: 20px;
  margin-bottom: 8px;
}
.resources-card li {
  margin-bottom: 4px;
  font-size: 14px;
}
.resources-card a {
  color: #4f46e5;
  text-decoration: none;
}
.resources-card a:hover {
  text-decoration: underline;
}

/* Avatar styling */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  margin-right: 8px;
  position: relative;
}

/* Base logo inside avatar */
.avatar-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Overlay to tint ONLY the blue ring/brain via blend mode */
.avatar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* Post info wrapper (username + tag) */
.post-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Post meta row (location and time) */
.post-meta {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* Top comments preview */
.top-comments {
  border-top: 1px solid #e5e7eb;
  margin-top: 8px;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.comment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  background: #f9fafb;
  padding: 6px 8px;
  border-radius: 6px;
}
.comment-preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.comment-username {
  font-weight: 500;
  color: #4f46e5;
  cursor: pointer;
  margin-right: 2px;
}
.comment-votes {
  display: flex;
  align-items: center;
  gap: 4px;
}
.comment-vote-count {
  min-width: 16px;
  text-align: center;
}
.comment-vote-btn {
  background: #e5e7eb;
  border: none;
  border-radius: 4px;
  padding: 2px 4px;
  cursor: pointer;
  font-size: 12px;
}
.comment-vote-btn:hover {
  background: #d1d5db;
}

/* Full comments section in modal */
.full-comments {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.comment-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #f9fafb;
  padding: 8px;
  border-radius: 8px;
}
.comment-body {
  flex: 1;
}
.comment-header {
  font-size: 13px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
}
.comment-header .comment-username {
  font-weight: 600;
  color: #4f46e5;
  cursor: pointer;
}
.comment-action-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 12px;
}
.comment-input {
  flex: 1;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}
.comment-form-container {
  margin-top: 12px;
  display: flex;
  align-items: center;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 6px;
}

.post-tag {
  background: #eef2ff;
  color: #4f46e5;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.post-text {
  margin: 6px 0;
  font-size: 15px;
}

.post-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.vote-btn {
  background: #e5e7eb;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.vote-btn.voted {
  background: #c7d2fe;
  color: #4f46e5;
}

.comment-count {
  color: #6b7280;
  cursor: pointer;
}

/* Communities */
.communities-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 12px;
}

.communities-list {
  padding: 0 12px 24px 12px;
}

.community-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.community-card .community-name {
  font-weight: 500;
}

/* Messages */
.messages-container {
  display: flex;
  height: calc(100vh - 140px);
}

.conversations-panel {
  width: 30%;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  padding: 12px;
}

.conversation-item {
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 6px;
}

.conversation-item:hover,
.conversation-item.active {
  background: #eef2ff;
}

.chat-panel {
  width: 70%;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  margin-bottom: 12px;
}

.message {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
}

.message.me {
  align-items: flex-end;
}

.message-content {
  background: #e5e7eb;
  border-radius: 8px;
  padding: 6px 10px;
  display: inline-block;
  max-width: 70%;
}

.message.me .message-content {
  background: #c7d2fe;
  color: #3730a3;
}

.chat-form {
  display: flex;
  gap: 8px;
}

.chat-form input {
  flex: 1;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
}

/* Profile */
.profile-section {
  padding: 16px 12px;
}

.profile-section h3 {
  margin-bottom: 8px;
}

.profile-post,
.profile-comment {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
}

.profile-comment small {
  color: #6b7280;
}

/* Auth */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #f5f6fa;
  padding: 16px;
}

.auth-card {
  background: white;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 400px;
}

/* Note on the registration form encouraging anonymity */
.auth-card .note {
  margin: 6px 0 12px 0;
  font-size: 13px;
  color: #6b7280;
}

.auth-card h2 {
  margin-bottom: 8px;
  color: #4f46e5;
}

.auth-card .subtitle {
  margin-bottom: 16px;
  color: #6b7280;
  font-size: 14px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-card input {
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.auth-card .primary-btn {
  width: 100%;
  margin-top: 4px;
}

.alert {
  background: #fee2e2;
  color: #b91c1c;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 14px;
}

.switch {
  margin-top: 12px;
  font-size: 14px;
}

.switch a {
  color: #4f46e5;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 10px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
  margin-bottom: 12px;
}

.modal-content textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  resize: vertical;
  font-size: 14px;
  margin-bottom: 8px;
}

.modal-content .form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.modal-content select {
  flex: 1;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.comment-item {
  background: #f9fafb;
  border-radius: 6px;
  padding: 6px;
  margin-top: 4px;
  font-size: 14px;
}

.comment-item small {
  color: #6b7280;
  font-size: 12px;
}