/* Super-admin gateway styles */
@import url("./tokens.css");

.admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}

.admin-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.admin-login-card .logo-lg {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: contain;
  margin-bottom: 20px;
  display: block;
}

.admin-login-card h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.admin-login-card .lead {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 24px;
  line-height: 1.5;
}

.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.admin-nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.admin-nav-brand .badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.admin-nav-brand span {
  font-weight: 700;
  font-size: 0.92rem;
}

.admin-nav-brand small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 500;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 600;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.admin-main {
  padding: 24px 28px;
  overflow-y: auto;
  max-height: 100vh;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  animation: fadeInDown 0.35s ease both;
}

.admin-topbar h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.admin-topbar .meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 600;
}

.live-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-card .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 6px;
  line-height: 1;
}

.stat-card .sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
}

.stat-card.accent { border-color: var(--accent-border); background: var(--accent-soft); }
.stat-card.accent .value { color: var(--accent); }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  animation: fadeInUp 0.4s ease both;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.panel-header h3 {
  font-size: 0.88rem;
  font-weight: 700;
}

.panel-body { padding: 0; }

.panel-body.padded { padding: 16px 18px; }

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
  position: sticky;
  top: 0;
}

.data-table tr {
  transition: background 0.12s ease;
}

.data-table tbody tr:hover { background: var(--accent-soft); }

.data-table .mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.data-table .truncate {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.pagination-btns { display: flex; gap: 6px; }

/* Health indicators */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.health-item {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.health-item .name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.health-item .status {
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 6px;
}

.health-item.ok .status { color: var(--success); }
.health-item.warn .status { color: var(--warning); }
.health-item.err .status { color: var(--error); }

/* Config kv */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.kv-item {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.kv-item .k {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.kv-item .v {
  font-size: 0.84rem;
  font-weight: 600;
  margin-top: 4px;
  word-break: break-all;
}

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: fadeIn 0.3s ease both;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar input {
  flex: 1;
  min-width: 180px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.84rem;
}

.btn-sm {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.btn-sm:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn-sm.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-sm.danger {
  color: var(--error);
  border-color: var(--error-border);
  background: var(--error-soft);
}

.btn-sm.danger:hover {
  background: var(--error);
  color: #fff;
}

.latency-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 8px;
}

.latency-bar-fill {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Activity chart */
.activity-row {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.8rem;
}

.activity-label { color: var(--muted); font-weight: 500; }

.activity-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.activity-bar {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #1d4ed8);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 4px;
}

.activity-value {
  font-weight: 700;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav {
    position: fixed;
    left: -260px;
    z-index: 40;
    transition: left 0.3s ease;
    width: 240px;
  }
  .admin-nav.open { left: 0; }
  .admin-main { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
