/* ─── Design tokens ──────────────────────────────────────────── */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --primary-hover: #4338ca;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning-soft: #fef3c7;
  --warning-text: #92400e;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

* { -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Inter", "Helvetica Neue", sans-serif;
  font-size: 14px;
}

/* ─── Navbar ─────────────────────────────────────────────────── */
.navbar {
  background: rgba(15, 23, 42, 0.95) !important;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-top: 12px;
  padding-bottom: 12px;
}
.navbar-brand { font-weight: 700; letter-spacing: 0.3px; font-size: 16px; }
.nav-link { font-weight: 500; font-size: 14px; padding: 6px 14px !important; border-radius: 8px; transition: all 0.15s; }
.nav-link:hover { background: rgba(255,255,255,0.06); }
.nav-link.active { background: rgba(255,255,255,0.12); color: #fff !important; }

main.container-fluid { padding-left: 24px; padding-right: 24px; padding-top: 8px; padding-bottom: 32px; }

/* ─── Toolbar (search + filters + actions in one row) ────────── */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.toolbar .form-control,
.toolbar .form-select,
.toolbar .btn {
  height: 32px;
  line-height: 1;
}
.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border-strong);
  margin: 0 6px;
}

/* ─── Forms ──────────────────────────────────────────────────── */
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--surface);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.form-control-sm, .form-select-sm { font-size: 13px; padding: 6px 10px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  font-size: 14px;
}
.btn-sm { font-size: 13px; padding: 6px 12px; }
.btn-xs { font-size: 12px; padding: 3px 10px; border-radius: 6px; line-height: 1.5; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-outline-secondary {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface);
}
.btn-outline-secondary:hover { background: var(--bg); border-color: var(--border-strong); color: var(--text); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn:disabled { opacity: 0.5; }

/* ─── Cards / table container ────────────────────────────────── */
.table-card, .table-responsive {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  padding: 14px 18px;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.table {
  margin-bottom: 0;
  color: var(--text);
}
.table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  white-space: nowrap;
}
.table tbody td {
  padding: 13px 16px;
  border-color: var(--border);
  vertical-align: middle;
  font-size: 13.5px;
}
.table-hover tbody tr { transition: background 0.1s; }
.table-hover tbody tr:hover { background: #fafbfc; }
.table tbody tr.row-disabled { background: #fafbfc; color: var(--text-muted); }
.table tbody tr.row-disabled td { color: var(--text-muted); }

/* sortable column headers */
.table th.sortable { cursor: pointer; user-select: none; transition: color 0.15s; }
.table th.sortable:hover { color: var(--primary); }
.table th .sort-icon::before {
  content: " ⇅";
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.35;
  font-weight: bold;
}
.table th.sort-asc .sort-icon::before { content: " ↑"; opacity: 1; color: var(--primary); }
.table th.sort-desc .sort-icon::before { content: " ↓"; opacity: 1; color: var(--primary); }

/* ─── Chips ──────────────────────────────────────────────────── */
.tag-chip {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-right: 4px;
  margin-bottom: 3px;
  font-weight: 500;
  letter-spacing: 0.1px;
}
.tag-chip.muted { background: #f1f5f9; color: #94a3b8; }

.tag-filter-chip {
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-weight: 500;
  transition: all 0.15s;
}
.tag-filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.tag-filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.bot-chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--warning-soft);
  color: var(--warning-text);
  margin-right: 4px;
  margin-bottom: 3px;
  font-weight: 500;
}
.bot-cell { line-height: 1.8; }

/* ─── Status pills ───────────────────────────────────────────── */
.status-pill {
  display: inline-block;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.status-pill-success { background: var(--success-soft); color: var(--success); }
.status-pill-danger { background: var(--danger-soft); color: var(--danger); }
.status-pill-info { background: var(--primary-soft); color: var(--primary); }
.status-pill-muted { background: #f1f5f9; color: var(--text-muted); }

/* ─── Misc ───────────────────────────────────────────────────── */
.text-truncate-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text);
}
.chat-id {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.2px;
}
.link-secondary { color: var(--primary) !important; text-decoration: none; font-weight: 500; }
.link-secondary:hover { text-decoration: underline; }

.badge { font-weight: 500; letter-spacing: 0.2px; padding: 4px 9px; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-content {
  border-radius: 16px;
  border: none;
  box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 24px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 22px 24px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 24px; }
.btn-close { opacity: 0.5; transition: opacity 0.15s; }
.btn-close:hover { opacity: 1; }

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  border: none;
}

/* ─── Pagination row ─────────────────────────────────────────── */
#pagination button[disabled] { opacity: 0.4; pointer-events: none; }
