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

:root {
  --primary: #1f2937;
  --primary-light: #374151;
  --primary-dark: #111827;
  --secondary: #ef4444;
  --gradient-start: #1f2937;
  --gradient-end: #374151;
  --bg-body: #f3f4f6;
  --bg-topbar: #fff;
  --bg-card: #fff;
  --bg-sidebar: #fff;
  --bg-message: #fff;
  --bg-message-hover: #f9fafb;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-topbar: #1f2937;
  --text-sidebar: #374151;
  --border-light: #e5e7eb;
  --border-sidebar: #e5e7eb;
  --btn-primary: #1f2937;
  --btn-hover: #374151;
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-sidebar: 4px 0 20px rgba(0, 0, 0, 0.08);
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 50px;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
}

[data-theme="dark"] {
  --primary: #fff;
  --primary-light: #f3f4f6;
  --primary-dark: #e5e7eb;
  --gradient-start: #fff;
  --gradient-end: #f3f4f6;
  --bg-body: #1a1d24;
  --bg-topbar: #23272f;
  --bg-card: #2a2f38;
  --bg-sidebar: #23272f;
  --bg-message: #2a2f38;
  --bg-message-hover: #353b47;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-topbar: #f9fafb;
  --text-sidebar: #e5e7eb;
  --border-light: #3d4451;
  --border-sidebar: #3d4451;
  --btn-primary: #fff;
  --btn-hover: #f3f4f6;
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-sidebar: 4px 0 20px rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  transition: 0.3s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sidebar);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-nav-text,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-user-info {
  opacity: 0;
  visibility: hidden;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 0.75rem;
}

.sidebar.collapsed .sidebar-nav-item i {
  margin-right: 0;
}

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-sidebar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-body);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  transition: 0.3s;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--primary);
  color: var(--bg-body);
  border-color: var(--primary);
}

.sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.sidebar-nav-section {
  margin-bottom: 1.5rem;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  transition: 0.3s;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-s);
  color: var(--text-sidebar);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: 0.2s;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav-item i {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: 0.2s;
}

.sidebar-nav-item:hover {
  background: rgba(128, 128, 128, 0.1);
  color: var(--btn-primary);
}

.sidebar-nav-item:hover i {
  color: var(--btn-primary);
}

.sidebar-nav-item.active {
  background: rgba(128, 128, 128, 0.15);
  color: var(--btn-primary);
}

.sidebar-nav-item.active i {
  color: var(--btn-primary);
}

.sidebar-nav-text {
  transition: 0.3s;
}

.sidebar-user {
  padding: 1rem;
  border-top: 1px solid var(--border-sidebar);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
  cursor: pointer;
}

.sidebar-user-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-body);
  font-weight: 600;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.sidebar-user-info {
  overflow: hidden;
  transition: 0.3s;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-wrapper.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

.top-bar {
  background: var(--bg-topbar);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.theme-toggle,
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0.5rem;
  border-radius: var(--radius-s);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  cursor: pointer;
}

.theme-toggle:hover,
.icon-btn:hover {
  background: rgba(128, 128, 128, 0.1);
  color: var(--btn-primary);
}

.auth-btn {
  background: var(--btn-primary);
  color: var(--bg-body);
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-l);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: 0.3s;
  border: none;
  white-space: nowrap;
}

.auth-btn:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
}

.main-content {
  flex: 1;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.feed-container {
  width: 100%;
  max-width: 700px;
}

.message-card {
  background: var(--bg-message);
  padding: 1rem 1.25rem;
  display: flex;
  gap: 1rem;
  transition: 0.2s;
  border-bottom: 1px solid var(--border-light);
}

.message-card:hover {
  background: var(--bg-message-hover);
}

.message-avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  background: linear-gradient(135deg, #6b7280, #9ca3af);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.message-author {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.95rem;
  cursor: pointer;
}

.message-author:hover {
  color: var(--btn-primary);
}

.message-timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message-content {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
  word-wrap: break-word;
  cursor: pointer;
}

.message-media {
  margin-top: 0.75rem;
  border-radius: var(--radius-m);
  overflow: hidden;
  max-width: 100%;
}

.message-media img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
}

.message-media iframe,
.message-media video {
  max-width: 100%;
  border-radius: var(--radius-m);
}

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-m);
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.reaction-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.2s;
  color: var(--text-main);
}

.reaction-btn:hover {
  background: rgba(128, 128, 128, 0.1);
  transform: scale(1.05);
}

.reaction-btn.active {
  background: rgba(128, 128, 128, 0.15);
}

.reaction-btn .emoji {
  font-size: 1rem;
}

.reaction-btn .count {
  font-weight: 600;
  font-size: 0.8rem;
}

.add-reaction-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: transparent;
  border: 1px dashed var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  transition: 0.2s;
}

.add-reaction-btn:hover {
  background: rgba(128, 128, 128, 0.1);
  color: var(--btn-primary);
}

.emoji-picker {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-m);
  padding: 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
}

.emoji-picker.active {
  display: block;
}

.emoji-picker-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.25rem;
}

.emoji-option {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: var(--radius-s);
  transition: 0.2s;
}

.emoji-option:hover {
  background: rgba(128, 128, 128, 0.15);
  transform: scale(1.15);
}

.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--btn-primary);
  color: var(--bg-body);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  transition: 0.3s;
  z-index: 50;
  cursor: pointer;
  border: none;
}

.fab:hover {
  transform: scale(1.1) rotate(90deg);
}

.loader-card {
  background: var(--bg-card);
  border-radius: var(--radius-m);
  padding: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
}

.loader-card i {
  color: var(--btn-primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  opacity: 0;
  transition: 0.3s;
}

.sidebar-overlay.active {
  opacity: 1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(8px);
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-m);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-light);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-s);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.5rem;
  transition: 0.2s;
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.modal-body {
  padding: 1.5rem;
}

.modal-form-group {
  margin-bottom: 1.25rem;
}

.modal-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.modal-textarea,
.modal-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-m);
  font-size: 0.95rem;
  background: var(--bg-body);
  color: var(--text-main);
  transition: 0.3s;
  font-family: inherit;
}

.modal-textarea {
  min-height: 120px;
  resize: vertical;
}

.modal-textarea:focus,
.modal-input:focus {
  outline: none;
  border-color: var(--btn-primary);
}

.modal-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.modal-media-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn-cancel {
  padding: 0.7rem 1.5rem;
  background: transparent;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-m);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.btn-cancel:hover {
  background: var(--bg-body);
}

.btn-send {
  padding: 0.7rem 1.5rem;
  background: var(--btn-primary);
  color: var(--bg-body);
  border: none;
  border-radius: var(--radius-m);
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s;
}

.btn-send:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Notification banner */
.notification-banner {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: var(--bg-card);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-hover);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  z-index: 100;
  max-width: 350px;
  border: 1px solid var(--border-light);
  transition: transform 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(4px);
}

.notification-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.notification-badge {
  background: linear-gradient(135deg, #ff4d4d, #ff1a1a);
  color: white;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(255, 0, 0, 0.3);
}

.notification-text {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-main);
  flex: 1;
}