/* ==================== ChatEbash Design System ==================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Colors - Dark Premium Palette */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: rgba(26, 26, 46, 0.6);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);

  --accent-primary: #6c5ce7;
  --accent-secondary: #a29bfe;
  --accent-gradient: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 50%, #74b9ff 100%);
  --accent-glow: 0 0 20px rgba(108, 92, 231, 0.3);
  --accent-success: #00cec9;
  --accent-danger: #ff6b6b;
  --accent-warning: #feca57;

  --text-primary: #e8e8f0;
  --text-secondary: #8b8ba3;
  --text-muted: #5a5a72;
  --text-accent: #a29bfe;

  --border-color: rgba(255, 255, 255, 0.06);
  --border-active: rgba(108, 92, 231, 0.3);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-width: 340px;
  --header-height: 64px;
}

/* ==================== Reset & Base ==================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a {
  color: var(--accent-secondary);
  text-decoration: none;
}

a:hover {
  color: var(--accent-primary);
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ==================== Auth Page ==================== */
.auth-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(108, 92, 231, 0.15) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  animation: float 8s ease-in-out infinite;
}

.auth-page::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(116, 185, 255, 0.1) 0%, transparent 70%);
  bottom: -150px;
  left: -150px;
  animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -30px) scale(1.05);
  }

  66% {
    transform: translate(-20px, 20px) scale(0.95);
  }
}

.auth-card {
  width: 420px;
  padding: 48px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  z-index: 1;
  animation: slideUp 0.6s var(--transition-slow);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-logo {
  text-align: center;
  margin-bottom: 36px;
}

.auth-logo h1 {
  font-size: 32px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 8px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
  background: var(--bg-glass-hover);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 15px;
  box-shadow: var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(108, 92, 231, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-active);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--accent-danger);
  border: 1px solid rgba(255, 107, 107, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.25);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 18px;
}

.btn-icon:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.auth-error {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.2);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--accent-danger);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
  animation: shake 0.4s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-8px);
  }

  75% {
    transform: translateX(8px);
  }
}

/* ==================== Chat Layout ==================== */
.chat-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow);
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
}

.sidebar-header h2 {
  font-size: 20px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
}

.sidebar-search {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: all var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235a5a72'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 18px;
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  margin-bottom: 2px;
}

.chat-item:hover {
  background: var(--bg-glass-hover);
}

.chat-item.active {
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid rgba(108, 92, 231, 0.15);
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-avatar .online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: var(--accent-success);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-secondary);
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.chat-time {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-badge {
  background: var(--accent-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
}

.chat-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--header-height);
  background: var(--bg-secondary);
  backdrop-filter: blur(10px);
}

.chat-header-info {
  flex: 1;
}

.chat-header-name {
  font-weight: 600;
  font-size: 16px;
}

.chat-header-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-header-status.online {
  color: var(--accent-success);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Empty state */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.chat-empty-icon {
  font-size: 80px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.chat-empty h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.chat-empty p {
  font-size: 14px;
}

/* Messages */
.message {
  display: flex;
  gap: 10px;
  max-width: 70%;
  animation: messageIn 0.3s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.own {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-content {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  position: relative;
}

.own .message-content {
  background: rgba(108, 92, 231, 0.2);
  border: 1px solid rgba(108, 92, 231, 0.15);
  border-radius: 16px 16px 4px 16px;
}

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-secondary);
  margin-bottom: 2px;
}

.message-sender.admin-tag {
  color: var(--accent-warning);
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.message-text img {
  max-width: 280px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

.message-system {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px;
  align-self: center;
  max-width: 100%;
}

/* Typing indicator */
.typing-indicator {
  padding: 4px 24px;
  font-size: 12px;
  color: var(--accent-secondary);
  min-height: 24px;
  font-style: italic;
}

/* Input Area */
.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.chat-input-wrapper {
  flex: 1;
  position: relative;
}

.chat-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 120px;
  min-height: 48px;
  transition: border-color var(--transition-fast);
}

.chat-input:focus {
  border-color: var(--accent-primary);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 48px;
  height: 48px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
  box-shadow: var(--accent-glow);
  flex-shrink: 0;
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 0 25px rgba(108, 92, 231, 0.4);
}

/* ==================== Modal ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  display: none;
}

.modal-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* User list in modal */
.user-select-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 16px 0;
}

.user-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-select-item:hover {
  background: var(--bg-glass-hover);
}

.user-select-item.selected {
  background: rgba(108, 92, 231, 0.15);
  border: 1px solid rgba(108, 92, 231, 0.2);
}

.user-select-item input[type="checkbox"] {
  accent-color: var(--accent-primary);
  width: 18px;
  height: 18px;
}

/* ==================== Admin Panel ==================== */
.admin-layout {
  display: flex;
  height: 100vh;
}

.admin-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.admin-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.admin-sidebar-header h2 {
  font-size: 20px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.admin-sidebar-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.admin-nav {
  padding: 12px;
  flex: 1;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.admin-nav-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.admin-nav-item.active {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent-secondary);
  border: 1px solid rgba(108, 92, 231, 0.15);
}

.admin-nav-item .nav-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.admin-section h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
}

.admin-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table td {
  padding: 14px 16px;
  background: var(--bg-card);
  font-size: 14px;
}

.admin-table tr td:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.admin-table tr td:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.admin-table tbody tr {
  transition: all var(--transition-fast);
}

.admin-table tbody tr:hover td {
  background: var(--bg-glass-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-admin {
  background: rgba(254, 202, 87, 0.15);
  color: var(--accent-warning);
}

.badge-user {
  background: rgba(0, 206, 201, 0.15);
  color: var(--accent-success);
}

.badge-online {
  background: rgba(0, 206, 201, 0.15);
  color: var(--accent-success);
}

.badge-offline {
  background: rgba(139, 139, 163, 0.15);
  color: var(--text-secondary);
}

.badge-private {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent-secondary);
}

.badge-group {
  background: rgba(116, 185, 255, 0.15);
  color: #74b9ff;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

/* ==================== Profile Sidebar ==================== */
.profile-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 360px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: 100;
  transition: right var(--transition-slow);
  display: flex;
  flex-direction: column;
}

.profile-panel.open {
  right: 0;
}

.profile-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profile-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.profile-avatar-large {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 20px;
  position: relative;
  overflow: hidden;
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==================== Toast / Notification ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.success {
  border-left: 3px solid var(--accent-success);
}

.toast.error {
  border-left: 3px solid var(--accent-danger);
}

.toast.info {
  border-left: 3px solid var(--accent-primary);
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .chat-header .mobile-menu-btn {
    display: block;
  }

  .auth-card {
    width: 100%;
    margin: 16px;
  }
}

/* ==================== Loading ==================== */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loader-dots {
  display: flex;
  gap: 6px;
}

.loader-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  animation: bounce 1.4s ease-in-out infinite;
}

.loader-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loader-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Group avatar */
.chat-avatar.group {
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
}

/* ==================== Reactions ==================== */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.reaction-badge:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-active);
  transform: scale(1.1);
}

.reaction-badge.own {
  background: rgba(108, 92, 231, 0.15);
  border-color: rgba(108, 92, 231, 0.3);
}

.reaction-badge .reaction-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.reaction-picker {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  gap: 2px;
  flex-wrap: wrap;
  animation: fadeIn 0.15s ease;
}

.reaction-picker.show {
  display: flex;
}

.reaction-picker span {
  font-size: 22px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.reaction-picker span:hover {
  background: var(--bg-glass-hover);
  transform: scale(1.25);
}

/* ==================== Reply Quote ==================== */
.reply-quote {
  background: rgba(108, 92, 231, 0.08);
  border-left: 3px solid var(--accent-secondary);
  padding: 6px 10px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.reply-quote:hover {
  background: rgba(108, 92, 231, 0.15);
}

.reply-quote .reply-author {
  font-weight: 600;
  color: var(--accent-secondary);
  margin-bottom: 2px;
}

.reply-quote .reply-text {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

/* Reply compose bar */
.reply-compose {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  animation: slideUp 0.2s ease;
}

.reply-compose.active {
  display: flex;
}

.reply-compose .reply-preview {
  flex: 1;
  border-left: 3px solid var(--accent-secondary);
  padding-left: 10px;
}

.reply-compose .reply-preview-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-secondary);
}

.reply-compose .reply-preview-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-compose .reply-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.reply-compose .reply-close:hover {
  color: var(--text-primary);
}

/* ==================== Pinned Message Banner ==================== */
.pinned-banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.08), rgba(116, 185, 255, 0.08));
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.pinned-banner.visible {
  display: flex;
}

.pinned-banner:hover {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(116, 185, 255, 0.15));
}

.pinned-banner .pin-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.pinned-banner .pin-content {
  flex: 1;
  min-width: 0;
}

.pinned-banner .pin-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-secondary);
}

.pinned-banner .pin-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-banner .pin-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.pinned-banner .pin-close:hover {
  color: var(--accent-danger);
}

/* ==================== Search Modal ==================== */
.search-results-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  z-index: 1000;
}

.search-results-modal.active {
  display: flex;
}

.search-results-container {
  width: 560px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

.search-results-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-results-header input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.search-results-header input:focus {
  border-color: var(--accent-primary);
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.search-result-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-bottom: 4px;
}

.search-result-item:hover {
  background: var(--bg-glass-hover);
}

.search-result-chat {
  font-size: 11px;
  color: var(--accent-secondary);
  font-weight: 600;
  margin-bottom: 4px;
}

.search-result-text {
  font-size: 14px;
  color: var(--text-primary);
}

.search-result-text mark {
  background: rgba(108, 92, 231, 0.3);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 0 2px;
}

.search-result-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==================== Message Context Menu ==================== */
.msg-context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 200;
  min-width: 180px;
  animation: fadeIn 0.15s ease;
  backdrop-filter: blur(20px);
}

.msg-context-menu .ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.msg-context-menu .ctx-item:hover {
  background: var(--bg-glass-hover);
}

.msg-context-menu .ctx-item.danger {
  color: var(--accent-danger);
}

.msg-context-menu .ctx-item .ctx-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.msg-context-menu .ctx-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* ==================== Delivery Status ==================== */
.delivery-status {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  font-size: 13px;
  vertical-align: middle;
}

.delivery-status .tick {
  color: var(--text-muted);
}

.delivery-status .tick.delivered {
  color: var(--text-secondary);
}

.delivery-status .tick.read {
  color: var(--accent-success);
}

/* ==================== Edited indicator ==================== */
.message-edited-tag {
  display: inline;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-left: 4px;
}

/* ==================== Message Highlight ==================== */
.message.highlight {
  animation: highlightMsg 2s ease;
}

@keyframes highlightMsg {

  0%,
  30% {
    background: rgba(108, 92, 231, 0.15);
  }

  100% {
    background: transparent;
  }
}