/* VaultChat - Premium Vanilla CSS Design System */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* Color Variables and Tokens */
:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Color Palette (Light Mode Default) */
  --bg-primary: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --bg-hover: #F1F5F9;
  --bg-active: #EEF2FF;
  --bg-composer: #F8FAFC;
  
  --border-color: #E2E8F0;
  --border-hover: #CBD5E1;
  --border-active: #C7D2FE;
  
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-active: #4F46E5;
  
  --brand-color: #4F46E5;
  --brand-hover: #4338CA;
  --brand-glow: rgba(79, 70, 229, 0.15);
  
  --danger-color: #EF4444;
  --danger-hover: #DC2626;
  --danger-bg: #FEF2F2;
  
  --warning-color: #D97706;
  --warning-bg: #FFFBEB;
  --warning-border: #FDE68A;
  --warning-text: #B45309;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Tokens Override */
html.dark {
  --bg-primary: #0B0F19;
  --bg-card: #131B2E;
  --bg-sidebar: #111827;
  --bg-hover: #1E293B;
  --bg-active: #1E2235;
  --bg-composer: #1E293B;
  
  --border-color: #1E293B;
  --border-hover: #334155;
  --border-active: #312E81;
  
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-active: #818CF8;
  
  --brand-color: #6366F1;
  --brand-hover: #4F46E5;
  --brand-glow: rgba(99, 102, 241, 0.2);
  
  --danger-color: #F87171;
  --danger-hover: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  
  --warning-color: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --warning-border: rgba(245, 158, 11, 0.2);
  --warning-text: #FBBF24;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* Reset and Globals */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

input, button, [contenteditable] {
  font-family: inherit;
  color: inherit;
}

a {
  color: var(--brand-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  text-decoration: underline;
}

/* Scrollbars */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Layout classes */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.hidden {
  display: none !important;
}

/* ==========================================================================
   1. LOGIN PAGE STYLING
   ========================================================================== */
.login-body {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-primary);
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 28px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background-color: var(--bg-hover);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.login-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  position: relative;
}

.form-input {
  width: 100%;
  height: 46px;
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  border-color: var(--brand-color);
  box-shadow: 0 0 0 4px var(--brand-glow);
}

.submit-btn {
  width: 100%;
  height: 46px;
  background-color: var(--brand-color);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}
.submit-btn:hover {
  background-color: var(--brand-hover);
}
.submit-btn:active {
  transform: scale(0.98);
}
.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   2. MAIN DASHBOARD LAYOUT
   ========================================================================== */
.app-layout {
  display: flex;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

/* --- SIDEBAR STYLING --- */
.sidebar {
  width: 300px;
  min-width: 300px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 30;
  transition: transform var(--transition-normal), background-color var(--transition-normal);
}

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

.header-branding {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-box {
  width: 32px;
  height: 32px;
  background-color: var(--brand-color);
  color: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 36px;
  background-color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-full);
  padding: 0 16px 0 34px;
  font-size: 13.5px;
  outline: none;
  transition: box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.search-box input:focus {
  background-color: var(--bg-card);
  box-shadow: 0 0 0 2px var(--border-hover);
}

.channels-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loading-channels, .empty-channels {
  padding: 16px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* Channel Item Row */
.channel-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.channel-item:hover {
  background-color: var(--bg-hover);
}

.channel-item.active {
  background-color: var(--bg-active);
  border-color: var(--border-active);
}

.channel-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 3px;
  background-color: var(--brand-color);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.channel-actions-trigger {
  opacity: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
  z-index: 5;
  flex-shrink: 0;
}

.channel-item:hover .channel-actions-trigger,
.channel-actions-trigger:focus {
  opacity: 1;
}

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

/* Mobile: always show the options button so it is easy to touch */
@media (max-width: 1024px) {
  .channel-actions-trigger {
    opacity: 1;
  }
}

.channel-meta-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.channel-icon {
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

.channel-name-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.channel-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-item.active .channel-title {
  color: var(--text-active);
}

.channel-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer / Admin info */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-box {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--bg-hover);
  border: 2px solid var(--bg-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex-shrink: 0;
}

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

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

.user-name {
  font-size: 13px;
  font-weight: 700;
}

.user-role {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.logout-btn:hover {
  color: var(--danger-color);
}

/* --- MAIN WORKSPACE --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  position: relative;
  background-color: var(--bg-primary);
}

/* No Channel selected view */
.no-channel-state {
  flex: 1;
  height: 100%;
  flex-direction: column;
  padding: 24px;
}

.empty-state-card {
  max-width: 360px;
  flex-direction: column;
  text-align: center;
  padding: 40px 24px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  animation: scaleIn 0.3s ease-out;
}

.empty-icon-circle {
  width: 80px;
  height: 80px;
  background-color: var(--bg-primary);
  border-radius: var(--radius-full);
  margin-bottom: 20px;
  color: var(--text-muted);
}

.empty-state-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state-card p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.primary-btn {
  height: 40px;
  padding: 0 18px;
  background-color: var(--brand-color);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 10px var(--brand-glow);
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}
.primary-btn:hover {
  background-color: var(--brand-hover);
}
.primary-btn:active {
  transform: scale(0.97);
}

/* Chat Screen Layout */
.chat-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  position: relative;
}

/* Header */
.chat-header {
  height: 64px;
  min-height: 64px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.channel-emoji {
  font-size: 20px;
}

.channel-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.channel-meta h2 {
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-meta p {
  font-size: 11px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Messages area */
.messages-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
}

.messages-list-wrapper {
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* Date Divider */
.date-divider {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 24px 0;
  padding: 0 24px;
  pointer-events: none;
}

.date-divider-line {
  flex: 1;
  border-top: 1px solid var(--border-color);
}

.date-divider-label {
  padding: 6px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  margin: 0 16px;
  white-space: nowrap;
}

/* ==========================================================================
   3. MESSAGE BUBBLES & PREVIEWS
   ========================================================================== */
.message-row {
  display: flex;
  width: 100%;
  padding: 0 24px;
  margin-bottom: 24px;
  animation: slideUpIn 0.3s ease-out;
}

.message-bubble-container {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 48px);
  width: fit-content;
}

.message-bubble {
  padding: 16px;
  border-radius: var(--radius-lg);
  border-top-left-radius: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.message-bubble.pinned {
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
}

/* Pin indicator */
.pin-indicator-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background-color: var(--bg-card);
  border: 1px solid var(--warning-border);
  color: var(--warning-color);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.pin-indicator-icon svg {
  transform: rotate(45deg);
}

.message-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  word-break: break-word;
  white-space: pre-wrap;
}

.message-text.has-pin {
  padding-right: 24px;
}

/* Link Preview Cards */
.preview-card {
  display: flex;
  margin-top: 16px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
  max-width: 580px;
}
.preview-card:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-hover);
  text-decoration: none;
}

.preview-media-container {
  width: 120px;
  height: 100px;
  flex-shrink: 0;
  background-color: var(--bg-hover);
  border-right: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.preview-media-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-video-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-button-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  padding-left: 3px;
  color: #000;
}

.preview-fallback-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-color);
}

.preview-info {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.preview-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-description {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-site {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.8;
}

.preview-favicon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  object-fit: cover;
}

.preview-site-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: lowercase;
}

/* Image attachment preview */
.image-attachment-preview {
  display: block;
  margin-top: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  max-width: min(360px, 100%);
  background-color: var(--bg-primary);
}
.image-attachment-preview img {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: contain;
  display: block;
}

/* Video attachment preview */
.video-attachment-preview {
  margin-top: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  max-width: min(400px, 100%);
  background-color: #000;
}
.video-attachment-preview video {
  width: 100%;
  height: auto;
  max-height: 300px;
  display: block;
}

/* Message footer containing time/edited tag */
.message-bubble-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.message-time-info {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-hover-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

.msg-action-btn {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background-color: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.msg-action-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-secondary);
}

/* Blockquote formatting inside messages */
.rich-text-content blockquote {
  position: relative;
  border-left: 4px solid var(--brand-color);
  padding: 8px 14px;
  margin: 8px 0;
  font-weight: 500;
  color: var(--text-secondary);
  background: linear-gradient(to right, var(--bg-hover), transparent);
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

/* Loading skeleton layout */
.loading-skeleton-container {
  padding: 24px;
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.skeleton-bubble {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  border-top-left-radius: 0;
  padding: 16px;
  width: 70%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0.7;
  animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-line {
  height: 12px;
  background-color: var(--bg-hover);
  border-radius: var(--radius-full);
}
.skeleton-line.header {
  width: 40%;
  height: 10px;
}
.skeleton-line.body-1 {
  width: 95%;
}
.skeleton-line.body-2 {
  width: 80%;
}

/* Empty channel state */
.empty-channel-bubble {
  max-width: 320px;
  width: 100%;
  margin: 80px auto;
  padding: 40px 24px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  text-align: center;
  flex-direction: column;
  gap: 12px;
}

.empty-channel-icon-wrapper {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background-color: var(--bg-active);
  color: var(--text-active);
  margin: 0 auto 12px;
}

.empty-channel-bubble h4 {
  font-size: 16px;
  font-weight: 700;
}
.empty-channel-bubble p {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ==========================================================================
   4. COMPOSER & EDITING
   ========================================================================== */
.composer-section {
  padding: 16px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  z-index: 10;
}

.composer-container {
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}

.composer-editing-banner {
  position: absolute;
  bottom: 100%;
  left: 16px;
  right: 16px;
  background-color: var(--bg-active);
  border: 1px solid var(--border-active);
  border-bottom: none;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-active);
  font-weight: 600;
  animation: slideUpIn 0.2s ease-out;
}

.cancel-edit-btn {
  background: transparent;
  border: none;
  color: var(--text-active);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  width: 24px;
  height: 24px;
  transition: background-color var(--transition-fast);
}
.cancel-edit-btn:hover {
  background-color: rgba(79, 70, 229, 0.1);
}

.composer-box {
  background-color: var(--bg-composer);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.composer-box:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 4px var(--brand-glow);
  background-color: var(--bg-card);
}

.composer-editable {
  width: 100%;
  min-height: 40px;
  max-height: 200px;
  overflow-y: auto;
  outline: none;
  border: none;
  font-size: 14.5px;
  color: var(--text-primary);
}

/* Custom placeholder logic for contenteditable */
.composer-editable[placeholder]:empty:before {
  content: attr(placeholder);
  color: var(--text-muted);
  cursor: text;
}

.composer-controls {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.control-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.control-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-secondary);
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.keyboard-tip {
  font-size: 10px;
  color: var(--text-muted);
}

.send-btn {
  width: 36px;
  height: 36px;
  background-color: var(--brand-color);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}
.send-btn:hover {
  background-color: var(--brand-hover);
}
.send-btn:active {
  transform: scale(0.95);
}
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   5. POPOVERS & CONTEXT MENUS
   ========================================================================== */
.popover-wrapper {
  position: relative;
}

.popover-content {
  position: absolute;
  top: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  min-width: 160px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.15s ease-out;
}

.popover-content.right-align {
  right: 0;
}

.popover-item {
  height: 34px;
  padding: 0 12px;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.popover-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}
.popover-item.text-red {
  color: var(--danger-color);
}
.popover-item.text-red:hover {
  background-color: var(--danger-bg);
  color: var(--danger-hover);
}

/* Floating Message Context Menu */
.message-popover {
  position: fixed;
  z-index: 1000;
  min-width: 140px;
}

/* ==========================================================================
   6. DIALOG MODAL LAYOUTS
   ========================================================================== */
.modal-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease-out;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-xl);
  z-index: 10;
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.modal-close-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-form input {
  width: 100%;
  height: 40px;
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-size: 14.5px;
  outline: none;
  margin-bottom: 20px;
  transition: border-color var(--transition-fast);
}
.modal-form input:focus {
  border-color: var(--brand-color);
}

.modal-body p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-ghost {
  height: 38px;
  padding: 0 16px;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.btn-ghost:hover {
  background-color: var(--bg-hover);
}

.btn-primary {
  height: 38px;
  padding: 0 16px;
  background-color: var(--brand-color);
  color: white;
  border: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.btn-primary:hover {
  background-color: var(--brand-hover);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-destructive {
  height: 38px;
  padding: 0 16px;
  background-color: var(--danger-color);
  color: white;
  border: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.btn-destructive:hover {
  background-color: var(--danger-hover);
}

/* ==========================================================================
   7. SONNER TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  padding: 12px 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toast-success {
  border-left: 4px solid #10B981;
}

.toast-error {
  border-left: 4px solid var(--danger-color);
  color: var(--danger-color);
}

/* ==========================================================================
   8. RESPONSIVE DESIGN & MOBILE
   ========================================================================== */
.lg-hidden {
  display: none;
}

@media (max-width: 1024px) {
  .lg-hidden {
    display: flex;
  }
  
  .hidden-mobile {
    transform: translateX(-100%);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
  }
  
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 25;
    animation: fadeIn 0.25s ease-out;
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .keyboard-tip {
    display: none;
  }
  
  .msg-hover-actions {
    opacity: 1;
  }
}

/* ==========================================================================
   9. KEYFRAMES & MICRO-ANIMATIONS
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

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

/* Toast animations */
.toast.animate-in {
  animation: toastSlideIn 0.3s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
}

.toast.animate-out {
  animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
  from { transform: translateY(-16px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to { transform: translateY(-16px) scale(0.9); opacity: 0; }
}
