/* P2P Stealth Pro - Admin Dashboard Dark SaaS Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-main: #0b0e14;
  --bg-card: #121721;
  --bg-card-hover: #161c29;
  --bg-card-alt: #1a2232;
  --border-subtle: #1e293b;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(61, 214, 140, 0.35);

  --primary: #3dd68c;
  --primary-hover: #34be7b;
  --primary-glow: rgba(61, 214, 140, 0.18);
  --primary-text: #0b0e14;

  --accent-cyan: #38bdf8;
  --accent-purple: #a855f7;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --status-active: #3dd68c;
  --status-pending: #f59e0b;
  --status-suspended: #ef4444;
  --status-expired: #94a3b8;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px -5px rgba(61, 214, 140, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #253147;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Layout Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 14, 20, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, rgba(61, 214, 140, 0.15) 0%, rgba(56, 189, 248, 0.1) 100%);
  border: 1px solid rgba(61, 214, 140, 0.3);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.logo-icon {
  font-size: 1.15rem;
}

.badge-version {
  background: rgba(61, 214, 140, 0.25);
  color: var(--primary);
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  font-weight: 700;
  margin-left: 0.35rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.7);
  animation: pulse-ring 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(61, 214, 140, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(61, 214, 140, 0);
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-email-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-light);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.admin-email-badge span.email-text {
  color: var(--text-primary);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 2px 10px rgba(61, 214, 140, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card-alt);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  background: #232c3f;
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
  background: rgba(245, 158, 11, 0.25);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.775rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 0.45rem;
  border-radius: var(--radius-md);
  background: var(--bg-card-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-icon:hover {
  color: var(--text-primary);
  background: #232c3f;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Config Banner (shown if Supabase unconfigured) */
.config-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(239, 68, 68, 0.15) 100%);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.config-banner-text h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 0.25rem;
}

.config-banner-text p {
  font-size: 0.85rem;
  color: #cbd5e1;
}

/* Auth Login Card */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 65vh;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.auth-card-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-card-header .lock-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.auth-card-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #ffffff;
}

.auth-card-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.form-control {
  width: 100%;
  background: #0d121c;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
  color: #475569;
}

.auth-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  margin-bottom: 1.25rem;
  display: none;
}
.auth-alert.show {
  display: block;
}
.auth-alert.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

/* Metrics Section */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.metric-info h3 {
  font-size: 0.775rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.1;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.metric-icon.blue {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
}
.metric-icon.amber {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
}
.metric-icon.green {
  background: rgba(61, 214, 140, 0.12);
  color: #3dd68c;
}
.metric-icon.rose {
  background: rgba(244, 63, 94, 0.12);
  color: #f43f5e;
}

/* Pending Approvals Section */
.pending-section {
  background: linear-gradient(135deg, #131b2b 0%, #15222e 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px -2px rgba(245, 158, 11, 0.08);
}

.pending-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.pending-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.pending-title h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

.pending-count-badge {
  background: var(--accent-amber);
  color: #000;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
}

.pending-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pending-item {
  background: rgba(18, 23, 33, 0.85);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: border-color var(--transition-fast);
}

.pending-item:hover {
  border-color: rgba(245, 158, 11, 0.4);
}

.pending-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.pending-user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pending-user-email {
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.pending-user-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pending-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

/* User Management Section */
.users-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.users-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  max-width: 600px;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-box input {
  padding-left: 2.25rem;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}

.filter-select {
  background: #0d121c;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
  cursor: pointer;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Table */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

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

.data-table th {
  background: #0d121c;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  color: #cbd5e1;
}

.data-table tbody tr {
  transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.725rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge.status-active {
  background: rgba(61, 214, 140, 0.15);
  color: #3dd68c;
  border: 1px solid rgba(61, 214, 140, 0.3);
}

.badge.status-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge.status-suspended {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge.status-expired {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge.tier-free_trial,
.badge.tier-trial {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge.tier-pro_monthly,
.badge.tier-monthly {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge.tier-lifetime {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(236, 72, 153, 0.2));
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.device-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.775rem;
  font-family: 'JetBrains Mono', monospace;
  background: #0d121c;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  color: #94a3b8;
}

.device-chip.active {
  border-color: rgba(61, 214, 140, 0.4);
  color: #e2e8f0;
}

.device-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748b;
}

.device-chip.active .dot {
  background: var(--primary);
  box-shadow: 0 0 5px var(--primary);
}

.user-cell-title {
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.user-cell-sub {
  font-size: 0.775rem;
  color: var(--text-muted);
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.1rem 0.25rem;
  transition: color var(--transition-fast);
}

.copy-btn:hover {
  color: var(--text-primary);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity var(--transition-normal);
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: #0d121c;
}

.preset-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-card);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.85rem;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.toast-success {
  border-left: 4px solid var(--primary);
}

.toast.toast-error {
  border-left: 4px solid var(--accent-rose);
}

.toast.toast-info {
  border-left: 4px solid var(--accent-cyan);
}

.toast.toast-warning {
  border-left: 4px solid var(--accent-amber);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .main-content {
    padding: 1rem;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .pending-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .pending-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar-left {
    max-width: 100%;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right {
    width: 100%;
    justify-content: space-between;
  }
}
