/* ============================================
   ARYBIT CORE™ — AI NODE DASHBOARD
   Production v1.0.0 — Arybit Technologies
   ============================================ */

:root {
  /* Brand */
  --brand:         #32062e;
  --brand-mid:     #4d0850;
  --brand-light:   #6b1068;
  --brand-glow:    rgba(50, 6, 46, 0.5);

  /* Backgrounds */
  --bg-root:       #0b0f1a;
  --bg-dark:       #0f1422;
  --bg-surface:    #141929;
  --bg-raised:     #1a2035;
  --bg-hover:      #1f2842;

  /* Borders */
  --border:        rgba(255,255,255,0.07);
  --border-mid:    rgba(255,255,255,0.12);
  --border-brand:  rgba(107,16,104,0.4);

  /* Text */
  --text-primary:  #eef0f6;
  --text-secondary:#8a90a8;
  --text-muted:    #5a6278;
  --text-brand:    #c084fc;

  /* Status */
  --ok:            #22c55e;
  --ok-bg:         rgba(34,197,94,0.1);
  --warn:          #f59e0b;
  --warn-bg:       rgba(245,158,11,0.1);
  --bad:           #ef4444;
  --bad-bg:        rgba(239,68,68,0.1);
  --info:          #60a5fa;
  --info-bg:       rgba(96,165,250,0.1);

  /* Sizing */
  --sidebar-w:     280px;
  --header-h:      56px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;
  --radius-xl:     20px;

  /* Fonts */
  --font-display:  'Syne', sans-serif;
  --font-body:     'DM Sans', sans-serif;

  /* Transitions */
  --t-fast:        0.15s ease;
  --t-mid:         0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; scroll-behavior: smooth; }

body {
  height: 100%;
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ───────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── LAYOUT ──────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
}

/* ── HEADER ──────────────────────────────── */
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: var(--brand);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--brand-glow);
}

.brand-logo svg { width: 18px; height: 18px; }

.brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.brand-name sup {
  font-size: 9px;
  color: var(--text-muted);
  vertical-align: super;
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: 0;
}

.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--ok-bg);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 20px;
  font-size: 11px;
  color: var(--ok);
  font-weight: 500;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
}

.header-btn:hover {
  background: var(--bg-raised);
  border-color: var(--border-mid);
  color: var(--text-primary);
}

.header-btn.primary {
  background: var(--brand);
  border-color: var(--brand-mid);
  color: #fff;
}

.header-btn.primary:hover {
  background: var(--brand-mid);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-mid);
  border: 1.5px solid var(--border-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: border-color var(--t-fast);
}

.user-avatar:hover { border-color: var(--brand-light); }

/* ── SIDEBAR ─────────────────────────────── */
.app-sidebar {
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child { border-bottom: none; flex: 1; overflow-y: auto; }

.section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Status indicators */
.status-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast);
}

.status-row:hover { border-color: var(--border-mid); }

.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.status-icon.ok   { background: var(--ok-bg);   color: var(--ok); }
.status-icon.bad  { background: var(--bad-bg);  color: var(--bad); }
.status-icon.warn { background: var(--warn-bg); color: var(--warn); }
.status-icon.info { background: var(--info-bg); color: var(--info); }

.status-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
}

.status-badge.ok   { color: var(--ok);   background: var(--ok-bg);   }
.status-badge.bad  { color: var(--bad);  background: var(--bad-bg);  }
.status-badge.warn { color: var(--warn); background: var(--warn-bg); }
.status-badge.muted { color: var(--text-muted); background: var(--bg-raised); }

/* Metrics row */
.metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.metric-value.ok   { color: var(--ok); }
.metric-value.warn { color: var(--warn); }
.metric-value.info { color: var(--info); }

.metric-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Model selector */
.model-select-wrap {
  position: relative;
}

.model-select-wrap::after {
  content: '\F282';
  font-family: 'bootstrap-icons';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}

select#modelSelect {
  width: 100%;
  padding: 9px 32px 9px 12px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--t-fast);
}

select#modelSelect:focus { border-color: var(--brand-light); }
select#modelSelect:hover { border-color: var(--border-mid); }

.endpoint-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.endpoint-info i { font-size: 10px; color: var(--text-muted); }

.endpoint-url {
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
  letter-spacing: -0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Conversation list */
.conv-list { display: flex; flex-direction: column; gap: 4px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t-fast);
  border: 1px solid transparent;
}

.conv-item:hover { background: var(--bg-raised); border-color: var(--border); }
.conv-item.active { background: var(--brand-glow); border-color: var(--border-brand); }

.conv-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-muted);
  flex-shrink: 0;
}

.conv-item.active .conv-icon { background: var(--brand); color: #fff; }

.conv-text { flex: 1; overflow: hidden; }
.conv-title { font-size: 12px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta  { font-size: 10px; color: var(--text-muted); }

/* ── MAIN CHAT AREA ──────────────────────── */
.app-main {
  display: flex;
  flex-direction: column;
  background: var(--bg-root);
  overflow: hidden;
}

/* Chat topbar */
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-subtitle { font-size: 11px; color: var(--text-muted); }

.topbar-chips { display: flex; gap: 6px; }

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-secondary);
}

.chip i { font-size: 10px; }

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Welcome state */
.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  gap: 20px;
}

.welcome-icon {
  width: 64px; height: 64px;
  background: var(--brand);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  border: 1px solid var(--brand-mid);
  box-shadow: 0 0 40px var(--brand-glow);
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.welcome-sub { font-size: 13px; color: var(--text-secondary); max-width: 400px; line-height: 1.7; }

.suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  margin-top: 8px;
}

.suggestion-btn {
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all var(--t-fast);
  line-height: 1.4;
}

.suggestion-btn:hover {
  background: var(--bg-raised);
  border-color: var(--border-brand);
  color: var(--text-primary);
}

.suggestion-btn i { display: block; font-size: 16px; margin-bottom: 6px; color: var(--text-brand); }

/* Message bubbles */
.msg-group { display: flex; gap: 10px; align-items: flex-end; animation: msgIn 0.2s ease; }
.msg-group.user { flex-direction: row-reverse; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}

.msg-avatar.ai   { background: var(--brand); border: 1.5px solid var(--brand-mid); color: #fff; }
.msg-avatar.user { background: var(--info-bg); border: 1.5px solid rgba(96,165,250,0.3); color: var(--info); }

.msg-content { max-width: 72%; display: flex; flex-direction: column; gap: 4px; }

.msg-bubble {
  padding: 11px 15px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-group.ai   .msg-bubble { background: var(--bg-raised); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-group.user .msg-bubble { background: var(--brand); border: 1px solid var(--brand-mid); border-bottom-right-radius: 4px; color: #fff; align-self: flex-end; }

.msg-meta { font-size: 10px; color: var(--text-muted); padding: 0 4px; }
.msg-group.user .msg-meta { text-align: right; }

/* Typing indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
}

.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* Input area */
.input-area {
  padding: 16px 24px 20px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.tool-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--t-fast);
}

.tool-btn:hover { background: var(--bg-raised); color: var(--text-secondary); border-color: var(--border-mid); }
.tool-btn i { font-size: 12px; }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  transition: border-color var(--t-fast);
}

.input-row:focus-within { border-color: var(--brand-light); }

textarea#prompt {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 22px;
  max-height: 160px;
  overflow-y: auto;
}

textarea#prompt::placeholder { color: var(--text-muted); }

.send-btn {
  width: 36px; height: 36px;
  background: var(--brand);
  border: 1px solid var(--brand-mid);
  border-radius: var(--radius-md);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
  font-size: 14px;
}

.send-btn:hover:not(:disabled) { background: var(--brand-mid); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}

.input-hint { font-size: 11px; color: var(--text-muted); }

.char-counter { font-size: 11px; color: var(--text-muted); }

/* Status bar */
.status-bar {
  font-size: 11px;
  color: var(--text-muted);
  min-height: 16px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-bar.error { color: var(--bad); }
.status-bar.loading { color: var(--info); }

.status-spinner {
  width: 10px; height: 10px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── NOTIFICATIONS / TOASTS ──────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
  min-width: 260px;
  max-width: 340px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast.ok   i { color: var(--ok); }
.toast.bad  i { color: var(--bad); }
.toast.info i { color: var(--info); }

/* ── OVERLAY (mobile) ────────────────────── */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { display: none; }
  .header-center { display: none; }
}

/* ── UTILITY ─────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* Code blocks in messages */
.msg-bubble pre {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 8px 0 0;
  overflow-x: auto;
  font-size: 12px;
}

.msg-bubble code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--ok);
}

/* ── FADE ANIMATION ──────────────────────── */
.fade-in { animation: fadeIn 0.4s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}