/* =======================================================
   ADMIN & REAL-TIME LOGS CONSOLE STYLING
   Streamer Toolkit Suite 2.0
   ======================================================= */

:root {
  --admin-bg: #090a10;
  --admin-surface: #11131f;
  --admin-card: rgba(22, 25, 41, 0.85);
  --admin-border: rgba(147, 51, 234, 0.2);
  --admin-border-hover: rgba(168, 85, 247, 0.5);
  --admin-primary: #9333ea;
  --admin-accent: #06b6d4;
  --admin-success: #10b981;
  --admin-warning: #f59e0b;
  --admin-danger: #ef4444;
  --admin-twitch: #a855f7;
  --admin-spotify: #1db954;
  --admin-text-main: #f3f4f6;
  --admin-text-muted: #9ca3af;
  --admin-term-bg: #06070a;
}

body.admin-body {
  background-color: var(--admin-bg);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(147, 51, 234, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(29, 185, 84, 0.04) 0%, transparent 60%);
  color: var(--admin-text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.admin-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* Header & Health Meters */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #9333ea, #06b6d4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 0 20px rgba(147, 51, 234, 0.4);
}

.admin-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 30%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.admin-badge {
  background: rgba(147, 51, 234, 0.2);
  border: 1px solid rgba(147, 51, 234, 0.4);
  color: #c084fc;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-nav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-admin {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--admin-text-main);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-admin:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-admin-primary {
  background: linear-gradient(135deg, #9333ea, #7c3aed);
  border: 1px solid #a855f7;
  color: #fff;
  box-shadow: 0 4px 14px rgba(147, 51, 234, 0.35);
}

.btn-admin-primary:hover {
  background: linear-gradient(135deg, #a855f7, #9333ea);
  box-shadow: 0 6px 20px rgba(147, 51, 234, 0.5);
}

/* System Health Cards Grid */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.health-card {
  background: var(--admin-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.health-card:hover {
  border-color: var(--admin-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.health-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.health-service-name {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--admin-text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6b7280;
  position: relative;
}

.health-status-dot.active {
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
}

.health-status-dot.active::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: #10b981;
  opacity: 0.4;
  animation: pulse-dot 1.8s infinite;
}

.health-status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}

@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

.health-value-main {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.health-meta-sub {
  font-size: 0.78rem;
  color: var(--admin-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tabs */
.admin-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 20px;
  overflow-x: auto;
}

.admin-tab {
  background: transparent;
  border: none;
  color: var(--admin-text-muted);
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.admin-tab:hover {
  color: var(--admin-text-main);
}

.admin-tab.active {
  color: #c084fc;
  border-bottom-color: #a855f7;
  background: rgba(147, 51, 234, 0.05);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Live Terminal Log Viewer */
.terminal-wrapper {
  position: relative;
  background: var(--admin-term-bg);
  border: 1px solid rgba(147, 51, 234, 0.25);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  height: 600px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(147, 51, 234, 0.1);
  overflow: hidden;
}

/* Floating Jump to Realtime Button */
.btn-jump-realtime {
  position: absolute;
  bottom: 24px;
  right: 28px;
  z-index: 100;
  background: linear-gradient(135deg, #9333ea, #7c3aed);
  border: 1px solid #c084fc;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(147, 51, 234, 0.4), 0 0 12px rgba(192, 132, 252, 0.3);
  animation: bounceJump 1.8s infinite ease-in-out;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-jump-realtime:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 28px rgba(147, 51, 234, 0.6), 0 0 18px rgba(192, 132, 252, 0.5);
  background: linear-gradient(135deg, #a855f7, #9333ea);
}

.unread-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

@keyframes bounceJump {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.terminal-toolbar {
  background: #0d0f18;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.terminal-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--admin-text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--admin-text-main);
}

.filter-chip.active {
  background: rgba(147, 51, 234, 0.25);
  border-color: #a855f7;
  color: #fff;
  box-shadow: 0 0 10px rgba(147, 51, 234, 0.3);
}

.terminal-search-box {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 10px;
  gap: 8px;
}

.terminal-search-input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.8rem;
  outline: none;
  width: 180px;
}

.terminal-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.terminal-btn-icon {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--admin-text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.terminal-btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
}

.terminal-logs-container {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  scroll-behavior: smooth;
}

.terminal-logs-container::-webkit-scrollbar {
  width: 8px;
}
.terminal-logs-container::-webkit-scrollbar-track {
  background: #090a10;
}
.terminal-logs-container::-webkit-scrollbar-thumb {
  background: #1f2438;
  border-radius: 4px;
}

.log-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 3px 6px;
  border-radius: 4px;
  transition: background 0.1s ease;
  word-break: break-word;
}

.log-line:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-ts {
  color: #4b5563;
  font-size: 0.75rem;
  flex-shrink: 0;
  user-select: none;
}

.log-tag-badge {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.badge-HTTP { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-TWITCH { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-SPOTIFY { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-IRC { background: rgba(236, 72, 153, 0.15); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }
.badge-SUBATHON { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-ERROR { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); font-weight: 800; }
.badge-AUTH { background: rgba(14, 165, 233, 0.15); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.3); }
.badge-SYSTEM { background: rgba(156, 163, 175, 0.15); color: #d1d5db; border: 1px solid rgba(156, 163, 175, 0.3); }

.log-content {
  color: #e5e7eb;
  flex: 1;
}

.log-content.log-err {
  color: #fca5a5;
  font-weight: 600;
}

/* Diagnostics & Tools Panel */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.tool-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  padding: 24px;
}

.tool-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-card-desc {
  font-size: 0.85rem;
  color: var(--admin-text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.diagnostic-output-box {
  background: #07090e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  font-family: monospace;
  font-size: 0.78rem;
  color: #a7f3d0;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 14px;
  white-space: pre-wrap;
  display: none;
}

/* Users Table */
.admin-table-wrapper {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.admin-table th {
  background: rgba(0, 0, 0, 0.3);
  padding: 14px 18px;
  color: var(--admin-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

/* Modal Overlay Gating for Unauthenticated users */
.gating-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(6, 7, 12, 0.88);
  backdrop-filter: blur(10px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gating-card {
  background: linear-gradient(145deg, #131627, #0d0f1b);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 20px;
  max-width: 460px;
  width: 100%;
  padding: 36px 30px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(147, 51, 234, 0.2);
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.gating-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #9333ea, #ec4899);
  border-radius: 18px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 0 24px rgba(147, 51, 234, 0.5);
}

.gating-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 10px;
  color: #fff;
}

.gating-desc {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-bottom: 24px;
  line-height: 1.6;
}

.gating-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
