/* ─── Global Reset & Design Tokens ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #22263a;
  --accent: #6c63ff;
  --accent-light: #8b84ff;
  --accent-dim: rgba(108, 99, 255, 0.15);
  --text-primary: #e8eaf6;
  --text-secondary: #8891b0;
  --text-muted: #4e5570;
  --border: rgba(255,255,255,0.07);
  --success: #4caf88;
  --error: #f25656;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --font: 'Inter', system-ui, sans-serif;
  --transition: 150ms ease;
}

html, body { height: 100%; background: var(--bg-base); color: var(--text-primary); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 99px; }

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.flex-1 { flex: 1; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-secondary); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Button ──────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.6rem 1.25rem; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-family: var(--font); font-size: 0.9rem; font-weight: 500; transition: all var(--transition);
  text-decoration: none; user-select: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(108,99,255,0.4); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(242, 86, 86, 0.15); color: var(--error); border: 1px solid rgba(242,86,86,0.3); }
.btn-danger:hover { background: rgba(242, 86, 86, 0.25); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── Input ───────────────────────────────────────────────────────────────────── */
.input {
  width: 100%; padding: 0.7rem 1rem; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  color: var(--text-primary); font-family: var(--font); font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input::placeholder { color: var(--text-muted); }

/* ─── Card ────────────────────────────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; }

/* ─── Badge ───────────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: rgba(76,175,136,0.15); color: var(--success); }
.badge-accent { background: var(--accent-dim); color: var(--accent-light); }

/* ─── App Layout ──────────────────────────────────────────────────────────────── */
.app-layout { display: grid; grid-template-columns: 260px 1fr; height: 100vh; overflow: hidden; }
.sidebar { background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-header { padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); }
.sidebar-logo { font-size: 1.1rem; font-weight: 700; color: var(--accent-light); letter-spacing: -0.02em; }
.sidebar-logo span { color: var(--text-muted); font-weight: 400; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.5rem; }
.sidebar-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition), color var(--transition); color: var(--text-secondary); font-size: 0.9rem; }
.sidebar-item:hover, .sidebar-item.active { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active { color: var(--accent-light); }
.sidebar-section-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 1rem 0.75rem 0.25rem; }

/* ─── Chat Layout ─────────────────────────────────────────────────────────────── */
.chat-main { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.chat-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: rgba(26,29,39,0.8); backdrop-filter: blur(10px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.chat-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }

/* ─── Message Bubble ──────────────────────────────────────────────────────────── */
.message { display: flex; gap: 0.75rem; animation: fadeSlideIn 0.2s ease; }
.message-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #a78bfa); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0; }
.message-body { flex: 1; }
.message-meta { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.25rem; }
.message-name { font-weight: 600; font-size: 0.9rem; color: var(--accent-light); }
.message-time { font-size: 0.72rem; color: var(--text-muted); }
.message-text { color: var(--text-primary); line-height: 1.6; font-size: 0.9rem; }

/* ─── Chat Input ──────────────────────────────────────────────────────────────── */
.chat-input-wrapper { display: flex; gap: 0.75rem; align-items: flex-end; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.5rem 0.75rem; transition: border-color var(--transition); }
.chat-input-wrapper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.chat-textarea { flex: 1; background: none; border: none; color: var(--text-primary); font-family: var(--font); font-size: 0.9rem; line-height: 1.5; resize: none; outline: none; max-height: 120px; overflow-y: auto; }
.chat-textarea::placeholder { color: var(--text-muted); }

/* ─── Auth Page ───────────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 60% 0%, rgba(108,99,255,0.15) 0%, transparent 60%), var(--bg-base); }
.auth-card { width: 100%; max-width: 420px; padding: 2.5rem; }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo h1 { font-size: 1.8rem; font-weight: 700; background: linear-gradient(135deg, var(--accent-light), #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.auth-logo p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.4rem; }
.form-error { color: var(--error); font-size: 0.8rem; margin-top: 0.25rem; }
.auth-switch { text-align: center; font-size: 0.85rem; color: var(--text-secondary); margin-top: 1.5rem; }
.auth-switch a { color: var(--accent-light); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

/* ─── Animations ──────────────────────────────────────────────────────────────── */
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.2); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ─── Online indicator ────────────────────────────────────────────────────────── */
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; box-shadow: 0 0 0 2px rgba(76,175,136,0.3); }
