/* JoshChat Enhanced Stylesheet */
/* Modern dark theme with smooth animations */

:root {
  /* Core colors - Dark theme (default) */
  --bg-primary: #0c0c0c;
  --bg-secondary: #141414;
  --bg-tertiary: #1a1a1a;
  --bg-elevated: #202020;
  --accent: #ff6b35;
  --accent-hover: #ff8555;
  --accent-muted: #cc5629;
  --accent-glow: rgba(255, 107, 53, 0.4);
  --text-primary: #fafafa;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --border: #2a2a2a;
  --border-hover: #3a3a3a;
  --success: #22c55e;
  --error: #ef4444;
  --channel-active: #1f1f1f;
  
  /* Effects */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
  
  /* Spacing */
  --sidebar-width: 260px;
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eeeeee;
  --bg-elevated: #e0e0e0;
  --accent: #ff6b35;
  --accent-hover: #ff8555;
  --accent-muted: #cc5629;
  --accent-glow: rgba(255, 107, 53, 0.3);
  --text-primary: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #888888;
  --border: #d0d0d0;
  --border-hover: #b0b0b0;
  --channel-active: #e8e8e8;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Animated grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255,107,53,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,107,53,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
  animation: gridPulse 8s ease-in-out infinite;
}

@keyframes gridPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.app { 
  display: flex; 
  height: 100vh; 
  position: relative; 
  z-index: 1; 
}

/* ==================== PASSWORD SCREEN ==================== */
.password-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.5s ease;
}

.password-screen.hidden { 
  display: none; 
  animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.password-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 48px;
  text-align: center;
  border-radius: 0;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(20px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

.password-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.password-logo span { 
  color: var(--accent);
  text-shadow: var(--shadow-glow);
}

.password-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 32px;
}

.password-input {
  width: 160px;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  text-align: center;
  letter-spacing: 12px;
  outline: none;
  transition: all var(--transition-normal);
}

.password-input:focus { 
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.password-input::placeholder { letter-spacing: 4px; }

.password-error {
  color: var(--error);
  margin-top: 16px;
  font-size: 13px;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-normal);
}

.sidebar-header { 
  padding: 20px; 
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo span { 
  color: var(--accent);
  text-shadow: var(--shadow-glow);
}

.user-section { 
  padding: 16px 20px; 
  border-bottom: 1px solid var(--border);
}

.user-info { display: flex; align-items: center; gap: 12px; }

.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: #000;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.user-avatar:hover {
  transform: scale(1.1);
}

.user-details { flex: 1; min-width: 0; }

.user-name { 
  font-weight: 600; 
  font-size: 13px; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}

.user-status { 
  font-size: 11px; 
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.edit-name-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: all var(--transition-fast);
}

.edit-name-btn:hover { 
  color: var(--accent); 
  transform: rotate(15deg);
}

.channels-section { 
  flex: 1; 
  overflow-y: auto; 
  padding: 12px 0; 
}

.channels-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  padding: 0 20px; 
  margin-bottom: 8px;
}

.channels-title { 
  font-size: 11px; 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: 1px; 
  color: var(--text-muted);
}

.add-channel-btn {
  width: 22px;
  height: 22px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.add-channel-btn:hover { 
  background: var(--accent); 
  color: #000; 
  border-color: var(--accent); 
  transform: scale(1.1);
}

.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  font-size: 13px;
  position: relative;
}

.channel::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform var(--transition-fast);
}

.channel:hover { 
  background: var(--bg-tertiary); 
  color: var(--text-primary); 
}

.channel.active { 
  background: var(--channel-active); 
  color: var(--text-primary); 
}

.channel.active::before {
  transform: scaleY(1);
}

.channel.pinned { color: var(--accent); }
.channel.pinned::before {
  content: '';
  display: block;
  font-size: 8px;
  margin-right: 2px;
  transform: scaleY(1);
}

.channel-name { 
  flex: 1; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}

/* ==================== MAIN CHAT ==================== */
.main { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  min-width: 0; 
  background: var(--bg-primary);
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.chat-header-info { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
}

.chat-channel-name { 
  font-size: 15px; 
  font-weight: 600; 
}

.chat-channel-desc { 
  font-size: 12px; 
  color: var(--text-muted); 
}

/* ==================== MESSAGES ==================== */
.messages { 
  flex: 1; 
  overflow-y: auto; 
  padding: 20px 24px; 
  display: flex; 
  flex-direction: column; 
  gap: 16px; 
  scroll-behavior: smooth;
}

.message { 
  display: flex; 
  gap: 12px; 
  animation: messageIn 0.3s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-muted), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.message:hover .message-avatar {
  transform: scale(1.1);
}

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

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

.message-sender { 
  font-weight: 600; 
  font-size: 13px; 
  color: var(--accent); 
}

.message-time { 
  font-size: 11px; 
  color: var(--text-muted); 
  font-family: 'JetBrains Mono', monospace; 
}

.message-text { 
  font-size: 14px; 
  line-height: 1.5; 
  color: var(--text-primary); 
  word-wrap: break-word; 
}

.message-text a { 
  color: var(--accent); 
  text-decoration: none;
  transition: color var(--transition-fast);
}

.message-text a:hover {
  text-decoration: underline;
}

.message-text img { 
  max-width: 300px; 
  border-radius: 0;
  margin: 8px 0; 
  display: block; 
  transition: transform var(--transition-fast);
}

.message-text img:hover {
  transform: scale(1.02);
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.reaction:hover { 
  border-color: var(--accent); 
  transform: translateY(-2px);
}

.reaction-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}

/* ==================== MESSAGE INPUT ==================== */
.input-area { 
  padding: 16px 24px; 
  border-top: 1px solid var(--border); 
  background: var(--bg-secondary); 
}

.input-toolbar { 
  display: flex; 
  gap: 8px; 
  margin-bottom: 12px; 
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.toolbar-btn:hover { 
  background: var(--bg-elevated); 
  color: var(--text-primary); 
  border-color: var(--accent);
  transform: translateY(-2px);
}

.input-container { 
  display: flex; 
  gap: 12px; 
  align-items: flex-end; 
}

.message-input-wrapper { 
  flex: 1; 
  position: relative; 
}

.message-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all var(--transition-normal);
}

.message-input:focus { 
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.message-input::placeholder { 
  color: var(--text-muted); 
}

.send-btn {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border: none;
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--transition-fast);
}

.send-btn:hover { 
  background: var(--accent-hover); 
  transform: scale(1.05);
  box-shadow: var(--shadow-glow);
}

.send-btn:disabled { 
  background: var(--bg-tertiary); 
  color: var(--text-muted); 
  cursor: not-allowed; 
  transform: none;
  box-shadow: none;
}

/* ==================== EMOJI PICKER ==================== */
.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 12px;
  display: none;
  z-index: 50;
  width: 280px;
  box-shadow: var(--shadow-lg);
  animation: dropdownIn 0.2s ease;
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.emoji-grid { 
  display: grid; 
  grid-template-columns: repeat(7, 1fr); 
  gap: 2px; 
}

.emoji-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition-fast);
  border-radius: 0;
}

.emoji-btn:hover { 
  background: var(--bg-tertiary); 
  transform: scale(1.2);
}

/* ==================== GIF PICKER ==================== */
.gif-picker {
  position: absolute;
  bottom: 100%;
  left: 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 12px;
  display: none;
  z-index: 50;
  width: 320px;
  box-shadow: var(--shadow-lg);
  animation: dropdownIn 0.2s ease;
}

.gif-picker.open { 
  display: block; 
}

.gif-search {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  margin-bottom: 12px;
  outline: none;
  transition: all var(--transition-fast);
}

.gif-search:focus { 
  border-color: var(--accent);
}

.gif-grid { 
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: 8px; 
  max-height: 250px; 
  overflow-y: auto; 
}

.gif-item { 
  width: 100%; 
  cursor: pointer; 
  transition: all var(--transition-fast); 
  border: 2px solid transparent;
}

.gif-item:hover { 
  opacity: 0.8; 
  border-color: var(--accent);
  transform: scale(1.02);
}

/* ==================== IMAGE UPLOAD ==================== */
.image-upload {
  display: none;
}

.image-upload.open { 
  display: block; 
}

.image-preview {
  margin-bottom: 12px;
  position: relative;
  display: inline-block;
  animation: fadeIn 0.2s ease;
}

.image-preview img {
  max-width: 200px;
  max-height: 150px;
  display: block;
}

.image-preview .remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: var(--error);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.image-preview .remove-btn:hover {
  transform: scale(1.1);
}

/* ==================== WHITEBOARD ==================== */
.whiteboard-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 200;
  display: none;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

.whiteboard-overlay.open { 
  display: flex; 
}

.whiteboard-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.whiteboard-tools { 
  display: flex; 
  gap: 8px; 
}

.whiteboard-tool {
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.whiteboard-tool.active { 
  background: var(--accent); 
  color: #000; 
  border-color: var(--accent); 
}

.whiteboard-tool:hover:not(.active) {
  border-color: var(--accent);
  color: var(--text-primary);
}

.color-picker { 
  display: flex; 
  gap: 4px; 
}

.color-dot {
  width: 22px;
  height: 22px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}

.color-dot:hover { 
  transform: scale(1.1); 
}

.color-dot.active { 
  border-color: #fff; 
  transform: scale(1.1);
  box-shadow: 0 0 10px currentColor;
}

.whiteboard-canvas { 
  flex: 1; 
  background: #fff; 
  cursor: crosshair; 
}

.close-whiteboard {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all var(--transition-fast);
}

.close-whiteboard:hover { 
  background: var(--bg-elevated); 
  border-color: var(--accent);
}

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { 
  display: none; 
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-title { 
  font-size: 18px; 
  font-weight: 600; 
  margin-bottom: 4px; 
  text-align: center; 
}

.modal-subtitle { 
  color: var(--text-muted); 
  text-align: center; 
  margin-bottom: 24px; 
  font-size: 13px;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 16px;
  outline: none;
  transition: all var(--transition-fast);
}

.modal-input:focus { 
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  border: none;
  color: #000;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-btn:hover { 
  background: var(--accent-hover); 
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { 
  width: 6px; 
}

::-webkit-scrollbar-track { 
  background: transparent; 
}

::-webkit-scrollbar-thumb { 
  background: var(--border); 
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover { 
  background: var(--text-muted); 
}

/* ==================== LOADING & EMPTY ==================== */
.loading, .empty-state { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  color: var(--text-muted); 
  gap: 12px; 
  font-size: 13px;
}

.spinner { 
  width: 20px; 
  height: 20px; 
  border: 2px solid var(--border); 
  border-top-color: var(--accent); 
  animation: spin 0.8s linear infinite; 
  border-radius: 50%;
}

@keyframes spin { 
  to { 
    transform: rotate(360deg); 
  } 
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 13px;
  z-index: 200;
  animation: toastIn 0.3s ease;
  box-shadow: var(--shadow-md);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.error { 
  border-color: var(--error); 
  color: var(--error); 
}

.toast.success { 
  border-color: var(--success); 
  color: var(--success); 
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar { 
    position: fixed; 
    left: -260px; 
    height: 100%; 
    z-index: 50; 
    transition: left 0.3s ease; 
  }
  
  .sidebar.open { 
    left: 0; 
    box-shadow: var(--shadow-lg);
  }
  
  .mobile-menu-btn { 
    display: flex; 
  }
}

.mobile-menu-btn { 
  display: none; 
  width: 36px; 
  height: 36px; 
  align-items: center; 
  justify-content: center; 
  background: var(--bg-tertiary); 
  border: 1px solid var(--border); 
  color: var(--text-primary); 
  cursor: pointer; 
  font-size: 16px;
  transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 768px) {
  .mobile-menu-btn { 
    display: flex; 
  }
}

/* ==================== GIPHY ATTRIBUTION ==================== */
.giphy-attribution {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* ==================== NEW MESSAGE FLASH ==================== */
.message.new {
  animation: newMessageFlash 0.5s ease;
}

@keyframes newMessageFlash {
  0% {
    background: rgba(255, 107, 53, 0.2);
  }
  100% {
    background: transparent;
  }
}

/* ==================== HOVER EFFECTS FOR INTERACTIVE ELEMENTS ==================== */
button:hover {
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus-visible {
  outline: none;
}

/* ==================== SELECTION STYLING ==================== */
::selection {
  background: var(--accent);
  color: #000;
}

/* ==================== AUDIO RECORDER ==================== */
.audio-recorder {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 150;
  box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
  animation: audioRecorderIn 0.3s ease;
}

@keyframes audioRecorderIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.audio-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 30px;
}

.audio-bar {
  width: 4px;
  height: 100%;
  background: var(--accent);
  animation: audioBar 0.5s ease-in-out infinite alternate;
}

.audio-bar:nth-child(1) { animation-delay: 0s; }
.audio-bar:nth-child(2) { animation-delay: 0.1s; }
.audio-bar:nth-child(3) { animation-delay: 0.2s; }
.audio-bar:nth-child(4) { animation-delay: 0.3s; }
.audio-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes audioBar {
  0% { height: 20%; }
  100% { height: 100%; }
}

.audio-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-primary);
}

.audio-cancel {
  width: 28px;
  height: 28px;
  background: var(--error);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.audio-cancel:hover {
  transform: scale(1.1);
}

/* Audio message in chat */
.audio-message {
  margin-top: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 250px;
}

.audio-play-btn {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border: none;
  color: #000;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.audio-play-btn:hover {
  transform: scale(1.1);
}

.audio-progress {
  flex: 1;
  height: 4px;
  background: var(--border);
  cursor: pointer;
}

.audio-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
}

.audio-duration {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== ACCOUNT MODAL ==================== */
.account-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.account-tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.account-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  margin-bottom: -1px;
}

.account-error {
  color: var(--error);
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

.account-success {
  color: var(--success);
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

/* ==================== USER PROFILE DISPLAY ==================== */
.user-profile-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 16px;
  margin-top: 8px;
}

.user-profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.user-profile-avatar {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  color: #000;
}

.user-profile-info {
  flex: 1;
}

.user-profile-name {
  font-weight: 600;
  font-size: 15px;
}

.user-profile-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.user-profile-joined {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ==================== ONLINE USERS LIST ==================== */
.online-users-section {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.online-users-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.online-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.online-user-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

/* ==================== PROFILE POPUP ==================== */
.profile-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 340px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0;
  z-index: 2000;
  display: none;
  animation: modalSlideIn 0.2s ease;
}

.profile-popup.open {
  display: block;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.profile-popup-header {
  height: 100px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  position: relative;
}

.profile-popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.profile-popup-close:hover {
  background: var(--bg-elevated);
}

.profile-popup-avatar {
  position: absolute;
  bottom: -36px;
  left: 20px;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 28px;
  color: #000;
  border: 4px solid var(--bg-secondary);
}

.profile-popup-body {
  padding: 48px 20px 20px;
}

.profile-popup-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-popup-handle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.profile-popup-bio {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-tertiary);
}

.profile-popup-bio:empty::before {
  content: 'No bio yet';
  color: var(--text-muted);
  font-style: italic;
}

.profile-popup-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.profile-popup-custom-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.profile-custom-tag {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 12px;
}

.profile-custom-tag-label {
  color: var(--text-muted);
  margin-right: 4px;
}

.profile-custom-tag-value {
  color: var(--accent);
}

.profile-popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.profile-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1999;
  display: none;
}

.profile-popup-overlay.open {
  display: block;
}

/* ==================== SETTINGS MODAL ==================== */
.settings-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  z-index: 2000;
  display: none;
  overflow: hidden;
}

.settings-modal.open {
  display: flex;
  flex-direction: column;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.settings-title {
  font-size: 18px;
  font-weight: 600;
}

.settings-close {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.settings-close:hover {
  background: var(--bg-elevated);
}

.settings-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 14px;
}

.settings-label-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  transition: var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  transition: var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* Settings input */
.settings-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  margin-top: 8px;
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-textarea {
  min-height: 80px;
  resize: vertical;
}

/* Custom field tags */
.custom-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.custom-tag-input {
  flex: 1;
  min-width: 120px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
}

.custom-tag-input:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 12px;
}

.custom-tag-remove {
  cursor: pointer;
  opacity: 0.6;
}

.custom-tag-remove:hover {
  opacity: 1;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1999;
  display: none;
}

.settings-overlay.open {
  display: block;
}

/* Message sender clickable */
.message-sender {
  cursor: pointer;
}

.message-sender:hover {
  text-decoration: underline;
}

.message-avatar {
  cursor: pointer;
}

.message-avatar:hover {
  opacity: 0.8;
}

/* Settings button in sidebar */
.settings-btn {
  margin-top: auto;
  padding: 12px 20px;
  background: var(--bg-tertiary);
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  transition: var(--transition-fast);
}

.settings-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.settings-btn-icon {
  font-size: 16px;
}

/* ==================== CHESS OVERLAY ==================== */
.chess-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 1500;
  display: none;
  flex-direction: column;
}

.chess-overlay.open {
  display: flex;
}

.chess-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.chess-title {
  font-size: 20px;
  font-weight: 700;
}

.chess-controls {
  display: flex;
  gap: 8px;
}

.chess-btn {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition-fast);
}

.chess-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
}

.chess-container {
  flex: 1;
  display: flex;
  padding: 24px;
  gap: 24px;
  overflow: auto;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(70vh, 560px);
  height: min(70vh, 560px);
  border: 2px solid var(--border);
}

.chess-square {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(6vh, 48px);
  cursor: pointer;
  user-select: none;
}

.chess-square.light {
  background: #f0d9b5;
}

.chess-square.dark {
  background: #b58863;
}

.chess-square .piece {
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}

.chess-square .piece.black {
  color: #1a1a1a;
  text-shadow: none;
}

.chess-square.selected {
  box-shadow: inset 0 0 0 3px var(--accent);
}

.chess-square.valid-move {
  position: relative;
}

.chess-square.valid-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
}

.chess-square.dark.valid-move::after {
  background: rgba(255, 255, 255, 0.3);
}

.chess-square.last-move {
  background: rgba(255, 107, 53, 0.3);
}

.chess-sidebar {
  flex: 1;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chess-status {
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

.chess-moves {
  flex: 1;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.8;
}

.chess-moves-grid {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 4px 12px;
}

.move-number {
  color: var(--text-muted);
}

.move-white, .move-black {
  color: var(--text-primary);
}

.chess-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-card {
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.player-card.active {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.player-card.winner {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.player-color {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.player-name {
  font-weight: 600;
}

.player-name.bot {
  color: var(--accent);
}

/* ==================== CHESS MENU ==================== */
.chess-menu {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chess-menu-content {
  flex: 1;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.chess-menu-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 20px;
}

.chess-menu-section h3 {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chess-menu-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition-fast);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chess-menu-btn:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.chess-menu-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chess-menu-btn.primary:hover {
  background: var(--accent-hover);
}

.chess-menu-btn.bot-btn {
  background: var(--bg-tertiary);
}

.chess-waiting-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chess-waiting-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.chess-waiting-player:hover {
  border-color: var(--accent);
}

.chess-waiting-player.your-game {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.1);
}

.chess-waiting-player .cancel-btn {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
}

.chess-waiting-player .cancel-btn:hover {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
}

.chess-waiting-player .join-btn {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
}

.chess-empty-state {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.chess-game-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chess-game-view.hidden {
  display: none;
}
