/* G8way Max Futuristic Inbox - Light & Dark Mode */
:root {
  --g8-primary: #667eea;
  --g8-primary-dark: #764ba2;
  --g8-accent: #f093fb;
  --g8-success: #10b981;
  --g8-bg: #ffffff;
  --g8-bg-elevated: #fafafa;
  --g8-bg-hover: #f5f5f5;
  --g8-border: rgba(0,0,0,0.08);
  --g8-border-light: rgba(0,0,0,0.04);
  --g8-text: #1a1a1a;
  --g8-text-secondary: #6b7280;
  --g8-text-muted: #9ca3af;
  --g8-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --g8-shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --g8-radius: 16px;
  --g8-radius-sm: 12px;
  --g8-radius-full: 999px;
}

#g8inbox.dark-mode {
  --g8-bg: #0a0a0a;
  --g8-bg-elevated: #1a1a1a;
  --g8-bg-hover: #2a2a2a;
  --g8-border: rgba(255,255,255,0.1);
  --g8-border-light: rgba(255,255,255,0.05);
  --g8-text: #ffffff;
  --g8-text-secondary: #a1a1aa;
  --g8-text-muted: #71717a;
  --g8-shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -1px rgba(0,0,0,0.2);
  --g8-shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.5), 0 10px 10px -5px rgba(0,0,0,0.3);
}

#g8inbox {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--g8-text);
  background: transparent;
  position: relative;
}

@media (max-width: 768px) {
  #g8inbox {
    padding: 0;
    max-width: 100%;
  }
}

/* Loading Overlay */
.g8loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.3s ease;
}

.g8loading-gif {
  max-width: 90%;
  max-height: 90vh;
  object-fit: contain;
}

/* Connection Banner */
.g8connection-banner {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  padding: 12px 20px;
  border-radius: var(--g8-radius-sm);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--g8-shadow);
  animation: slideDown 0.3s ease-out;
}

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

/* Shell Layout */
.g8shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  height: calc(100vh - 120px);
  min-height: 600px;
}

@media (max-width: 768px) {
  .g8shell {
    grid-template-columns: 1fr;
    gap: 0;
    height: 100vh;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
  }
}

/* Sidebar */
.g8sidebar {
  background: var(--g8-bg);
  border: 1px solid var(--g8-border);
  border-radius: var(--g8-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--g8-shadow);
}

@media (max-width: 768px) {
  .g8sidebar {
    border-radius: 0;
    border: none;
    height: 100vh;
    max-height: 100vh;
  }
}

.g8header {
  padding: 20px;
  border-bottom: 1px solid var(--g8-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  color: white;
}

@media (max-width: 768px) {
  .g8header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
  }
}

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

.g8brand {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.g8muted {
  font-size: 12px;
  opacity: 0.9;
}

.g8small {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.g8status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--g8-success);
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

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

.g8icon-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: all 0.2s;
  flex-shrink: 0;
}

.g8icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: white;
  stroke-width: 2;
}

.g8icon-btn:hover {
  background: rgba(255,255,255,0.35);
  transform: scale(1.08);
}

.g8icon-btn:active {
  transform: scale(0.95);
}

/* Search Bar */
.g8search-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid var(--g8-border-light);
  background: var(--g8-bg-elevated);
  display: flex;
  gap: 8px;
  align-items: center;
}

.g8search-input {
  flex: 1;
  border: 1px solid var(--g8-border);
  border-radius: var(--g8-radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--g8-text);
  background: var(--g8-bg);
  outline: none;
  transition: all 0.2s;
}

.g8search-input:focus {
  border-color: var(--g8-primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

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

.g8search-close {
  background: transparent;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--g8-text-secondary);
  font-size: 16px;
  transition: all 0.2s;
}

.g8search-close:hover {
  background: var(--g8-bg-hover);
  color: var(--g8-text);
}

/* Threads List */
.g8threads {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  .g8threads {
    -webkit-overflow-scrolling: touch;
  }
}

.g8threads::-webkit-scrollbar {
  width: 6px;
}

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

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

.g8thread-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--g8-border-light);
  transition: all 0.2s;
  position: relative;
  min-height: 76px;
  max-height: 76px;
  align-items: center;
}

.g8thread-item:hover {
  background: var(--g8-bg-hover);
}

.g8thread-item.active {
  background: linear-gradient(90deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.05) 100%);
  border-left: 3px solid var(--g8-primary);
}

.g8thread-item.unread {
  font-weight: 600;
}

.g8thread-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

.g8thread-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.g8thread-avatar-fallback {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

/* Special G8way branded logo style */
.g8thread-avatar-fallback.g8-logo-style {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -1px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

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

.g8thread-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.g8thread-name-small {
  font-size: 14px;
  font-weight: 600;
  color: var(--g8-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g8thread-time {
  font-size: 11px;
  color: var(--g8-text-muted);
  flex-shrink: 0;
  margin-left: 8px;
}

.g8thread-preview {
  font-size: 13px;
  color: var(--g8-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Chat Area */
.g8main {
  background: var(--g8-bg);
  border: 1px solid var(--g8-border);
  border-radius: var(--g8-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--g8-shadow);
  position: relative;
}

@media (max-width: 768px) {
  .g8main {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    border: none;
    z-index: 1001;
    display: none;
  }
  
  .g8main.active {
    display: flex;
  }
}

.g8scroll-to-bottom {
  position: absolute;
  bottom: 90px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--g8-border);
  box-shadow: var(--g8-shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
  color: var(--g8-primary);
}

.g8scroll-to-bottom svg {
  flex-shrink: 0;
}

.g8scroll-to-bottom:hover {
  background: var(--g8-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(102,126,234,0.3);
}

.g8chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--g8-border-light);
  background: var(--g8-bg-elevated);
  display: flex;
  align-items: center;
  gap: 0;
}

@media (max-width: 768px) {
  .g8chat-header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    justify-content: center;
  }
}

.g8chat-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.g8thread-avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.g8thread-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.g8avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

/* Ensure all avatars stay circular */
.g8thread-avatar, .g8thread-avatar-wrap, [id*="Avatar"] {
  border-radius: 50% !important;
}

.g8thread-avatar img, .g8msg-avatar, .g8msg-avatar img,
.g8thread-avatar-img, [id*="Avatar"] img {
  width: 100%;
  height: 100%;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block !important;
}

.g8thread-name-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.g8thread-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--g8-text);
}

.g8thread-arrow {
  display: none;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .g8thread-arrow {
    display: block;
  }
}

.g8thread-status {
  font-size: 12px;
  color: var(--g8-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Messages Area */
.g8messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--g8-bg-elevated);
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(102,126,234,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(118,75,162,0.03) 0%, transparent 50%);
}

@media (max-width: 768px) {
  .g8messages {
    padding: 16px;
    padding-bottom: 24px;
  }
}

.g8messages::-webkit-scrollbar {
  width: 8px;
}

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

.g8messages::-webkit-scrollbar-thumb {
  background: var(--g8-border);
  border-radius: 4px;
}

.g8date-separator {
  text-align: center;
  margin: 24px 0;
  position: relative;
}

.g8date-separator::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--g8-border-light);
}

.g8date-separator span {
  background: var(--g8-bg-elevated);
  padding: 4px 16px;
  font-size: 12px;
  color: var(--g8-text-muted);
  font-weight: 600;
  position: relative;
  z-index: 1;
  border-radius: var(--g8-radius-full);
}

.g8message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  max-width: 75%;
}

.g8message.me {
  margin-left: auto;
  flex-direction: row-reverse;
}

.g8msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.g8msg-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.g8msg-avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

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

.g8message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--g8-text-secondary);
  margin-bottom: 4px;
}

.g8message-bubble {
  background: var(--g8-bg);
  border: 1px solid var(--g8-border);
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.2s;
  position: relative;
}

.g8message-bubble:hover .g8message-actions {
  opacity: 1;
  visibility: visible;
}

.g8message.me .g8message-bubble {
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  color: white;
  border: none;
}

.g8message-actions {
  position: absolute;
  top: -12px;
  right: 12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.g8message.me .g8message-actions {
  right: auto;
  left: 12px;
}

.g8msg-action-btn {
  background: var(--g8-bg);
  border: 1px solid var(--g8-border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--g8-shadow);
  color: var(--g8-text-secondary);
}

.g8msg-action-btn:hover {
  background: var(--g8-primary);
  border-color: var(--g8-primary);
  color: white;
  transform: scale(1.1);
}

.g8msg-action-btn:hover svg {
  stroke: white !important;
}

.g8msg-action-btn svg {
  stroke: currentColor;
  fill: none;
  width: 14px;
  height: 14px;
}

.g8reaction-popup {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  font-size: 32px;
  animation: reactionPop 2s ease-out forwards;
  pointer-events: none;
}

@keyframes reactionPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(0) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translateX(-50%) translateY(-8px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-40px) scale(1);
  }
}

/* Emoji Picker Popup */
.g8emoji-picker {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--g8-bg);
  border: 2px solid var(--g8-primary);
  border-radius: var(--g8-radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: emojiPickerSlide 0.2s ease-out;
  max-width: calc(100vw - 32px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .g8emoji-picker {
    max-width: calc(100vw - 32px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    justify-content: center;
  }
}

#g8inbox.dark-mode .g8emoji-picker {
  background: var(--g8-bg-elevated);
  border-color: var(--g8-primary);
}

@keyframes emojiPickerSlide {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

.g8emoji-option {
  background: #ffffff;
  border: 2px solid #e5e7eb;
  font-size: 32px;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}

#g8inbox.dark-mode .g8emoji-option {
  background: #2a2a2a;
  border-color: #444;
}

.g8emoji-option:hover {
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  border-color: var(--g8-primary);
  transform: scale(1.25);
  box-shadow: 0 6px 16px rgba(102,126,234,0.6);
}

#g8inbox.dark-mode .g8emoji-option:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 6px 16px rgba(102,126,234,0.8);
}

.g8emoji-option.selected {
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  border-color: var(--g8-primary);
  transform: scale(1.25);
  box-shadow: 0 6px 16px rgba(102,126,234,0.6);
}

#g8inbox.dark-mode .g8emoji-option.selected {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 6px 16px rgba(102,126,234,0.8);
}

.g8emoji-option:active {
  transform: scale(1.05);
}

/* Permanent Reaction Badge */
.g8reaction-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--g8-bg);
  border: 2px solid var(--g8-primary);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--g8-shadow);
  z-index: 10;
  cursor: pointer;
  transition: all 0.2s;
}

.g8reaction-badge:hover {
  transform: scale(1.15);
  box-shadow: var(--g8-shadow-lg);
}

.g8message-text {
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.g8message-attachment {
  margin-bottom: 8px;
}

.g8message-image {
  max-width: 400px;
  max-height: 400px;
  border-radius: 12px;
  display: block;
  cursor: pointer;
  transition: transform 0.2s;
  object-fit: contain;
}

@media (max-width: 768px) {
  .g8message-image {
    max-width: 280px;
    max-height: 280px;
  }
}

.g8message-image:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.g8file-attachment {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--g8-bg-elevated);
  border: 1px solid var(--g8-border);
  border-radius: 10px;
  transition: all 0.2s;
}

.g8file-attachment:hover {
  background: var(--g8-bg-hover);
}

.g8file-attachment svg {
  color: var(--g8-text-secondary);
  flex-shrink: 0;
}

.g8file-info {
  flex: 1;
  min-width: 0;
}

.g8file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--g8-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g8file-size {
  font-size: 11px;
  color: var(--g8-text-muted);
  margin-top: 2px;
}

.g8file-download {
  background: var(--g8-primary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  color: white;
}

.g8file-download:hover {
  background: var(--g8-primary-dark);
  transform: scale(1.1);
}

.g8file-download svg {
  stroke: white;
}

.g8message.me .g8file-attachment {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.g8message.me .g8file-name {
  color: white;
}

.g8message.me .g8file-size {
  color: rgba(255,255,255,0.7);
}

.g8message-link {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
  transition: opacity 0.2s;
}

.g8message-link:hover {
  opacity: 0.8;
}

.g8message.me .g8message-link {
  color: white;
  text-decoration-color: rgba(255,255,255,0.6);
}

.g8message-time {
  font-size: 11px;
  color: var(--g8-text-muted);
  margin-top: 4px;
}

.g8message.me .g8message-time {
  text-align: right;
  color: rgba(255,255,255,0.7);
}

/* Typing Indicator */
.g8typing-indicator {
  display: flex;
  gap: 12px;
  padding: 0 24px 12px;
  align-items: center;
}

.g8typing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  opacity: 0.3;
  flex-shrink: 0;
}

.g8typing-bubble {
  background: var(--g8-bg);
  border: 1px solid var(--g8-border);
  border-radius: 18px;
  padding: 12px 16px;
}

.g8typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.g8typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--g8-text-muted);
  animation: typingBounce 1.4s infinite;
}

.g8typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.g8typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Composer */
.g8composer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--g8-border-light);
  background: var(--g8-bg);
}

@media (max-width: 768px) {
  .g8composer {
    padding: 12px 16px;
    position: sticky;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
  }
}

.g8composer-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  position: relative;
}

.g8file-btn {
  background: var(--g8-bg-elevated);
  border: 1px solid var(--g8-border);
  border-radius: var(--g8-radius-sm);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--g8-text-secondary);
  flex-shrink: 0;
  padding: 0;
}

.g8file-btn:hover {
  background: var(--g8-primary);
  color: white;
  border-color: var(--g8-primary);
  transform: translateY(-1px);
}

.g8file-btn svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.5;
}

.g8file-preview {
  padding: 12px;
  background: var(--g8-bg-elevated);
  border: 1px solid var(--g8-border);
  border-radius: var(--g8-radius-sm);
}

.g8file-preview-item {
  display: flex;
  gap: 12px;
  align-items: center;
}

.g8file-preview-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
}

.g8file-preview-icon {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--g8-bg);
  border-radius: 8px;
  color: var(--g8-text-secondary);
}

.g8file-preview-info {
  flex: 1;
  min-width: 0;
}

.g8file-preview-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--g8-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g8file-preview-size {
  font-size: 12px;
  color: var(--g8-text-muted);
}

.g8file-preview-remove {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #ef4444;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.g8file-preview-remove svg {
  width: 18px;
  height: 18px;
  stroke: #ef4444;
  stroke-width: 2.5;
}

.g8file-preview-remove:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
}

.g8file-preview-remove:hover svg {
  stroke: white;
}

.g8composer-hint {
  position: absolute;
  bottom: 4px;
  left: 24px;
  font-size: 10px;
  color: var(--g8-text-muted);
  opacity: 0;
  transition: opacity 0.2s;
}

.g8input:focus ~ .g8composer-hint {
  opacity: 1;
}

.g8input {
  flex: 1;
  border: 1px solid var(--g8-border);
  border-radius: var(--g8-radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--g8-text);
  background: var(--g8-bg-elevated);
  transition: all 0.2s;
  outline: none;
}

@media (max-width: 768px) {
  .g8input {
    font-size: 16px;
    padding: 12px 14px;
  }
}

.g8input:focus {
  border-color: var(--g8-primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.g8input::placeholder {
  color: var(--g8-text-muted);
}

#g8inbox.dark-mode .g8input {
  color: #ffffff;
  background: #1a1a1a;
}

.g8send-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--g8-primary) 0%, var(--g8-primary-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--g8-radius-sm);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(102,126,234,0.3);
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .g8send-btn {
    padding: 12px 20px;
    min-width: 48px;
  }
}

.g8send-btn svg {
  stroke: white !important;
  fill: none !important;
  width: 20px;
  height: 20px;
}

.g8send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(102,126,234,0.4);
}

.g8send-btn:active:not(:disabled) {
  transform: translateY(0);
}

.g8send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Empty States */
.g8empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--g8-text-secondary);
}

.g8empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.g8empty div:last-child {
  font-size: 14px;
  font-weight: 500;
}

.g8empty.g8error {
  color: #ef4444;
}

/* Loading State */
.g8loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.g8spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--g8-border);
  border-top-color: var(--g8-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* System Messages */
.g8system-msg {
  text-align: center;
  font-size: 13px;
  color: var(--g8-text-muted);
  padding: 8px 16px;
  margin: 16px auto;
  max-width: 80%;
  background: var(--g8-bg-hover);
  border-radius: var(--g8-radius-sm);
}

.g8system-msg.g8error {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}

/* Skeleton Loading */
.g8skeleton {
  background: linear-gradient(90deg, var(--g8-bg-hover) 25%, var(--g8-bg-elevated) 50%, var(--g8-bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.g8skeleton-thread {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--g8-border-light);
}

.g8skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--g8-bg-hover);
}

.g8skeleton-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.g8skeleton-line {
  height: 12px;
  background: var(--g8-bg-hover);
  border-radius: 6px;
}

.g8skeleton-line.short {
  width: 60%;
}

.g8skeleton-line.long {
  width: 85%;
}

/* Enhanced tooltips */
.g8tooltip {
  position: relative;
}

.g8tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: var(--g8-text);
  color: var(--g8-bg);
  font-size: 11px;
  white-space: nowrap;
  border-radius: 6px;
  margin-bottom: 8px;
  z-index: 1000;
  pointer-events: none;
  animation: fadeIn 0.2s;
}

/* Responsive */
@media (max-width: 1024px) {\n  .g8shell {
    grid-template-columns: 320px 1fr;
  }
}

@media (max-width: 768px) {
  .g8brand {
    font-size: 16px;
  }
  
  .g8message {
    max-width: 90%;
  }
  
  .g8send-btn span {
    display: none;
  }
  
  .g8thread-preview {
    font-size: 13px;
  }
  
  .g8thread-item {
    padding: 14px 16px;
  }
  
  .g8chat-info {
    flex: 1;
  }
  
  .g8thread-name {
    font-size: 16px;
  }
  
  .g8back-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.3) !important;
    border: 2px solid rgba(0, 0, 0, 0.4) !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    margin-right: 12px !important;
    flex-shrink: 0 !important;
    color: #000000 !important;
    z-index: 1000 !important;
    position: relative !important;
  }
  
  #g8inbox.dark-mode .g8back-btn {
    background: rgba(255, 255, 255, 0.3) !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    color: #ffffff !important;
  }
  
  .g8back-btn:hover {
    background: rgba(0, 0, 0, 0.4) !important;
    transform: scale(1.05) !important;
  }
  
  #g8inbox.dark-mode .g8back-btn:hover {
    background: rgba(255, 255, 255, 0.4) !important;
  }
  
  .g8back-btn svg {
    width: 26px !important;
    height: 26px !important;
    stroke: currentColor !important;
    fill: none !important;
    position: relative !important;
    z-index: 1001 !important;
  }
}

/* Animations */
.g8thread-item,
.g8message {
  animation: fadeIn 0.3s ease-out;
}

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

