/* ═══════════════════════════════════════════════════════════════════════════
   Onyx Credit Intelligence — Admin Console Stylesheet
   Depends on: styles.css (design tokens)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Body ──────────────────────────────────────────────────────────────── */

.ci-admin-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.ci-header {
  background: rgba(4, 12, 6, 0.98);
  border-bottom: 1px solid rgba(0, 255, 106, 0.14);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  height: 52px;
  gap: 16px;
}

.ci-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ci-header-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.ci-header-title {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ci-header-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.ci-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.ci-layout {
  display: flex;
  min-height: calc(100vh - 52px);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.ci-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: rgba(4, 12, 6, 0.98);
  border-right: 1px solid var(--line);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
}

.ci-nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 20px;
  text-align: left;
  cursor: pointer;
  font-size: 0.88rem;
  width: 100%;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
}

.ci-nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.ci-nav-btn.active {
  color: var(--green);
  border-left-color: var(--green);
  background: rgba(0, 255, 106, 0.07);
}

.ci-nav-icon {
  font-style: normal;
  font-size: 0.9em;
  width: 16px;
  flex-shrink: 0;
  text-align: center;
}

/* ── Main content ────────────────────────────────────────────────────────── */

.ci-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  min-width: 0;
}

.ci-section {
  max-width: 1100px;
}

/* ── Section title ───────────────────────────────────────────────────────── */

.ci-section-title {
  font-size: 1.3rem;
  font-weight: 600;
  font-family: Georgia, serif;
  margin: 0 0 20px;
  color: var(--ink);
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.ci-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.ci-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.ci-connector-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: transform 0.12s, box-shadow 0.12s;
}

.ci-connector-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.ci-connector-card-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}

.ci-stat-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
}

.ci-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--green);
  display: block;
}

.ci-stat-label {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Profile cards ───────────────────────────────────────────────────────── */

.ci-profile-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
}

.ci-profile-card-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ci-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* ── Status badges ───────────────────────────────────────────────────────── */

.ci-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.ci-badge-pending {
  background: rgba(0, 255, 106, 0.16);
  color: var(--green);
}

.ci-badge-running {
  background: rgba(0, 180, 255, 0.18);
  color: var(--electric);
}

.ci-badge-complete {
  background: rgba(52, 211, 153, 0.18);
  color: #34d399;
}

.ci-badge-failed {
  background: rgba(216, 106, 82, 0.18);
  color: var(--rust);
}

.ci-badge-manual {
  background: rgba(127, 163, 220, 0.18);
  color: var(--navy);
}

.ci-badge-verified {
  background: rgba(52, 211, 153, 0.18);
  color: #34d399;
}

.ci-badge-blocked {
  background: rgba(216, 106, 82, 0.18);
  color: var(--rust);
}

.ci-badge-configured {
  background: rgba(52, 211, 153, 0.18);
  color: #34d399;
}

.ci-badge-not-configured {
  background: rgba(127, 163, 220, 0.12);
  color: var(--muted);
}

/* ── Score bar ───────────────────────────────────────────────────────────── */

.ci-score-bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin: 6px 0;
}

.ci-score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.ci-score-bar-fill.positive {
  background: #34d399;
}

.ci-score-bar-fill.neutral {
  background: var(--green);
}

.ci-score-bar-fill.negative {
  background: var(--rust);
}

/* ── Score dial ──────────────────────────────────────────────────────────── */

.ci-score-dial {
  text-align: center;
  padding: 24px;
}

.ci-score-number {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  font-family: Georgia, serif;
}

.ci-score-band {
  font-size: 1.1rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Form styles ─────────────────────────────────────────────────────────── */

.ci-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
}

.ci-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.ci-form input,
.ci-form select,
.ci-form textarea {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.ci-form input::placeholder,
.ci-form textarea::placeholder {
  color: rgba(169, 181, 200, 0.5);
}

.ci-form input:focus,
.ci-form select:focus,
.ci-form textarea:focus {
  outline: none;
  border-color: var(--green);
}

.ci-form select option {
  background: var(--surface-strong);
  color: var(--ink);
}

.ci-form textarea {
  resize: vertical;
  min-height: 72px;
}

.ci-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.ci-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--green);
  color: #0a0f1a;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 10px rgba(0, 255, 106, 0.22);
}

.ci-btn-primary:hover {
  background: #e4bf7a;
  box-shadow: 0 4px 16px rgba(0, 255, 106, 0.30);
  transform: translateY(-1px);
}

.ci-btn-primary:active {
  transform: translateY(0);
}

.ci-btn-primary:disabled {
  background: rgba(0, 255, 106, 0.30);
  color: rgba(10, 15, 26, 0.5);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.ci-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ci-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(195, 210, 235, 0.28);
  color: var(--ink);
}

.ci-btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* small danger variant used for retry/delete in tables */
.ci-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  color: var(--rust);
  border: 1px solid rgba(216, 106, 82, 0.3);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ci-btn-danger:hover {
  background: rgba(216, 106, 82, 0.12);
  border-color: var(--rust);
}

/* small neutral action button used in tables */
.ci-btn-table {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--electric);
  border: 1px solid rgba(0, 255, 106, 0.20);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.ci-btn-table:hover {
  background: rgba(0, 200, 80, 0.10);
  border-color: var(--electric);
}

/* ── Table ───────────────────────────────────────────────────────────────── */

.ci-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.ci-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(10, 36, 56, 0.4);
}

.ci-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(195, 210, 235, 0.06);
  color: var(--ink);
  vertical-align: middle;
}

.ci-table tr:last-child td {
  border-bottom: none;
}

.ci-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */

.ci-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.ci-modal-box {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.ci-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--ink);
  font-family: Georgia, serif;
}

.ci-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.ci-modal-close:hover {
  color: var(--ink);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

.ci-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  transform: translateY(8px);
  z-index: 200;
  max-width: 360px;
  line-height: 1.4;
}

.ci-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.ci-toast.success {
  border-color: #34d399;
}

.ci-toast.error {
  border-color: var(--rust);
}

.ci-toast.info {
  border-color: var(--electric);
}

/* ── Access denied ───────────────────────────────────────────────────────── */

.ci-access-denied {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
  padding: 40px 24px;
  text-align: center;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */

.ci-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

/* ── Helper copy ─────────────────────────────────────────────────────────── */

.ci-helper-copy {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

/* ── Check groups ────────────────────────────────────────────────────────── */

.ci-check-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ci-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink);
  user-select: none;
}

.ci-check-item input[type="checkbox"],
.ci-check-item input[type="radio"] {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Score factor row (used by JS) ───────────────────────────────────────── */

.ci-factor-row {
  margin-bottom: 14px;
}

.ci-factor-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 2px;
}

.ci-factor-name {
  color: var(--ink);
}

.ci-factor-score {
  color: var(--muted);
  font-size: 0.78rem;
}

/* ── Reason item (used by JS) ────────────────────────────────────────────── */

.ci-reason-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(195, 210, 235, 0.06);
  font-size: 0.85rem;
}

.ci-reason-item:last-child {
  border-bottom: none;
}

.ci-reason-code {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(127, 163, 220, 0.14);
  color: var(--navy);
  margin-top: 1px;
}

.ci-reason-text {
  color: var(--ink);
  line-height: 1.4;
}

/* ── Missing data flag (used by JS) ──────────────────────────────────────── */

.ci-missing-flag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 0.85rem;
  color: var(--green);
  border-bottom: 1px solid rgba(195, 210, 235, 0.06);
}

.ci-missing-flag:last-child {
  border-bottom: none;
}

/* ── Result / feedback areas ─────────────────────────────────────────────── */

.ci-result-success {
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 8px;
  padding: 12px 16px;
  color: #34d399;
  font-size: 0.88rem;
}

.ci-result-error {
  background: rgba(216, 106, 82, 0.08);
  border: 1px solid rgba(216, 106, 82, 0.25);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--rust);
  font-size: 0.88rem;
}

.ci-result-info {
  background: rgba(0, 200, 80, 0.08);
  border: 1px solid rgba(0, 200, 80, 0.20);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--electric);
  font-size: 0.88rem;
}

/* ── Check progress item (used by JS) ────────────────────────────────────── */

.ci-check-progress-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(195, 210, 235, 0.06);
  font-size: 0.88rem;
}

.ci-check-progress-item:last-child {
  border-bottom: none;
}

.ci-check-progress-label {
  flex: 1;
  color: var(--ink);
}

/* ── Consent record (used by JS) ─────────────────────────────────────────── */

.ci-consent-record {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(195, 210, 235, 0.06);
  font-size: 0.85rem;
}

.ci-consent-record:last-child {
  border-bottom: none;
}

.ci-consent-record-meta {
  flex: 1;
  min-width: 0;
}

.ci-consent-record-type {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.ci-consent-record-date {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Pagination row ──────────────────────────────────────────────────────── */

.ci-pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ── Scrollbar (Webkit) ──────────────────────────────────────────────────── */

.ci-sidebar::-webkit-scrollbar,
.ci-main::-webkit-scrollbar,
.ci-modal-box::-webkit-scrollbar {
  width: 6px;
}

.ci-sidebar::-webkit-scrollbar-track,
.ci-main::-webkit-scrollbar-track,
.ci-modal-box::-webkit-scrollbar-track {
  background: transparent;
}

.ci-sidebar::-webkit-scrollbar-thumb,
.ci-main::-webkit-scrollbar-thumb,
.ci-modal-box::-webkit-scrollbar-thumb {
  background: rgba(195, 210, 235, 0.14);
  border-radius: 3px;
}

/* ── Loading spinner (utility) ───────────────────────────────────────────── */

@keyframes ci-spin {
  to { transform: rotate(360deg); }
}

.ci-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 255, 106, 0.22);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: ci-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .ci-layout {
    flex-direction: column;
  }

  .ci-sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
    padding: 8px 4px;
    gap: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .ci-nav-btn {
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .ci-nav-btn.active {
    border-bottom-color: var(--green);
    border-left-color: transparent;
  }

  .ci-main {
    padding: 16px;
  }

  .ci-card-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ci-header-subtitle {
    display: none;
  }

  .ci-score-number {
    font-size: 3rem;
  }
}

@media (max-width: 480px) {
  .ci-card-grid {
    grid-template-columns: 1fr;
  }

  .ci-btn-row {
    flex-direction: column;
  }

  .ci-btn-primary,
  .ci-btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .ci-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}
