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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #313338;
  color: #dbdee1;
  min-height: 100vh;
}

a {
  color: #00a8fc;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Auth pages */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.auth-box {
  background: #1e1f22;
  border-radius: 8px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
}

.auth-box h1 {
  color: #f2f3f5;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

.auth-box p.subtitle {
  color: #b5bac1;
  text-align: center;
  margin-bottom: 20px;
  font-size: 14px;
}

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

.form-group label {
  display: block;
  color: #b5bac1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: #1e1f22;
  border: 1px solid #3f4147;
  border-radius: 4px;
  color: #dbdee1;
  font-size: 16px;
  outline: none;
}

.form-group input:focus {
  border-color: #5865f2;
}

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
}

.btn-primary {
  background: #5865f2;
  color: white;
}

.btn-primary:hover {
  background: #4752c4;
}

.btn-danger {
  background: #ed4245;
  color: white;
}

.btn-danger:hover {
  background: #c03537;
}

.btn-primary:disabled {
  background: #4752c4;
  opacity: 0.6;
  cursor: not-allowed;
}

.divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  color: #6d6f78;
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid #3f4147;
}

.divider span {
  padding: 0 8px;
}

.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid #3f4147;
  border-radius: 4px;
  background: #2b2d31;
  color: #dbdee1;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}

.btn-oauth:hover {
  background: #3f4147;
}

.auth-footer {
  margin-top: 16px;
  font-size: 14px;
  color: #b5bac1;
}

.error-message {
  background: #f23f42;
  color: white;
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
}

.error-message.visible {
  display: block;
}

/* App layout */
.app-layout {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 280px;
  background: #2b2d31;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #313338;
}

.content-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid #1e1f22;
  height: 48px;
  flex-shrink: 0;
}

#content-title {
  font-weight: 600;
  color: #f2f3f5;
  white-space: nowrap;
  flex-shrink: 0;
}

#content-title:empty {
  display: none;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.search-btn {
  width: auto !important;
  padding: 6px 14px !important;
  margin-top: 0 !important;
  font-size: 13px !important;
  flex-shrink: 0;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-filter-toggle {
  position: absolute;
  right: 8px;
  cursor: pointer;
  color: #949ba4;
  font-size: 10px;
}

.search-filter-toggle:hover {
  color: #dbdee1;
}

.search-input {
  width: 100%;
  padding: 6px 28px 6px 10px;
  background: #1e1f22;
  border: 1px solid #3f4147;
  border-radius: 4px;
  color: #dbdee1;
  font-size: 13px;
  outline: none;
}

.search-input:focus {
  border-color: #5865f2;
}

.search-filters {
  padding: 8px 16px;
  background: #313338;
  border-bottom: 1px solid #1e1f22;
}

.search-filters input[type="text"] {
  width: 100%;
  padding: 6px 10px;
  background: #1e1f22;
  border: 1px solid #3f4147;
  border-radius: 4px;
  color: #dbdee1;
  font-size: 13px;
  outline: none;
}

.search-filters input[type="text"]:focus {
  border-color: #5865f2;
}

.search-filters .form-group {
  margin-bottom: 8px;
}

.search-filters input[type="date"] {
  width: 100%;
  padding: 6px 8px;
  background: #1e1f22;
  border: 1px solid #3f4147;
  border-radius: 4px;
  color: #dbdee1;
  font-size: 13px;
  outline: none;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  background: #2b2d31;
  padding: 8px;
}

.search-result-item {
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 4px;
  background: #313338;
}

.search-result-item:hover {
  background: #3f4147;
}

.search-result-meta {
  font-size: 12px;
  color: #949ba4;
  margin-bottom: 2px;
}

.search-result-content {
  color: #dbdee1;
  font-size: 14px;
}

.search-no-results {
  color: #949ba4;
  text-align: center;
  padding: 16px;
  font-size: 14px;
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.message-input-container {
  padding: 0 16px 16px;
}

.message-input {
  width: 100%;
  padding: 12px 16px;
  background: #383a40;
  border: none;
  border-radius: 8px;
  color: #dbdee1;
  font-size: 16px;
  outline: none;
}

.message-input::placeholder {
  color: #6d6f78;
}

.message-bar {
  display: flex;
  align-items: center;
  background: #383a40;
  border-radius: 8px;
  padding: 0 4px;
}

.message-bar .message-input {
  background: transparent;
  border-radius: 0;
  flex: 1;
  min-width: 0;
  width: auto;
  cursor: text;
}

.attach-btn {
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  color: #949ba4;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.attach-btn:hover {
  color: #dbdee1;
  background: #2b2d31;
}

.attachment-preview {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  flex-wrap: wrap;
}

.attachment-preview .att-item {
  position: relative;
  width: 60px;
  height: 60px;
}

.attachment-preview .att-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.attachment-preview .att-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ed4245;
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}

.message-attachments {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.message-attachments img {
  max-width: 300px;
  max-height: 300px;
  border-radius: 4px;
  cursor: pointer;
}

.message-attachments img:hover {
  opacity: 0.9;
}

.message {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  margin-bottom: 8px;
}

div.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #5865f2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  flex-shrink: 0;
}

img.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #5865f2;
}

.message-content {
  flex: 1;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.message-author {
  color: #f2f3f5;
  font-weight: 500;
}

.message-timestamp {
  color: #949ba4;
  font-size: 12px;
}

.message-text {
  color: #dbdee1;
  line-height: 1.4;
}

.message-actions {
  font-size: 12px;
  opacity: 0;
}

.message:hover .message-actions {
  opacity: 1;
}

.message-actions a {
  color: #949ba4;
  margin-left: 4px;
}

.message-actions a:hover {
  color: #dbdee1;
}

.message-edit-input {
  width: 100%;
  background: #383a40;
  border: 1px solid #5865f2;
  border-radius: 4px;
  color: #dbdee1;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  padding: 4px 8px;
  resize: none;
  outline: none;
  box-sizing: border-box;
  min-height: unset;
}

/* Sidebar items */
.sidebar-header {
  padding: 0 16px;
  font-weight: 600;
  color: #f2f3f5;
  border-bottom: 1px solid #1e1f22;
  font-size: 15px;
  height: 48px;
  display: flex;
  align-items: center;
}

.sidebar-item {
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  color: #949ba4;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-item:hover {
  background: #35373c;
  color: #dbdee1;
}

.sidebar-item.active {
  background: #404249;
  color: #f2f3f5;
}

.unread-badge {
  margin-left: auto;
  background: #ed4245;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.sidebar-section-title {
  padding: 16px 12px 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #949ba4;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-action {
  cursor: pointer;
  font-size: 16px;
  font-weight: 400;
  color: #949ba4;
}

.sidebar-action:hover {
  color: #dbdee1;
}

.info-icon {
  color: #949ba4;
  cursor: help;
  font-size: 14px;
  margin-left: auto;
}

.info-icon:hover {
  color: #dbdee1;
}

.user-bar {
  padding: 8px 12px;
  background: #232428;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #1e1f22;
}

.presence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.presence-dot.online, .presence-dot-inline.online { background: #23a559; }
.presence-dot.idle, .presence-dot-inline.idle { background: #f0b232; }
.presence-dot.away, .presence-dot-inline.away { background: #ed4245; }
.presence-dot.offline, .presence-dot-inline.offline { background: #80848e; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal {
  background: #313338;
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  position: relative;
}

.modal.modal-wide {
  max-width: 700px;
  min-height: 500px;
  padding: 0;
}

#modal-profile {
  width: 100%;
}

.profile-layout {
  display: flex;
  min-height: 500px;
}

.profile-nav {
  width: 180px;
  background: #2b2d31;
  padding: 16px 12px;
  border-radius: 8px 0 0 8px;
  flex-shrink: 0;
}

.profile-nav-item {
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  color: #949ba4;
  font-size: 14px;
  margin-bottom: 2px;
}

.profile-nav-item:hover {
  background: #35373c;
  color: #dbdee1;
}

.profile-nav-item.active {
  background: #404249;
  color: #f2f3f5;
}

.profile-body {
  flex: 1;
  padding: 24px 32px;
  min-width: 0;
}

.profile-section {
  display: none;
}

.profile-section.active {
  display: block;
}

.profile-section h2 {
  margin-bottom: 20px;
}

.profile-card {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.profile-card-avatar {
  flex-shrink: 0;
}

.profile-card-fields {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #2b2d31;
  border: 1px solid #3f4147;
  color: #dbdee1;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0 6px 6px 0;
}

.provider-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #23a559;
}

.link-provider-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px dashed #4e5058;
  background: transparent;
  color: #b5bac1;
  cursor: pointer;
  font-size: 13px;
  margin: 0 6px 6px 0;
  text-decoration: none;
}

.link-provider-btn:hover {
  border-color: #5865f2;
  color: #dbdee1;
  background: rgba(88, 101, 242, 0.1);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  color: #949ba4;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #f2f3f5;
}

.modal h2 {
  color: #f2f3f5;
  font-size: 20px;
  margin-bottom: 16px;
}

.modal .form-group label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal .form-group input[type="checkbox"] {
  width: auto;
}

.selected-user-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #404249;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 4px;
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1;
}

.tag-remove {
  background: none;
  color: #949ba4;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.tag-remove:hover {
  color: #f2f3f5;
}

.community-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 4px;
}

.community-member-row:hover {
  background: #35373c;
}

.community-member-row .member-name {
  font-size: 14px;
  color: #dbdee1;
}

.community-member-row .role-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #dbdee1;
}

.community-member-row .role-badge.owner {
  background: #f0b232;
  color: #1e1f22;
}

.community-member-row .role-badge.admin {
  background: #5865f2;
}

.community-member-row .role-badge.member {
  background: #3f4147;
}

.community-member-row select {
  background: #2b2d31;
  color: #dbdee1;
  border: 1px solid #4e5058;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
}

/* Channel gear icon */
.channel-gear {
  margin-left: auto;
  opacity: 0;
  cursor: pointer;
  font-size: 13px;
  color: #949ba4;
  padding: 0 2px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.sidebar-item:hover .channel-gear,
.sidebar-item.active .channel-gear {
  opacity: 1;
}

.channel-gear:hover {
  color: #f2f3f5;
}

/* Avatar wrap with inline presence dot */
.avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

.presence-dot-inline {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #313338;
}

/* Header action buttons */
.header-action-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  background: #4e5058;
  color: #dbdee1;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.header-action-btn:hover {
  background: #6d6f78;
}

/* Read receipt inline indicator */
.read-receipt-names {
  font-size: 11px;
  color: #949ba4;
  padding: 2px 0 0 52px;
}

/* Member sidebar (right) */
.member-sidebar {
  width: 240px;
  background: #2b2d31;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-left: 1px solid #1e1f22;
}

.member-sidebar-header {
  padding: 12px 16px;
  font-weight: 600;
  color: #949ba4;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.member-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: default;
}

.member-item:hover {
  background: #35373c;
}

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.member-avatar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.member-avatar .initial {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #5865f2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.member-avatar .presence-dot-inline {
  width: 8px;
  height: 8px;
  border: 2px solid #2b2d31;
}

.member-name {
  font-size: 14px;
  color: #dbdee1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-name.offline {
  color: #6d6f78;
}

.member-section-label {
  padding: 16px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #949ba4;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
