/* ============================================
   NEXUSAI — Chat Interface Styles
   ============================================ */

.chat-body {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ============ SIDEBAR ============ */
.chat-sidebar {
  width: 280px;
  min-width: 280px;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  z-index: 100;
}

.chat-sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

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

.sidebar-logo { font-size: 1.1rem; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.sidebar-toggle:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 4px;
  padding: 10px 16px;
  background: rgba(124,77,255,0.12);
  border: 1px solid rgba(124,77,255,0.25);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.new-chat-btn:hover { background: rgba(124,77,255,0.2); border-color: var(--accent); }

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

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 4px;
  margin-bottom: 8px;
}

/* Model Selector */
.model-selector { position: relative; }

.selected-model {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.88rem;
  font-weight: 600;
}
.selected-model:hover { border-color: var(--border-bright); }

.sel-model-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sel-arrow {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.model-selector.open .sel-arrow { transform: rotate(180deg); }

.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  overflow-y: auto;
  max-height: 320px;
  z-index: 200;
  display: none;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.model-selector.open .model-dropdown { display: block; }

.dropdown-group-label {
  padding: 10px 14px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-secondary);
}
.dropdown-item:hover { background: rgba(124,77,255,0.1); color: var(--text-primary); }
.dropdown-item.selected-item { background: rgba(124,77,255,0.15); color: var(--text-primary); }

.di-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.di-tag {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 6px;
  border-radius: 4px;
}
.admin-tag {
  background: rgba(255,64,129,0.15);
  color: #ff4081;
  border: 1px solid rgba(255,64,129,0.3);
}

/* History */
.history-list { display: flex; flex-direction: column; gap: 2px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.active-history { background: rgba(124,77,255,0.1); color: var(--text-primary); }
.history-item svg { flex-shrink: 0; color: var(--text-muted); }

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar-footer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.sidebar-footer-btn:hover { color: var(--text-primary); border-color: var(--border-bright); background: rgba(124,77,255,0.08); }

/* ============ MAIN CHAT ============ */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* Top Bar */
.chat-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(8,8,16,0.8);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  z-index: 10;
}

.topbar-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}
.topbar-menu-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.topbar-model-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.topbar-model-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gradient-main);
  flex-shrink: 0;
}
.topbar-model-info span:first-of-type {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}
.topbar-model-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400 !important;
}

.topbar-actions { display: flex; gap: 4px; }
.topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.topbar-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

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

/* Welcome Screen */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  flex: 1;
  animation: fadeInUp 0.5s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.welcome-icon {
  font-size: 3rem;
  margin-bottom: 20px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.chat-welcome h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.chat-welcome p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}
.chat-welcome strong { color: var(--accent); }

.welcome-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 600px;
  width: 100%;
}
.suggestion-chip {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  line-height: 1.4;
}
.suggestion-chip:hover {
  border-color: var(--border-bright);
  color: var(--text-primary);
  background: rgba(124,77,255,0.08);
  transform: translateY(-2px);
}

/* Message Rows */
.message-row {
  padding: 16px 24px;
  display: flex;
  gap: 16px;
  animation: msgSlideIn 0.3s ease;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.user-row { flex-direction: row-reverse; }

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.user-avatar { background: var(--gradient-main); color: white; }
.ai-msg-avatar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 1rem;
}

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

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}
.msg-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.msg-model-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(124,77,255,0.15);
  color: var(--accent);
  border: 1px solid rgba(124,77,255,0.2);
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.7;
  max-width: 100%;
  word-wrap: break-word;
}
.user-bubble {
  background: rgba(124,77,255,0.15);
  border: 1px solid rgba(124,77,255,0.25);
  border-radius: 16px 4px 16px 16px;
  color: var(--text-primary);
  max-width: 75%;
  margin-left: auto;
}
.ai-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  color: var(--text-secondary);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  width: fit-content;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.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); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Code blocks in messages */
.msg-bubble pre {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 0.82rem;
  line-height: 1.6;
}
.msg-bubble code {
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  background: rgba(124,77,255,0.1);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--accent-2);
}
.msg-bubble pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
}

/* Message actions */
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}
.message-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}
.msg-action-btn:hover { color: var(--text-primary); border-color: var(--border-bright); background: rgba(255,255,255,0.04); }

/* ============ INPUT AREA ============ */
.chat-input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.input-wrapper { max-width: 900px; margin: 0 auto; }

.input-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 14px 10px;
  transition: border-color 0.2s;
  position: relative;
}
.input-box:focus-within { border-color: var(--border-bright); box-shadow: 0 0 0 3px rgba(124,77,255,0.1); }

.input-box textarea {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: none;
  min-height: 24px;
  max-height: 200px;
  overflow-y: auto;
  padding: 0;
}
.input-box textarea::placeholder { color: var(--text-muted); }

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.input-left-actions { display: flex; align-items: center; gap: 8px; }

.input-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.input-action-btn:hover { color: var(--text-primary); border-color: var(--border-bright); }

.char-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--gradient-main);
  border: none;
  color: white;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }
.send-btn:not(:disabled):hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(124,77,255,0.4); }

.input-footer-note {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ============ ADMIN FLOAT BADGE ============ */
.admin-badge-float {
  position: fixed;
  bottom: 100px;
  right: 24px;
  padding: 8px 16px;
  background: rgba(255,64,129,0.15);
  border: 1px solid rgba(255,64,129,0.4);
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ff4081;
  z-index: 500;
  animation: floatBadge 3s ease-in-out infinite;
}
@keyframes floatBadge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .chat-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 200;
  }
  .chat-sidebar.mobile-open {
    transform: translateX(0);
  }
  .chat-sidebar.collapsed {
    width: 280px;
    min-width: 280px;
  }
  .welcome-suggestions { grid-template-columns: 1fr; }
  .message-row { padding: 12px 16px; }
  .chat-input-area { padding: 12px 16px 16px; }
}

@media (max-width: 480px) {
  .chat-welcome h2 { font-size: 1.4rem; }
  .topbar-model-sub { display: none; }
}