@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- Modern Dense Dashboard Theme Design System --- */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Custom HSL Color Palette */
  --bg-main: #090c15;
  --bg-card: rgba(17, 22, 39, 0.75);
  --bg-card-hover: rgba(26, 33, 56, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(0, 242, 254, 0.3);

  --color-primary: #00f2fe;
  --color-primary-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-bright: #ffffff;

  /* Overriding Pico CSS custom properties */
  --pico-font-family-sans-serif: var(--font-sans);
  --pico-font-family-monospace: var(--font-mono);
  --pico-background-color: var(--bg-main);
  --pico-color: var(--text-main);
  --pico-muted-color: var(--text-muted);
  --pico-card-background-color: var(--bg-card);
  --pico-card-border-color: var(--border-color);
  --pico-primary: #00f2fe;
  --pico-primary-hover: #4facfe;
  --pico-primary-background: var(--color-primary-gradient);
  --pico-form-element-background-color: rgba(10, 12, 22, 0.8);
  --pico-form-element-border-color: var(--border-color);
  --pico-form-element-active-border-color: var(--color-primary);
  --pico-form-element-focus-color: rgba(0, 242, 254, 0.15);
}

/* Base Body Modifications */
body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(0, 242, 254, 0.03) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(79, 172, 254, 0.03) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-bright);
  font-weight: 600;
  letter-spacing: -0.02em;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: all 0.2s ease;
}
a:hover {
  color: #4facfe;
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.3);
}

code, pre, .mono {
  font-family: var(--font-mono) !important;
  font-size: 0.825rem;
}

/* Glassmorphism Containers */
article {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1.5rem !important;
  margin-bottom: 1.5rem !important;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

article:hover {
  border-color: rgba(0, 242, 254, 0.15) !important;
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 242, 254, 0.03) !important;
}

/* App Nav Navigation Overhaul */
nav.app-nav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  padding: 0.75rem 1.5rem !important;
  background: rgba(13, 17, 30, 0.8) !important;
  border-bottom: 1px solid var(--border-color) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 1000;
  margin-bottom: 1.5rem;
}

nav.app-nav strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--color-primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-right: 0.5rem;
  letter-spacing: -0.01em;
}

nav.app-nav a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
}

nav.app-nav a:hover, nav.app-nav a.active {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.05);
}

nav.app-nav .spacer {
  flex: 1;
}

/* Header Action Buttons */
.btn-nav-outline {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-main);
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-nav-outline:hover {
  background: var(--border-color);
  color: var(--text-bright);
  border-color: var(--text-muted);
}

/* KPI Statistics Dashboard Widgets */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: transparent;
}

.stat-card.primary::before { background: var(--color-primary-gradient); }
.stat-card.success::before { background: var(--color-success); }
.stat-card.warning::before { background: var(--color-warning); }

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.1;
}

.stat-card .stat-trend {
  font-size: 0.7rem;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Modern Compact Dense Table styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem !important;
  border-bottom: 2px solid var(--border-color) !important;
}

table td {
  padding: 0.65rem 1rem !important;
  border-bottom: 1px solid var(--border-color) !important;
  font-size: 0.85rem;
  color: var(--text-main);
  vertical-align: middle;
}

table tbody tr {
  transition: background-color 0.15s ease;
}

table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02) !important;
}

/* Glowing Neon Pills/Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.725rem;
  font-weight: 600;
  line-height: 1.3;
}

.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.pill-ok {
  background: rgba(16, 185, 129, 0.1) !important;
  color: #34d399 !important;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.pill-ok::before {
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
  animation: pulse 2s infinite;
}

.pill-err {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #fca5a5 !important;
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.pill-err::before {
  background: var(--color-error);
  box-shadow: 0 0 8px var(--color-error);
  animation: pulse 1.5s infinite;
}

.pill-none {
  background: rgba(156, 163, 175, 0.1) !important;
  color: #d1d5db !important;
  border: 1px solid rgba(156, 163, 175, 0.25);
}
.pill-none::before {
  background: #9ca3af;
}

.pill-prov {
  background: rgba(59, 130, 246, 0.1) !important;
  color: #93c5fd !important;
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.pill-prov::before {
  background: var(--color-info);
  box-shadow: 0 0 6px var(--color-info);
}

.pill-unprov {
  background: rgba(245, 158, 11, 0.1) !important;
  color: #fde047 !important;
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.pill-unprov::before {
  background: var(--color-warning);
  box-shadow: 0 0 6px var(--color-warning);
}

/* Custom Interactive Controls / Buttons */
button, input[type="submit"], [role="button"] {
  font-family: var(--font-sans);
  font-size: 0.8rem !important;
  font-weight: 600;
  padding: 0.4rem 0.85rem !important;
  margin: 0 !important;
  border-radius: 6px !important;
  border: 1px solid transparent !important;
  background: var(--color-primary-gradient) !important;
  color: #050b14 !important;
  box-shadow: 0 4px 14px 0 rgba(0, 242, 254, 0.2) !important;
  cursor: pointer;
  transition: all 0.2s ease !important;
  width: auto;
}

button:hover, input[type="submit"]:hover, [role="button"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px 0 rgba(0, 242, 254, 0.35) !important;
  filter: brightness(1.1);
}

button:active, input[type="submit"]:active, [role="button"]:active {
  transform: translateY(0);
}

/* Secondary Button Reset (Sleek Outline) */
button.secondary, [role="button"].secondary, a.secondary[role="button"] {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  box-shadow: none !important;
}

button.secondary:hover, [role="button"].secondary:hover, a.secondary[role="button"]:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

/* Danger Button (Contrast / Outline) */
button.contrast.outline, form button.contrast.outline {
  background: transparent !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  color: #fca5a5 !important;
  box-shadow: none !important;
}

button.contrast.outline:hover, form button.contrast.outline:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  border-color: var(--color-error) !important;
  color: var(--text-bright) !important;
}

/* Form Styles & Inputs */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  font-family: var(--font-sans);
  background-color: rgba(10, 14, 25, 0.8) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-bright) !important;
  border-radius: 8px !important;
  padding: 0.5rem 0.75rem !important;
  font-size: 0.85rem !important;
  transition: all 0.2s ease !important;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15) !important;
  outline: none;
}

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem !important;
  display: block;
}

label input, label select, label textarea {
  margin-top: 0.25rem !important;
}

/* Action Container Grid */
.actions {
  display: inline-flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.actions form {
  margin: 0;
  display: inline;
}

/* Glowing password reveal component */
.reveal-box {
  background: rgba(245, 158, 11, 0.03) !important;
  border: 1px solid rgba(245, 158, 11, 0.25) !important;
  padding: 1.25rem !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.05);
  margin-top: 1rem;
}

.password-field {
  font-family: var(--font-mono) !important;
  font-size: 1.15rem !important;
  padding: 0.5rem 0.75rem !important;
  background: rgba(0, 0, 0, 0.4) !important;
  border: 1px solid rgba(245, 158, 11, 0.4) !important;
  color: #fde047 !important;
  border-radius: 6px !important;
  width: 100%;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.password-field:focus {
  border-color: #fde047 !important;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.15) !important;
}

/* Inline copy button */
.copy-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 0.2rem !important;
  margin-left: 0.4rem;
  background: transparent !important;
  border: none !important;
  color: var(--text-muted) !important;
  cursor: pointer;
  border-radius: 4px;
  vertical-align: middle;
  line-height: 1;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
}

.copy-btn:hover {
  color: var(--color-primary) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  transform: none !important;
  box-shadow: none !important;
  filter: none !important;
}

/* Alerts / Flash Errors */
.flash {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.825rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flash-error {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.2);
}

/* Audit Logs Timeline Layout (For extreme density) */
.logs-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 992px) {
  .logs-section {
    grid-template-columns: 1fr 1fr;
  }
}

.logs-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.logs-timeline::-webkit-scrollbar {
  width: 6px;
}
.logs-timeline::-webkit-scrollbar-track {
  background: transparent;
}
.logs-timeline::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.log-entry {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.775rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: all 0.15s ease;
}

.log-entry:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

.log-entry .log-meta {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* Glassmorphic Login Card Viewport override */
.login-container {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 16px !important;
  box-shadow: 0 15px 50px 0 rgba(0, 0, 0, 0.5) !important;
  padding: 2rem !important;
  position: relative;
}

.login-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.1) 0%, rgba(79, 172, 254, 0.05) 50%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}

.login-card h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 0.25rem;
  background: var(--color-primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p.subtitle {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Animations */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(0, 242, 254, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 242, 254, 0);
  }
}

/* HTMX Loading States and Spinners */
button.htmx-request, [role="button"].htmx-request {
  position: relative !important;
  pointer-events: none !important;
  color: transparent !important;
  opacity: 0.8 !important;
}

button.htmx-request::after, [role="button"].htmx-request::after {
  content: "" !important;
  position: absolute !important;
  width: 16px !important;
  height: 16px !important;
  top: calc(50% - 8px) !important;
  left: calc(50% - 8px) !important;
  border: 2px solid transparent !important;
  border-top-color: #050b14 !important;
  border-radius: 50% !important;
  animation: button-loading-spinner 0.8s linear infinite !important;
}

button.secondary.htmx-request::after, [role="button"].secondary.htmx-request::after {
  border-top-color: var(--text-bright) !important;
}

@keyframes button-loading-spinner {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Custom Details Dropdown reset */
details.dropdown-right {
  position: relative !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
}

details.dropdown-right summary {
  list-style: none !important;
  margin: 0 !important;
}

details.dropdown-right summary::-webkit-details-marker,
details.dropdown-right summary::marker {
  display: none !important;
}

details.dropdown-right[open] summary {
  margin-bottom: 0 !important;
}

details.dropdown-right .dropdown-content {
  position: absolute !important;
  right: 0 !important;
  top: calc(100% + 0.35rem) !important;
  background: rgba(18, 24, 38, 0.95) !important;
  border: 1px solid var(--border-color) !important;
  padding: 0.75rem !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
  z-index: 1000 !important;
  width: 14rem !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 500;
  border: 1px solid transparent;
  min-width: 220px;
  max-width: 380px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

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

.toast-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1);
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.1);
}

.toast-info {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

/* Users Grid Layout - Capping Add User, maximizing Active Users */
.users-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 992px) {
  .users-grid {
    grid-template-columns: 360px 1fr;
  }
}

