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

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #263348;
  --border:    #334155;
  --primary:   #6366f1;
  --primary-h: #4f46e5;
  --danger:    #ef4444;
  --danger-h:  #dc2626;
  --success:   #10b981;
  --warning:   #f59e0b;
  --text:      #f1f5f9;
  --muted:     #94a3b8;
  --dim:       #64748b;
  --radius:    8px;
  --radius-lg: 14px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  font-size: 15px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Nav ───────────────────────────────────────────────────────────────────── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
nav .logo span { color: var(--text); }
nav .spacer { flex: 1; }
nav .nav-info { color: var(--muted); font-size: .85rem; }
nav a.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  padding: .3rem .7rem;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}
nav a.nav-link:hover { background: var(--surface2); color: var(--text); }
nav a.nav-link.admin { color: var(--warning); }
nav button.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .3rem .8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  transition: background .15s, color .15s;
}
nav button.nav-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Auth pages ─────────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at top left, #1e1b4b 0%, var(--bg) 60%);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .4rem;
}
.auth-card .subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 1.8rem;
}
.auth-card .brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .4rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .6rem .85rem;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); }
.form-group .hint { font-size: .78rem; color: var(--dim); margin-top: .25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .65rem 1.4rem;
  border-radius: var(--radius);
  border: none;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: var(--danger-h); }
.btn-ghost  { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover  { background: var(--surface2); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .35rem .85rem; font-size: .85rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Error / info banners ───────────────────────────────────────────────────── */
.banner {
  border-radius: var(--radius);
  padding: .7rem 1rem;
  font-size: .9rem;
  margin-bottom: 1rem;
  display: none;
}
.banner.error   { background: rgba(239,68,68,.12);   border: 1px solid var(--danger);  color: #fca5a5; }
.banner.success { background: rgba(16,185,129,.12);  border: 1px solid var(--success); color: #6ee7b7; }
.banner.info    { background: rgba(99,102,241,.12);  border: 1px solid var(--primary); color: #a5b4fc; }
.banner.show    { display: block; }

/* ── Dividers ───────────────────────────────────────────────────────────────── */
.link-row {
  text-align: center;
  font-size: .88rem;
  color: var(--muted);
  margin-top: 1.2rem;
}
.link-row a { color: var(--primary); text-decoration: none; }
.link-row a:hover { text-decoration: underline; }

/* ── Setup stepper ──────────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 680px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}
.stepper {
  display: flex;
  gap: 0;
  margin-bottom: 2rem;
}
.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.step::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--border);
}
.step:last-child::before { display: none; }
.step.done::before  { background: var(--primary); }
.step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  z-index: 1;
  color: var(--muted);
}
.step.active .step-circle { border-color: var(--primary); color: var(--primary); background: rgba(99,102,241,.1); }
.step.done  .step-circle  { border-color: var(--primary); background: var(--primary); color: #fff; }
.step-label { font-size: .75rem; color: var(--muted); margin-top: .4rem; text-align: center; }
.step.active .step-label  { color: var(--text); font-weight: 500; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: .4rem; }
.card .desc { color: var(--muted); font-size: .9rem; margin-bottom: 1.6rem; }

/* ── Collection pills ───────────────────────────────────────────────────────── */
.collection-list {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1rem;
}
.col-pill {
  padding: .45rem 1rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: .88rem;
  transition: all .15s;
}
.col-pill:hover  { border-color: var(--primary); color: var(--text); }
.col-pill.selected { border-color: var(--primary); background: rgba(99,102,241,.15); color: var(--text); font-weight: 500; }
.or-divider { text-align: center; color: var(--dim); margin: 1rem 0; font-size: .85rem; position: relative; }
.or-divider::before, .or-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}
.or-divider::before { left: 0; }
.or-divider::after  { right: 0; }

/* ── Upload area ────────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.upload-area:hover, .upload-area.drag { border-color: var(--primary); background: rgba(99,102,241,.05); }
.upload-area input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-area .upload-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-area p  { color: var(--muted); font-size: .9rem; }
.upload-area .hint { color: var(--dim); font-size: .8rem; margin-top: .3rem; }
.file-list { margin-top: 1rem; display: flex; flex-direction: column; gap: .4rem; }
.file-item { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem .8rem; font-size: .85rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; }

/* ── Chat layout ────────────────────────────────────────────────────────────── */
.chat-layout {
  display: flex;
  height: calc(100vh - 56px);
}
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  gap: .75rem;
}
.sidebar .col-badge {
  background: rgba(99,102,241,.15);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  font-size: .82rem;
  color: #a5b4fc;
}
.sidebar .col-badge .label { font-size: .7rem; color: var(--dim); margin-bottom: .1rem; }
.sidebar .col-badge .name  { font-weight: 600; word-break: break-all; }
.sidebar-links { display: flex; flex-direction: column; gap: .4rem; margin-top: auto; }

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.msg { display: flex; gap: .75rem; max-width: 78%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  padding: .75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: .95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.user      .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.msg.assistant .msg-avatar { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.msg.user      .msg-avatar { background: var(--primary-h); color: #fff; }
.typing { display: flex; gap: .3rem; align-items: center; padding: .75rem 1rem; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: bounce .8s infinite;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s;  }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }

.chat-input-bar {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  background: var(--surface);
  display: flex;
  gap: .75rem;
  align-items: flex-end;
}
.chat-input-bar textarea {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  padding: .75rem 1rem;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
  min-height: 48px;
  max-height: 140px;
  line-height: 1.5;
  font-family: inherit;
}
.chat-input-bar textarea:focus { border-color: var(--primary); }

/* ── Admin table ────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface2); }
th, td { padding: .8rem 1.1rem; text-align: left; font-size: .9rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 500;
}
.badge-pending  { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-approved { background: rgba(16,185,129,.15);  color: var(--success); }
.action-row { display: flex; gap: .4rem; }

/* ── Pending / info pages ───────────────────────────────────────────────────── */
.center-page {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.info-card .icon { font-size: 3rem; margin-bottom: 1rem; }
.info-card h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: .6rem; }
.info-card p { color: var(--muted); font-size: .95rem; line-height: 1.6; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  display: none;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.4rem; }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Misc helpers ───────────────────────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.text-muted { color: var(--muted); font-size: .88rem; }
.empty-state { text-align: center; color: var(--dim); padding: 3rem 1rem; }
