/* ═══════════════════════════════════════════════════
   MXCI Admin Dashboard — Dark Carbon Premium Theme
   ═══════════════════════════════════════════════════ */

:root {
  --admin-bg:       #0d1117;
  --admin-surface:  #161b27;
  --admin-card:     #1c2333;
  --admin-elevated: #21293a;
  --admin-border:   rgba(48,54,71,1);
  --admin-border-s: rgba(255,255,255,.06);

  --indigo:         #6366f1;
  --indigo-dim:     rgba(99,102,241,.14);
  --indigo-muted:   rgba(99,102,241,.08);
  --cyan:           #06b6d4;
  --green:          #10b981;
  --amber:          #f59e0b;
  --rose:           #f43f5e;

  --text:           #e6edf3;
  --muted:          #8b949e;
  --subtle:         #4a5568;

  --gradient:       linear-gradient(135deg, #6366f1, #7c3aed, #06b6d4);

  --radius-card:    1rem;
  --radius-sm:      .6rem;
}

/* ─── Base overrides ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--admin-bg);
  color: var(--text);
  min-height: 100vh;
}

/* Reset Bootstrap dark card bg */
[data-bs-theme="dark"] .card {
  --bs-card-bg: var(--admin-card);
}

::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--admin-surface); }
::-webkit-scrollbar-thumb  { background: var(--subtle); border-radius: 3px; }

/* ─── Layout ──────────────────────────────────────── */
.admin-shell {
  max-width: 1680px;
}

/* ─── Sidebar ─────────────────────────────────────── */
.admin-sidebar {
  background: var(--admin-surface) !important;
  border: 1px solid var(--admin-border) !important;
  border-radius: var(--radius-card) !important;
  position: sticky;
  top: 1.5rem;
}

/* Brand mark */
.brand-mark {
  width: 3.1rem;
  height: 3.1rem;
  border-radius: .85rem;
  background: var(--gradient);
  display: grid;
  place-items: center;
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .04em;
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(99,102,241,.35);
}

.sidebar-subtitle {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 400;
}

.sidebar-divider {
  height: 1px;
  background: var(--admin-border);
}

/* Auth pill */
.auth-pill {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .85rem;
  border-radius: .6rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--admin-border-s);
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.4;
  word-break: break-all;
}

.auth-pill.signed-in {
  background: rgba(16,185,129,.1);
  border-color: rgba(16,185,129,.25);
  color: #6ee7b7;
}

.auth-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--subtle);
  flex-shrink: 0;
}

.auth-pill.signed-in .auth-dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16,185,129,.5);
}

/* Field label */
.field-label {
  display: block;
  font-size: .73rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: .4rem;
}

/* Custom input */
.input-group-custom {
  position: relative;
}

.input-icon {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  font-size: .85rem;
  pointer-events: none;
  z-index: 2;
}

.custom-input,
.custom-select {
  background: var(--admin-elevated) !important;
  border: 1px solid var(--admin-border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  font-size: .88rem !important;
  padding-left: 2.25rem !important;
  transition: border-color .2s, box-shadow .2s !important;
}

.custom-select {
  padding-left: .8rem !important;
  appearance: auto;
}

.custom-input:focus,
.custom-select:focus {
  border-color: rgba(99,102,241,.5) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15) !important;
  background: var(--admin-card) !important;
  outline: none !important;
}

.custom-input::placeholder { color: var(--subtle) !important; }

/* Buttons */
.btn-primary-custom {
  background: var(--gradient);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .88rem;
  padding: .65rem 1rem;
  transition: transform .15s, box-shadow .15s, opacity .2s;
  box-shadow: 0 4px 16px rgba(99,102,241,.35);
}

.btn-primary-custom:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(99,102,241,.45);
  color: #fff;
}

.btn-primary-custom:disabled {
  opacity: .45;
  pointer-events: none;
}

.btn-google-custom {
  background: var(--admin-elevated);
  border: 1px solid var(--admin-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: .88rem;
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, background .2s;
}

.btn-google-custom:hover {
  border-color: rgba(148,163,184,.35);
  background: rgba(255,255,255,.07);
  color: var(--text);
}

.btn-google-custom:disabled { opacity: .45; pointer-events: none; }

.btn-logout-custom {
  background: rgba(244,63,94,.1);
  border: 1px solid rgba(244,63,94,.25);
  color: #fca5b8;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: .88rem;
  padding: .65rem 1rem;
  transition: background .2s, border-color .2s;
}

.btn-logout-custom:hover {
  background: rgba(244,63,94,.18);
  border-color: rgba(244,63,94,.4);
  color: #fda4af;
}

.btn-refresh {
  background: var(--admin-elevated);
  border: 1px solid var(--admin-border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  padding: .62rem 1rem;
  transition: border-color .2s, color .2s, background .2s;
  height: 100%;
}

.btn-refresh:hover {
  border-color: rgba(99,102,241,.4);
  color: var(--text);
  background: var(--indigo-muted);
}

.btn-refresh:disabled { opacity: .5; pointer-events: none; }

/* Info notes */
.info-note {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  font-size: .77rem;
  color: var(--muted);
  line-height: 1.5;
}

.info-note-icon {
  width: 26px;
  height: 26px;
  border-radius: .4rem;
  background: rgba(99,102,241,.12);
  color: #a5b4fc;
  display: grid;
  place-items: center;
  font-size: .78rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.info-note code {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--admin-border-s);
  color: #a5b4fc;
  border-radius: 4px;
  padding: .05rem .3rem;
  font-size: .73rem;
}

/* ─── Metric Cards ────────────────────────────────── */
.metric-card {
  background: var(--admin-card);
  border-radius: var(--radius-card);
  border: 1px solid var(--admin-border);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-left-width: 3px !important;
  transition: transform .2s, box-shadow .2s;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,.25);
}

.metric-card-blue   { border-left-color: #60a5fa !important; }
.metric-card-indigo { border-left-color: var(--indigo) !important; }
.metric-card-green  { border-left-color: #34d399 !important; }
.metric-card-amber  { border-left-color: #fbbf24 !important; }

.metric-card-icon {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: .7rem;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.icon-blue   { background: rgba(96,165,250,.14); color: #60a5fa; }
.icon-indigo { background: rgba(99,102,241,.14); color: #a5b4fc; }
.icon-green  { background: rgba(52,211,153,.14);  color: #34d399; }
.icon-amber  { background: rgba(251,191,36,.14);  color: #fbbf24; }

.metric-card-body { min-width: 0; }

.metric-label {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
  white-space: nowrap;
}

.metric-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  margin-top: .15rem;
  color: var(--text);
}

/* ─── Filter Bar ──────────────────────────────────── */
.filter-bar {
  background: var(--admin-surface) !important;
  border: 1px solid var(--admin-border) !important;
  border-radius: var(--radius-card) !important;
}

/* ─── Table Card ──────────────────────────────────── */
.table-card {
  background: var(--admin-surface) !important;
  border: 1px solid var(--admin-border) !important;
  border-radius: var(--radius-card) !important;
  overflow: hidden;
}

.table-card-header {
  padding: 1.5rem 1.75rem 1.25rem;
  border-bottom: 1px solid var(--admin-border);
}

.table-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 .2rem;
}

.table-subtitle {
  font-size: .78rem;
  color: var(--muted);
  margin: 0;
}

.results-badge {
  background: var(--admin-elevated);
  border: 1px solid var(--admin-border);
  color: var(--muted);
  border-radius: 999px;
  padding: .25rem .75rem;
  font-size: .73rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ─── Table ───────────────────────────────────────── */
.admin-table {
  color: var(--text) !important;
  margin: 0 !important;
}

.admin-table thead tr {
  background: var(--admin-card) !important;
}

.admin-table thead th {
  background: var(--admin-card) !important;
  border-color: var(--admin-border) !important;
  color: var(--muted) !important;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .9rem 1.25rem !important;
  white-space: nowrap;
}

.admin-table tbody td {
  border-color: var(--admin-border-s) !important;
  padding: .95rem 1.25rem !important;
  font-size: .87rem;
  vertical-align: middle;
  background: transparent !important;
  color: var(--text) !important;
}

.admin-table tbody tr {
  cursor: pointer;
  transition: background .15s;
}

.admin-table tbody tr:hover td {
  background: rgba(99,102,241,.07) !important;
}

.admin-table tbody tr.table-active td {
  background: rgba(99,102,241,.12) !important;
}

/* Avatar */
.avatar-pill {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: .78rem;
  flex-shrink: 0;
}

/* Tier badges */
.tier-badge {
  border-radius: 999px;
  padding: .28rem .75rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  display: inline-block;
}

.tier-standard {
  background: rgba(99,102,241,.14);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,.25);
}

.tier-ad_free {
  background: rgba(52,211,153,.12);
  color: #6ee7b7;
  border: 1px solid rgba(52,211,153,.25);
}

.tier-ad {
  background: rgba(107,114,128,.12);
  color: #9ca3af;
  border: 1px solid rgba(107,114,128,.2);
}

/* Loading state */
.loading-state {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.75rem;
  font-size: .84rem;
  color: var(--muted);
}

.loading-spinner {
  color: var(--indigo) !important;
}

/* Empty state */
.empty-state-cell {
  text-align: center;
  color: var(--muted) !important;
  font-size: .87rem !important;
  padding: 4rem 1rem !important;
}

.empty-state-icon {
  font-size: 2rem;
  opacity: .35;
}

/* ─── Detail Card ─────────────────────────────────── */
.detail-card {
  background: var(--admin-surface) !important;
  border: 1px solid var(--admin-border) !important;
  border-radius: var(--radius-card) !important;
  position: sticky;
  top: 1.5rem;
  overflow: hidden;
}

.detail-card-header {
  padding: 1.5rem 1.75rem 1.25rem;
  border-bottom: 1px solid var(--admin-border);
}

.detail-empty {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  padding: 3.5rem 1rem;
}

.detail-empty-icon {
  font-size: 2.5rem;
  opacity: .3;
}

/* Detail grid */
.detail-grid {
  display: grid;
  gap: .65rem;
}

.detail-tile {
  background: var(--admin-card);
  border: 1px solid var(--admin-border-s);
  border-radius: .75rem;
  padding: .8rem 1rem;
  transition: border-color .2s;
}

.detail-tile:hover { border-color: rgba(99,102,241,.25); }

.detail-label {
  display: block;
  font-size: .67rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: .25rem;
  font-weight: 500;
}

.detail-value {
  display: block;
  color: var(--text);
  font-size: .87rem;
  word-break: break-all;
  line-height: 1.4;
}

/* AI usage bar in detail */
.ai-usage-bar-track {
  height: 5px;
  background: rgba(255,255,255,.08);
  border-radius: 3px;
  margin-top: .4rem;
  overflow: hidden;
}

.ai-usage-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--gradient);
  transition: width .4s ease;
}

/* ─── Bootstrap Alert overrides for dark ──────────── */
[data-bs-theme="dark"] .alert-danger {
  background: rgba(244,63,94,.12) !important;
  border-color: rgba(244,63,94,.25) !important;
  color: #fca5b8 !important;
}

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 1199.98px) {
  .admin-sidebar,
  .detail-card { position: static; }
}

@media (max-width: 767.98px) {
  .metric-value { font-size: 1.65rem; }
  .admin-table thead th,
  .admin-table tbody td { padding: .75rem .85rem !important; }
}
