/* ==========================================================================
   UID MANAGEMENT PLATFORM - PREMIUM SAAS DESIGN SYSTEM
   Compact, High-Density, Modern Dark/Light SaaS Aesthetic
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Surface Layers - Deep Dark Obsidian (Default) */
  --bg-app: #06080d;
  --bg-sidebar: #090d15;
  --bg-card: #0d121f;
  --bg-card-hover: #12192b;
  --bg-card-active: #172036;
  --bg-elevated: #161e31;
  --bg-input: #0a0e18;
  --bg-overlay: rgba(6, 8, 13, 0.85);

  /* Border Tokens */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);
  --border-brand: rgba(99, 102, 241, 0.40);
  --border-brand-glow: rgba(99, 102, 241, 0.25);

  /* Typography & Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-disabled: #475569;

  /* Brand Accents - Electric Indigo & Bright Sky */
  --brand-primary: #6366f1;
  --brand-primary-hover: #4f46e5;
  --brand-secondary: #38bdf8;
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #38bdf8 100%);
  --brand-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
  --brand-gradient-subtle: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(56, 189, 248, 0.08) 100%);
  --brand-glow: 0 0 30px rgba(99, 102, 241, 0.3);

  /* Status Colors with Glowing Badges */
  --status-active-bg: rgba(16, 185, 129, 0.10);
  --status-active-text: #34d399;
  --status-active-border: rgba(16, 185, 129, 0.30);
  --status-active-glow: 0 0 12px rgba(16, 185, 129, 0.25);

  --status-paused-bg: rgba(245, 158, 11, 0.10);
  --status-paused-text: #fbbf24;
  --status-paused-border: rgba(245, 158, 11, 0.30);
  --status-paused-glow: 0 0 12px rgba(245, 158, 11, 0.25);

  --status-expired-bg: rgba(239, 68, 68, 0.10);
  --status-expired-text: #f87171;
  --status-expired-border: rgba(239, 68, 68, 0.30);
  --status-expired-glow: 0 0 12px rgba(239, 68, 68, 0.25);

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 12px -2px rgba(0, 0, 0, 0.6), 0 3px 6px -3px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.7), 0 6px 12px -6px rgba(0, 0, 0, 0.6);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Mode Overrides */
[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-card-active: #e2e8f0;
  --bg-elevated: #ffffff;
  --bg-input: #f8fafc;
  --bg-overlay: rgba(248, 250, 252, 0.85);

  --border-subtle: rgba(0, 0, 0, 0.07);
  --border-medium: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.20);
  --border-brand: rgba(99, 102, 241, 0.5);
  --border-brand-glow: rgba(99, 102, 241, 0.15);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 12px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Reset & Global */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

code, pre, .font-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Compact Sidebar */
.sidebar {
  width: 240px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform var(--transition-smooth);
}

.sidebar-header {
  height: 60px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-md);
  filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.4));
  flex-shrink: 0;
}

.brand-logo-img-lg {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: var(--radius-md);
  filter: drop-shadow(0 0 14px rgba(99, 102, 241, 0.5));
}

.brand-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  padding: 1rem 0.65rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item:hover {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  font-weight: 600;
  border: 1px solid var(--border-brand);
}

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-app);
}

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--border-subtle);
  background-color: rgba(6, 8, 13, 0.8);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

[data-theme="light"] .topbar {
  background-color: rgba(255, 255, 255, 0.85);
}

.page-container {
  padding: 1.5rem 1.75rem;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Cards - Compact, High utility */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--border-medium);
}

.card-stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  overflow: hidden;
}

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

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

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

.btn-primary {
  background: var(--brand-gradient);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  background: var(--brand-gradient-hover);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-elevated);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-strong);
}

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

.btn-danger:hover {
  background-color: #ef4444;
  color: #ffffff;
}

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

.btn-icon {
  padding: 0.45rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

/* Glowing Pulsing Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge-active {
  background: var(--status-active-bg);
  color: var(--status-active-text);
  border: 1px solid var(--status-active-border);
}
.badge-active .badge-dot { background: #10b981; box-shadow: 0 0 6px #10b981; }

.badge-paused {
  background: var(--status-paused-bg);
  color: var(--status-paused-text);
  border: 1px solid var(--status-paused-border);
}
.badge-paused .badge-dot { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }

.badge-expired {
  background: var(--status-expired-bg);
  color: var(--status-expired-text);
  border: 1px solid var(--status-expired-border);
}
.badge-expired .badge-dot { background: #ef4444; box-shadow: 0 0 6px #ef4444; }

/* Tables - Compact, High readability */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
}

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

.data-table th {
  padding: 0.75rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 0.75rem 1rem;
  font-size: 0.84rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

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

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background-color: var(--bg-card);
}

.form-helper {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Progress Bars */
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background-color: var(--bg-app);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-bar-fill {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: var(--radius-full);
  transition: width var(--transition-smooth);
}

/* Modals & Drawers */
.modal-backdrop, .modal-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.active, .modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card, .modal {
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96);
  transition: transform var(--transition-smooth);
}

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

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

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-body {
  padding: 1.25rem;
}

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

/* Stacked Toasts */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 280px;
  max-width: 420px;
  animation: toastSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success { border-left: 3px solid #10b981; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-warning { border-left: 3px solid #f59e0b; }
.toast-info { border-left: 3px solid #6366f1; }

@keyframes toastSlide {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Mobile Responsiveness */
.mobile-nav-toggle {
  display: none;
}

@media (max-width: 900px) {
  .mobile-nav-toggle {
    display: inline-flex;
  }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar {
    padding: 0 1rem;
  }
  .page-container {
    padding: 1rem;
  }
}
