/* Citation Master Admin Dashboard — admin.css */
/* Standalone — does NOT import style.css */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #22263a;
  --border: #2e3249;
  --text: #e8eaf6;
  --text-muted: #7b82a6;
  --accent: #5c6bc0;
  --accent-hover: #7986cb;
  --green: #43a047;
  --green-bg: #1b2e1b;
  --red: #e53935;
  --red-bg: #2e1b1b;
  --yellow: #f9a825;
  --yellow-bg: #2e2a1b;
  --blue: #1e88e5;
  --blue-bg: #1b2338;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Fira Mono', 'Consolas', 'Courier New', monospace;
  --transition: 150ms ease;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────── */

#admin-body {
  display: none; /* hidden until auth confirmed */
  flex-direction: column;
  min-height: 100vh;
}

body.auth-ready #admin-body {
  display: flex;
}

/* ── Header ─────────────────────────────────────────── */

#admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.header-badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#header-user-email {
  color: var(--text-muted);
  font-size: 13px;
}

#gear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: color var(--transition), border-color var(--transition);
}

#gear-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ── Alert Banner ────────────────────────────────────── */

#alert-banner {
  display: none;
  background: var(--red-bg);
  border-bottom: 2px solid var(--red);
  color: #ff8a80;
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 500;
}

#alert-banner.show { display: flex; gap: 12px; align-items: center; }

/* ── Tab Bar ─────────────────────────────────────────── */

#tab-bar {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  gap: 4px;
  flex-shrink: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

/* ── Tab Content ─────────────────────────────────────── */

#tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Stat Cards ──────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.green { border-left: 3px solid var(--green); }
.stat-card.red   { border-left: 3px solid var(--red); }
.stat-card.blue  { border-left: 3px solid var(--blue); }
.stat-card.yellow{ border-left: 3px solid var(--yellow); }

/* ── Two-column row ──────────────────────────────────── */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ── Panels / Cards ──────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title .refresh-time {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-bg);
}

.btn-success {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.btn-success:hover:not(:disabled) {
  background: #388e3c;
  border-color: #388e3c;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ── Status Badges ───────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-green  { background: var(--green-bg);  color: #81c784; border: 1px solid #43a047; }
.badge-red    { background: var(--red-bg);    color: #ef9a9a; border: 1px solid #e53935; }
.badge-yellow { background: var(--yellow-bg); color: #fff176; border: 1px solid #f9a825; }
.badge-blue   { background: var(--blue-bg);   color: #90caf9; border: 1px solid #1e88e5; }
.badge-gray   { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Tables ──────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(92, 107, 192, 0.06);
}

.table-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Pagination ──────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Forms / Inputs ──────────────────────────────────── */

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 180px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="search"],
textarea,
select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font);
  width: 100%;
  transition: border-color var(--transition);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

/* ── Lookup Result Card ──────────────────────────────── */

#user-lookup-result {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
  display: none;
}

#user-lookup-result.show { display: block; }

.lookup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.lookup-email {
  font-size: 16px;
  font-weight: 600;
}

.lookup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.lookup-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.lookup-field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.lookup-field-value {
  font-size: 14px;
  font-weight: 600;
}

.lookup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  align-items: center;
}

/* ── Dropdown ────────────────────────────────────────── */
.dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 180px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  overflow: hidden;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--bg-surface-low);
}

.dropdown-item-danger {
  color: var(--red);
}

.dropdown-item-danger:hover {
  background: var(--red-bg);
}

/* ── Modal ───────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.modal-error {
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: #ef9a9a;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
}

.modal-error.show { display: block; }

.modal-success {
  background: var(--green-bg);
  border: 1px solid var(--green);
  color: #81c784;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
}

.modal-success.show { display: block; }

/* ── System Controls Drawer ──────────────────────────── */

#system-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  z-index: 200;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 250ms ease;
  display: flex;
  flex-direction: column;
}

#system-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}

.drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
}

.drawer-close:hover { color: var(--text); }

.drawer-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.control-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.control-row:last-child { margin-bottom: 0; }

.control-label {
  font-size: 13px;
  font-weight: 500;
}

.cap-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cap-input-row input {
  width: 100px;
}

/* ── Budget Chart (SVG) ──────────────────────────────── */

#budget-chart-svg {
  width: 100%;
  height: 180px;
  display: block;
}

.chart-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

/* ── Cost Breakdown ──────────────────────────────────── */

.cost-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.cost-bar-label {
  width: 100px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cost-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.cost-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 400ms ease;
}

.cost-bar-value {
  width: 60px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── Budget Progress Bar ─────────────────────────────── */

.progress-bar-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 400ms ease, background 400ms ease;
  background: var(--green);
}

.progress-bar-fill.warn  { background: var(--yellow); }
.progress-bar-fill.danger { background: var(--red); }

/* ── Funnel ──────────────────────────────────────────── */

.funnel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0;
}

.funnel-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.funnel-step-label {
  width: 90px;
  color: var(--text-muted);
}

.funnel-step-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.funnel-step-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.funnel-step-value {
  width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Feedback Item ───────────────────────────────────── */

.feedback-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.feedback-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 10px;
}

.feedback-citation {
  font-size: 12px;
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 8px;
  white-space: pre-wrap;
  overflow-x: auto;
}

.feedback-text {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.feedback-actions {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.feedback-actions textarea {
  flex: 1;
  min-width: 200px;
  min-height: 52px;
}

.bug-status-select {
  width: auto;
  min-width: 150px;
  max-width: 180px;
}

.bug-status-note-input {
  flex: 1;
  min-width: 220px;
}

/* ── Audit Log ───────────────────────────────────────── */

.audit-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: baseline;
}

.audit-row:last-child { border-bottom: none; }

.audit-time {
  color: var(--text-muted);
  width: 135px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.audit-action {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: var(--mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.audit-details {
  color: var(--text-muted);
  flex: 1;
}

/* ── Spinner ─────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-hover);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Collapsible ─────────────────────────────────────── */

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.collapsible-header:hover { color: var(--text); }

.collapsible-body {
  display: none;
}

.collapsible-body.open {
  display: block;
}

/* ── Inline copy box ─────────────────────────────────── */

.copy-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 13px;
  margin-top: 10px;
}

.copy-box-value {
  flex: 1;
  word-break: break-all;
}

/* ── Misc utility ────────────────────────────────────── */

.text-muted  { color: var(--text-muted); }
.text-green  { color: #81c784; }
.text-red    { color: #ef9a9a; }
.text-yellow { color: #fff176; }
.text-blue   { color: #90caf9; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
}

.inline-loading {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.fraud-highlight td {
  background: rgba(229, 57, 53, 0.08) !important;
  color: #ef9a9a;
}

/* sign out button */
#sign-out-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: color var(--transition), border-color var(--transition);
}

#sign-out-btn:hover {
  color: var(--red);
  border-color: var(--red);
}
