/* Nexus panel — admin-only slide-in chat */

#nexus-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 640px;
  max-width: 100vw;
  height: 100vh;
  background: #0f0f1a;
  color: #e5e7eb;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 0.25s ease, width 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#nexus-panel.nexus-open {
  transform: translateX(0);
}
/* Width modes — cycled by the ⤢ button (normal → wide → full) */
#nexus-panel.nexus-w-wide { width: 980px; }
#nexus-panel.nexus-w-full { width: 95vw; }
@media (max-width: 600px) {
  #nexus-panel,
  #nexus-panel.nexus-w-wide,
  #nexus-panel.nexus-w-full { width: 100vw; }
}

/* Header */
#nexus-header {
  flex-shrink: 0;
  padding: 12px 16px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  gap: 10px;
}
#nexus-header .nx-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
#nexus-header .nx-dot {
  width: 8px; height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: nx-pulse 2s infinite;
}
@keyframes nx-pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#nexus-header button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
#nexus-header button:hover { background: rgba(255,255,255,0.25); }

/* Body */
#nexus-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

#nexus-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #12122a;
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow-y: auto;
  padding: 6px;
  transition: width 0.2s ease, padding 0.2s ease;
}
#nexus-sidebar.nx-sidebar-collapsed {
  width: 32px;
  padding: 6px 2px;
  overflow: hidden;
}
#nexus-sidebar.nx-sidebar-collapsed #nexus-history,
#nexus-sidebar.nx-sidebar-collapsed #nexus-sidebar-title { display: none; }
#nexus-sidebar.nx-sidebar-collapsed #nexus-sidebar-toggle { margin: 0 auto; }
#nexus-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 4px 4px;
}
#nexus-sidebar-title {
  padding: 4px 4px;
  font-size: 10px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.08em;
}
#nexus-sidebar-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}
#nexus-sidebar-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; }
#nexus-history { display: flex; flex-direction: column; gap: 2px; }
.nx-history-item {
  padding: 6px 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nx-history-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nx-history-item.active { background: rgba(79,70,229,0.25); color: #c7d2fe; }

#nexus-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#nexus-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#nexus-messages::-webkit-scrollbar { width: 6px; }
#nexus-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.nx-msg {
  display: flex;
  flex-direction: column;
}
.nx-msg-user {
  align-self: flex-end;
  max-width: 85%;
}
.nx-msg-assistant {
  align-self: stretch;
  width: 100%;
}

.nx-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
}
.nx-msg-user .nx-bubble {
  background: #4f46e5;
  color: #fff;
}
.nx-msg-assistant .nx-bubble {
  background: #1a1a2e;
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.05);
}
.nx-bubble p { margin: 0 0 8px 0; }
.nx-bubble p:last-child { margin-bottom: 0; }
.nx-bubble code { background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 3px; font-size: 12px; font-family: 'SF Mono', Menlo, monospace; }
.nx-bubble h2, .nx-bubble h3, .nx-bubble h4 { color: #c7d2fe; margin: 10px 0 4px 0; }
.nx-bubble strong { color: #fff; }
.nx-bubble ul { padding-left: 18px; margin: 4px 0; }

.nx-table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 12px;
}
.nx-table th, .nx-table td {
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,0.08);
  text-align: left;
}
.nx-table th { background: rgba(79,70,229,0.15); color: #c7d2fe; }

.nx-thinking { color: rgba(255,255,255,0.5); font-style: italic; }
.nx-dots::after { content: ''; display: inline-block; width: 14px; text-align: left; animation: nx-dot 1.3s infinite; }
@keyframes nx-dot {
  0%   { content: '.'; }
  33%  { content: '..'; }
  66%  { content: '...'; }
}

.nx-status {
  margin-top: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  font-style: italic;
}

.nx-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.nx-followup {
  background: rgba(79,70,229,0.15);
  border: 1px solid rgba(79,70,229,0.35);
  color: #a5b4fc;
  font-size: 11.5px;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.nx-followup:hover {
  background: rgba(79,70,229,0.3);
  color: #c7d2fe;
}

/* Composer */
#nexus-composer {
  flex-shrink: 0;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0a0a18;
}
#nexus-composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#nexus-attach {
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.08);
  color: #c7d2fe;
  padding: 0 10px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
#nexus-attach:hover { background: #232342; }
#nexus-attach:disabled { opacity: 0.5; cursor: wait; }
#nexus-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#nexus-attachments:empty { display: none; }
.nx-attach-chip {
  background: rgba(79,70,229,0.2);
  border: 1px solid rgba(79,70,229,0.4);
  color: #c7d2fe;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
}
.nx-attach-chip .nx-attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nx-attach-chip .nx-attach-remove {
  background: transparent;
  border: none;
  color: #c7d2fe;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}
.nx-attach-chip.nx-attach-uploading { opacity: 0.6; }
.nx-attach-chip.nx-attach-error {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.5);
  color: #fecaca;
}
/* User message attachment indicator */
.nx-msg-attachments {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.8;
  font-style: italic;
}
#nexus-input {
  flex: 1;
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  font-family: inherit;
  outline: none;
  min-height: 44px;
  max-height: 200px;
}
#nexus-input:focus {
  border-color: rgba(79,70,229,0.6);
}
#nexus-send {
  background: #4f46e5;
  border: none;
  color: #fff;
  padding: 0 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
}
#nexus-send:hover { background: #6366f1; }
#nexus-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Sidebar trigger badge */
.nx-sidebar-badge {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}
