/* ============================================================
   style.css — TIK PNUP Chatbot & Admin Dashboard
   Shared stylesheet for: chat.html, dashboard.html, login.html
   Fonts: IBM Plex Sans (body) + IBM Plex Mono (mono/labels)
   ============================================================ */

/* ── RESET ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── DESIGN TOKENS ───────────────────────────────────────────── */
:root {
  /* Base surfaces */
  --bg:         #f5f4f0;
  --surface:    #ffffff;
  --border:     #d8d5ce;
  --border-2:   #ebe8e1;

  /* Accent */
  --accent:     #2563eb;
  --accent-dim: #1d4ed8;
  --accent-bg:  #eff6ff;

  /* Text */
  --text:       #1c1917;
  --muted:      #78716c;
  --muted2:     #a8a29e;

  /* Semantic */
  --red:          #dc2626;
  --red-bg:       #fef2f2;
  --red-border:   #fecaca;
  --green:        #16a34a;
  --green-bg:     #f0fdf4;
  --green-border: #bbf7d0;
  --yellow:       #b45309;
  --yellow-bg:    #fffbeb;
  --yellow-border:#fde68a;

  /* User bubble (chat) */
  --user-bg: #2563eb;
  --bot-bg:  #ffffff;
  --tag-bg:  #f0f0eb;

  /* Typography */
  --font:  'IBM Plex Sans', sans-serif;
  --mono:  'IBM Plex Mono', monospace;

  /* Layout */
  --sidebar-w: 256px;
  --r: 8px;
}

/* ── BASE ────────────────────────────────────────────────────── */
html, body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }
input, textarea { font-family: inherit; }

code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--tag-bg);
  padding: 1px 5px;
  border-radius: 3px;
}


/* ══════════════════════════════════════════════════════════════
   SHARED COMPONENTS
══════════════════════════════════════════════════════════════ */

/* ── Sidebar shell ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-top {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-2);
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border-2);
}

/* ── Brand block ─────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--r);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand-icon svg { width: 20px; height: 20px; color: #fff; }

.brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .1px;
  line-height: 1.3;
}
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Nav labels & items ──────────────────────────────────────── */
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted2);
  padding: 0 8px;
  margin-bottom: 4px;
  font-family: var(--mono);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: background .12s, color .12s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  cursor: pointer;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-item:hover { background: var(--accent-bg); color: var(--accent); }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
}

.nav-divider {
  border: none;
  border-top: 1px solid var(--border-2);
  margin: 10px 8px;
}

/* ── Mobile menu button ──────────────────────────────────────── */
.mobile-menu {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--muted);
}
.mobile-menu svg { width: 20px; height: 20px; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash-list { display: flex; flex-direction: column; gap: 8px; }

.flash {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 13px;
  border-radius: var(--r);
  font-size: 13px;
  line-height: 1.5;
}
.flash svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.flash.error   { background: var(--red-bg);    border: 1px solid var(--red-border);    color: var(--red); }
.flash.success { background: var(--green-bg);  border: 1px solid var(--green-border);  color: var(--green); }
.flash.info    { background: var(--accent-bg); border: 1px solid #bfdbfe;              color: var(--accent); }
.flash.warning { background: var(--yellow-bg); border: 1px solid var(--yellow-border); color: var(--yellow); }

/* ── Card shell ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-title-row { display: flex; align-items: center; gap: 9px; }
.card-icon {
  width: 30px; height: 30px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  display: grid; place-items: center;
}
.card-icon svg { width: 15px; height: 15px; color: var(--accent); }
.card-title { font-size: 14px; font-weight: 600; }
.card-sub   { font-size: 11.5px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.card-body  { padding: 20px; }

/* ── Buttons (shared) ────────────────────────────────────────── */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-logout:hover {
  border-color: var(--red-border);
  color: var(--red);
  background: var(--red-bg);
}
.btn-logout svg { width: 14px; height: 14px; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 36px 20px; }
.empty-icon  { font-size: 32px; margin-bottom: 10px; }
.empty-text  { font-size: 13.5px; color: var(--muted); }
.empty-sub   { font-size: 12px; color: var(--muted2); margin-top: 4px; font-family: var(--mono); }


/* ══════════════════════════════════════════════════════════════
   CHAT PAGE  (chat.html)
══════════════════════════════════════════════════════════════ */

.shell {
  display: flex;
  height: 100vh;
}

html.chat-page, body.chat-page {
  height: 100%;
  overflow: hidden;
}

/* Chat sidebar extras */
.chat-page .sidebar { transition: transform .25s ease; }

.sidebar-top .new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  margin-top: 16px;
}
.sidebar-top .new-chat:hover { background: #ede9e3; border-color: #c5c0b8; }
.sidebar-top .new-chat svg   { width: 15px; height: 15px; color: var(--muted); }

.status-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}
.dot-online {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.footer-school {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 6px;
  line-height: 1.5;
  font-family: var(--mono);
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left    { display: flex; align-items: center; gap: 10px; }
.header-title   { font-size: 14px; font-weight: 600; }
.header-sub     { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* Messages container */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar       { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Welcome / empty state */
.welcome {
  margin: auto;
  max-width: 480px;
  text-align: center;
  padding: 16px;
}
.welcome-icon {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 12px;
  display: grid; place-items: center;
  margin: 0 auto 16px;
}
.welcome-icon svg { width: 28px; height: 28px; color: #fff; }
.welcome h2      { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.welcome p       { font-size: 13px; color: var(--muted); line-height: 1.65; margin-bottom: 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.chip {
  padding: 6px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: var(--font);
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

/* Message groups & rows */
.msg-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 16px;
  animation: fadein .2s ease;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.msg-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-row.user { flex-direction: row-reverse; }

.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  align-self: flex-end;
}
.avatar.bot  { background: var(--accent); color: #fff; font-family: var(--mono); font-size: 11px; }
.avatar.user { background: var(--border); color: var(--muted); font-size: 11px; font-family: var(--mono); }

.bubble {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}
.bubble.bot  { background: var(--bot-bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text); }
.bubble.user { background: var(--user-bg); color: #fff; border-bottom-right-radius: 4px; }

/* Source chips inside bot bubble */
.sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-2);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.sources-label {
  font-size: 10px;
  color: var(--muted2);
  font-family: var(--mono);
  width: 100%;
  margin-bottom: 3px;
}
.src-tag {
  font-size: 10.5px;
  font-family: var(--mono);
  background: var(--tag-bg);
  border: 1px solid var(--border-2);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Typing indicator */
.typing-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 16px;
  animation: fadein .2s ease;
}
.typing-bubble {
  background: var(--bot-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
}
.dots { display: flex; gap: 4px; align-items: center; }
.dots span {
  width: 6px; height: 6px;
  background: var(--muted2);
  border-radius: 50%;
  animation: bounce .9s infinite;
}
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-5px); }
}

/* Input bar */
.input-bar {
  padding: 14px 24px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px 8px 14px;
  transition: border-color .2s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
#q {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  resize: none;
  max-height: 120px;
  min-height: 22px;
  line-height: 1.55;
}
#q::placeholder { color: var(--muted2); }

.send {
  width: 34px; height: 34px;
  border-radius: 6px;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background .15s;
}
.send:hover    { background: var(--accent-dim); }
.send:disabled { background: var(--border); cursor: not-allowed; }
.send svg      { width: 16px; height: 16px; }

.hint {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 7px;
  font-family: var(--mono);
  text-align: center;
}
.hint kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font-family: var(--mono);
  font-size: 10px;
}


/* ══════════════════════════════════════════════════════════════
   DASHBOARD PAGE  (dashboard.html)
══════════════════════════════════════════════════════════════ */

.dashboard-page .shell {
  min-height: 100vh;
  align-items: flex-start;
}

/* Dashboard sidebar extras */
.dashboard-page .sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Main area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-y: auto;
}

.main-header {
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.page-title { font-size: 16px; font-weight: 600; }
.page-sub   { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

.content {
  padding: 24px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 900px;
}

/* Stat row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .7px;
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: -1px;
  color: var(--text);
}
.stat-value.ok    { color: var(--green); }
.stat-value.error { color: var(--red); }
.stat-desc { font-size: 11.5px; color: var(--muted2); }

/* User row (sidebar footer) */
.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}
.user-avatar {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--mono);
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover,
.drop-zone.drag-over { border-color: var(--accent); background: var(--accent-bg); }
.drop-zone input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.drop-icon {
  width: 40px; height: 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: grid; place-items: center;
  margin: 0 auto 12px;
}
.drop-icon svg { width: 20px; height: 20px; color: var(--muted); }
.drop-text strong { font-size: 13.5px; font-weight: 600; display: block; margin-bottom: 4px; }
.drop-text span   { font-size: 12.5px; color: var(--muted); }

/* File preview */
.preview-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-size: 13px;
}
.preview-icon { font-size: 16px; flex-shrink: 0; }
.preview-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-size { font-size: 11px; color: var(--muted2); font-family: var(--mono); flex-shrink: 0; }
.preview-bad  { font-size: 11px; color: var(--red); }

/* Buttons */
.btn-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-upload:hover:not(:disabled) { background: var(--accent-dim); }
.btn-upload:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
.btn-upload svg { width: 15px; height: 15px; }

/* File table */
.file-table-wrap { overflow-x: auto; }
.file-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.file-table th {
  text-align: left;
  padding: 9px 14px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-family: var(--mono);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.file-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}
.file-table tr:last-child td { border-bottom: none; }
.file-table tr:hover td { background: var(--bg); }

.file-name-row { display: flex; align-items: center; gap: 9px; }
.ext-badge {
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.ext-badge.docx { background: var(--accent-bg); color: var(--accent); }
.ext-badge.pdf  { background: var(--red-bg);    color: var(--red); }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.fsize { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.idx-pill {
  display: inline-block;
  font-size: 10.5px;
  font-family: var(--mono);
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 11px;
  letter-spacing: .2px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.idx-pill.ok      { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border); }
.idx-pill.fail    { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
.idx-pill.pending { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }

.btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-delete:hover { border-color: var(--red-border); color: var(--red); background: var(--red-bg); }
.btn-delete svg   { width: 13px; height: 13px; }

/* Rebuild section */
.rebuild-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.rebuild-step  { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.step-num {
  width: 22px; height: 22px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid #bfdbfe;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  flex-shrink: 0;
  margin-top: 1px;
}

.rebuild-warn {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-border);
  border-radius: var(--r);
  padding: 10px 13px;
  font-size: 12.5px;
  color: var(--yellow);
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.rebuild-warn svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }

.index-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
  margin-bottom: 14px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok    { background: var(--green); }
.status-dot.error { background: var(--red); }

.btn-rebuild {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn-rebuild:hover    { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.btn-rebuild:disabled { opacity: .5; cursor: not-allowed; }
.btn-rebuild svg      { width: 15px; height: 15px; }


/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE  (login.html)
══════════════════════════════════════════════════════════════ */

.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

/* Subtle grid background */
.login-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-2) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  padding: 36px 32px 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}

/* Login brand */
.login-card .brand { margin-bottom: 28px; }
.login-card .brand-icon { width: 40px; height: 40px; }
.login-card .brand-icon svg { width: 22px; height: 22px; }
.login-card .brand-name { font-size: 14px; }

.login-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -.2px;
}
.login-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 24px;
  font-family: var(--mono);
}

/* Form */
.form-group       { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  font-family: var(--mono);
  margin-bottom: 7px;
}

.input-wrap-login {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0 12px;
  gap: 9px;
  transition: border-color .2s, box-shadow .2s;
}
.input-wrap-login:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.input-wrap-login svg { width: 15px; height: 15px; color: var(--muted2); flex-shrink: 0; }
.input-wrap-login input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  padding: 11px 0;
}
.input-wrap-login input::placeholder { color: var(--muted2); }

.toggle-pw {
  background: none; border: none;
  color: var(--muted2);
  cursor: pointer;
  display: grid; place-items: center;
  padding: 0;
  transition: color .15s;
}
.toggle-pw:hover { color: var(--muted); }
.toggle-pw svg   { width: 15px; height: 15px; }

.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-top: 6px;
}
.btn-submit:hover { background: var(--accent-dim); }
.btn-submit svg   { width: 15px; height: 15px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 18px;
  color: var(--muted2);
  font-size: 11px;
}
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--border-2); }

.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: color .15s;
}
.back-link:hover { color: var(--accent); }
.back-link svg   { width: 14px; height: 14px; }

.login-note {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted2);
  font-family: var(--mono);
  margin-top: 22px;
  line-height: 1.5;
}



/* ══════════════════════════════════════════════════════════════
   RIWAYAT CHAT (sidebar)
══════════════════════════════════════════════════════════════ */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  margin-top: 4px;
  padding-right: 2px;
}
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.history-empty {
  font-size: 12px;
  color: var(--muted2);
  padding: 10px 6px;
  text-align: center;
}

.history-item {
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background .15s;
  cursor: pointer;
}
.history-item:hover    { background: var(--hover, rgba(0,0,0,.05)); }
.history-item.active   { background: rgba(99,102,241,.10); }

.history-item-inner {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
}

.history-title {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.history-item.active .history-title { color: var(--accent); }

.history-meta {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 2px;
}

.history-del {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--muted2);
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.history-item:hover .history-del { opacity: 1; }
.history-del:hover                { color: #ef4444; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */

@media (max-width: 860px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  /* Slide-in sidebar (both pages) */
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100%;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.1);
  }
  .sidebar.open { transform: translateX(0); }

  .mobile-menu { display: flex; }

  /* Chat */
  .messages  { padding: 16px; }
  .input-bar { padding: 10px 12px 14px; }
  .bubble    { max-width: 82%; }

  /* Dashboard */
  .content     { padding: 16px 16px 40px; }
  .main-header { padding: 14px 16px; }
  .stats-row   { grid-template-columns: 1fr; }
}