/* ═══════════════════════════════════════════════════════════════
   Admin UI — Shared design system across admin tabs
   Prefix: ap-*  (Admin Panel)
   Used by: Bug Reports, Conversations, and future admin tabs
   ═══════════════════════════════════════════════════════════════ */

.ap-root { padding: 0; max-width: 1600px; margin: 0 auto; }

/* ── Header ── */
.ap-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border, rgba(99,102,241,0.1));
}
.ap-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.25rem; font-weight: 700;
  color: var(--text, #e8edf5);
}
.ap-title .lucide { width: 22px; height: 22px; color: var(--primary, #6366f1); }
.ap-subtitle {
  font-size: 0.8125rem; color: var(--text-muted, #8b9dc3);
  margin-top: 4px;
}
.ap-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ── */
.ap-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border, rgba(99,102,241,0.1));
  background: var(--bg-card, rgba(22,32,56,0.82));
  color: var(--text, #e8edf5);
  font-family: inherit; font-size: 0.8125rem; font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.ap-btn:hover:not(:disabled) {
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.3);
}
.ap-btn:focus-visible { outline: 2px solid var(--primary, #6366f1); outline-offset: 2px; }
.ap-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ap-btn .lucide { width: 14px; height: 14px; }
.ap-btn-primary { background: var(--primary, #6366f1); color: #fff; border-color: transparent; }
.ap-btn-primary:hover:not(:disabled) { background: var(--primary-dark, #4f46e5); color: #fff; }
.ap-btn-success {
  background: rgba(74,222,128,0.12);
  color: #4ade80;
  border-color: rgba(74,222,128,0.25);
}
.ap-btn-success:hover:not(:disabled) {
  background: rgba(74,222,128,0.22);
  border-color: rgba(74,222,128,0.45);
  color: #4ade80;
}
.ap-btn-sm { padding: 5px 10px; font-size: 0.75rem; }

/* ── Form controls ── */
.ap-input, .ap-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(99,102,241,0.1));
  background: var(--bg-input, rgba(22,32,56,0.88));
  color: var(--text, #e8edf5);
  font-family: inherit;
  font-size: 0.8125rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.ap-input:focus, .ap-select:focus {
  outline: none;
  border-color: var(--primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.14);
}
.ap-input::placeholder { color: var(--text-muted, #8b9dc3); }
.ap-select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b9dc3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
[data-theme="light"] .ap-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* ── Search input with leading icon ── */
.ap-search-wrap {
  position: relative;
  flex: 1; min-width: 220px;
}
.ap-search-wrap .lucide {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-muted, #8b9dc3);
  pointer-events: none;
}
.ap-search-wrap .ap-input { width: 100%; padding-left: 36px; }

/* ── Filter bar ── */
.ap-filters {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--bg-card, rgba(22,32,56,0.82));
  border: 1px solid var(--border, rgba(99,102,241,0.1));
  border-radius: 12px;
  margin-bottom: 16px;
}
[data-theme="light"] .ap-filters { background: rgba(255,255,255,0.85); }
.ap-filters-label {
  font-size: 0.72rem; font-weight: 700;
  color: var(--text-muted, #8b9dc3);
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: center;
  padding-right: 4px;
}

.ap-meta-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
  font-size: 0.8125rem;
}
.ap-meta-bar-left { color: var(--text-muted, #8b9dc3); }
.ap-meta-bar-left strong { color: var(--text, #e8edf5); font-weight: 700; }

/* ── KPI Grid (reused across tabs) ── */
.ap-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px; margin-bottom: 24px;
}
@media (max-width: 1100px) { .ap-kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 680px)  { .ap-kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.ap-kpi {
  position: relative;
  background: var(--bg-card, rgba(22,32,56,0.82));
  border: 1px solid var(--border, rgba(99,102,241,0.1));
  border-radius: 12px;
  padding: 16px; text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}
.ap-kpi:hover { border-color: rgba(99,102,241,0.3); transform: translateY(-1px); }
[data-theme="light"] .ap-kpi { background: rgba(255,255,255,0.85); }

.ap-kpi-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.ap-kpi-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(99,102,241,0.10);
}
.ap-kpi-icon .lucide { width: 16px; height: 16px; }
.ap-kpi-val {
  font-size: 1.65rem; font-weight: 800; line-height: 1.1;
  color: var(--text, #e8edf5);
}
.ap-kpi-label {
  font-size: 0.7rem; font-weight: 600;
  color: var(--text-muted, #8b9dc3);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-top: 4px;
}

.ap-kpi.accent-indigo { --accent-color: #818cf8; }
.ap-kpi.accent-indigo .ap-kpi-icon { background: rgba(129,140,248,0.14); color: #818cf8; }
.ap-kpi.accent-indigo .ap-kpi-val { color: #818cf8; }
.ap-kpi.accent-amber  { --accent-color: #fbbf24; }
.ap-kpi.accent-amber  .ap-kpi-icon { background: rgba(251,191,36,0.14);  color: #fbbf24; }
.ap-kpi.accent-amber  .ap-kpi-val { color: #fbbf24; }
.ap-kpi.accent-green  { --accent-color: #4ade80; }
.ap-kpi.accent-green  .ap-kpi-icon { background: rgba(74,222,128,0.14);  color: #4ade80; }
.ap-kpi.accent-green  .ap-kpi-val { color: #4ade80; }
.ap-kpi.accent-primary { --accent-color: #a78bfa; }
.ap-kpi.accent-primary .ap-kpi-icon { background: rgba(167,139,250,0.14); color: #a78bfa; }
.ap-kpi.accent-primary .ap-kpi-val { color: #a78bfa; }
.ap-kpi.accent-teal   { --accent-color: #34d399; }
.ap-kpi.accent-teal   .ap-kpi-icon { background: rgba(52,211,153,0.14);  color: #34d399; }
.ap-kpi.accent-teal   .ap-kpi-val { color: #34d399; }
.ap-kpi.accent-rose   { --accent-color: #fb7185; }
.ap-kpi.accent-rose   .ap-kpi-icon { background: rgba(251,113,133,0.14); color: #fb7185; }
.ap-kpi.accent-rose   .ap-kpi-val { color: #fb7185; }

/* ── Section / card ── */
.ap-section {
  background: var(--bg-card, rgba(22,32,56,0.82));
  border: 1px solid var(--border, rgba(99,102,241,0.1));
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}
[data-theme="light"] .ap-section { background: rgba(255,255,255,0.85); }

.ap-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.ap-section-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.9rem; font-weight: 600;
  color: var(--text, #e8edf5);
}
.ap-section-title .lucide { width: 16px; height: 16px; color: var(--primary, #6366f1); }
.ap-section-sub {
  font-size: 0.75rem; color: var(--text-muted, #8b9dc3);
  margin-top: 2px;
}

/* ── Chip (status/tag) ── */
.ap-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600;
  white-space: nowrap;
  background: var(--chip-bg, rgba(99,102,241,0.12));
  color: var(--chip-color, #818cf8);
}
.ap-chip .lucide { width: 12px; height: 12px; }

/* ── Table ── */
.ap-table-wrap { overflow-x: auto; }
.ap-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.8125rem;
}
.ap-table thead th {
  padding: 10px 12px; text-align: left;
  font-size: 0.68rem; font-weight: 700;
  color: var(--text-muted, #8b9dc3);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border, rgba(99,102,241,0.15));
  background: rgba(99,102,241,0.03);
  position: sticky; top: 0;
}
.ap-table tbody tr {
  border-bottom: 1px solid var(--border, rgba(99,102,241,0.06));
  transition: background 0.15s;
}
.ap-table tbody tr:hover { background: rgba(99,102,241,0.04); }
.ap-table tbody tr:last-child { border-bottom: none; }
.ap-table td { padding: 10px 12px; vertical-align: middle; }
.ap-table td.num { text-align: center; font-variant-numeric: tabular-nums; }
.ap-table .ap-truncate {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ap-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  padding: 2px 6px; border-radius: 4px;
  background: rgba(99,102,241,0.08);
  color: var(--text-muted, #8b9dc3);
}

/* ── Empty / Error / Pagination ── */
.ap-empty {
  padding: 60px 20px; text-align: center;
  color: var(--text-muted, #8b9dc3);
}
.ap-empty .lucide { width: 40px; height: 40px; opacity: 0.5; margin-bottom: 12px; }
.ap-empty-title { font-size: 0.95rem; font-weight: 600; color: var(--text, #e8edf5); margin-bottom: 4px; }
.ap-empty-msg { font-size: 0.825rem; }

.ap-error {
  padding: 40px; text-align: center;
}
.ap-error-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.95rem; font-weight: 600; color: #f87171;
  margin-bottom: 6px;
}
.ap-error-msg { color: var(--text-muted, #8b9dc3); font-size: 0.85rem; margin-bottom: 16px; }

.ap-pagination {
  display: flex; gap: 8px; margin-top: 20px;
  justify-content: center; align-items: center;
}
.ap-pagination-info {
  font-size: 0.8125rem; color: var(--text-muted, #8b9dc3);
  padding: 0 12px;
}

/* ═══════════════════════════════════════════════════════════════
   Conversations — card-based layout
   ═══════════════════════════════════════════════════════════════ */

.ap-conv-list {
  display: grid; gap: 12px;
}
.ap-conv {
  background: var(--bg-card, rgba(22,32,56,0.82));
  border: 1px solid var(--border, rgba(99,102,241,0.1));
  border-left: 3px solid var(--conv-accent, #94a3b8);
  border-radius: 12px;
  padding: 16px 18px;
  transition: border-color 0.15s, transform 0.15s;
}
[data-theme="light"] .ap-conv { background: rgba(255,255,255,0.85); }
.ap-conv:hover {
  border-color: rgba(99,102,241,0.3);
  border-left-color: var(--conv-accent, #94a3b8);
  transform: translateY(-1px);
}

.ap-conv-top {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 12px;
}
.ap-conv-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(139,92,246,0.15));
  color: #a78bfa;
  font-size: 0.78rem; font-weight: 700;
  flex-shrink: 0;
}
.ap-conv-body { flex: 1; min-width: 0; }
.ap-conv-q {
  font-size: 0.9375rem; font-weight: 600;
  color: var(--text, #e8edf5);
  margin-bottom: 6px; line-height: 1.45;
}
.ap-conv-a {
  font-size: 0.8125rem; color: var(--text-muted, #8b9dc3);
  line-height: 1.6;
  max-height: 80px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.ap-conv-badges {
  display: flex; gap: 6px; flex-shrink: 0;
}

.ap-conv-meta {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  font-size: 0.75rem; color: var(--text-muted, #8b9dc3);
  padding-top: 12px;
  border-top: 1px solid var(--border, rgba(99,102,241,0.06));
}
.ap-conv-meta > span {
  display: inline-flex; align-items: center; gap: 4px;
}
.ap-conv-meta .lucide { width: 13px; height: 13px; opacity: 0.75; }
.ap-conv-meta strong { color: var(--text, #e8edf5); font-weight: 600; }
.ap-conv-meta-right { margin-left: auto; }

.ap-stars { color: #fbbf24; letter-spacing: 1px; font-size: 0.82rem; }
.ap-stars-empty { color: rgba(148,163,184,0.35); }

.ap-conv-correction {
  margin-top: 12px; padding: 10px 14px;
  background: rgba(249,115,22,0.06);
  border-left: 3px solid #f97316;
  border-radius: 6px;
}
.ap-conv-correction-label {
  font-size: 0.68rem; font-weight: 700;
  color: #f97316;
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 4px;
  display: inline-flex; align-items: center; gap: 4px;
}
.ap-conv-correction-label .lucide { width: 12px; height: 12px; }
.ap-conv-correction-text {
  font-size: 0.8125rem; color: var(--text, #e8edf5);
  line-height: 1.5;
}
