/* Global app styles */

/* Fixed-width digits and box to prevent jitter while time updates */
:root {
  --time-ago-ch: 12; /* adjust if you show longer strings like "1d 23h ago" */
}

/* iOS notch / safe area support: gently push hero content below the notch in standalone mode */
@supports(padding-top: env(safe-area-inset-top)) {
  /* Add only a small offset so large screens are unaffected */
  .dashboard-hero { padding-top: calc(env(safe-area-inset-top) + 0.35rem); }

  /* Tighten on very small phones so we do not waste vertical space */
  @media (max-width: 480px) {
    .dashboard-hero { padding-top: calc(env(safe-area-inset-top) + 0.25rem); }
  }

  /* If we detect a Dynamic Island style device, increase clearance */
  .dynamic-island .dashboard-hero { padding-top: calc(env(safe-area-inset-top) + 1.15rem); }
  @media (max-width: 480px) {
    .dynamic-island .dashboard-hero { padding-top: calc(env(safe-area-inset-top) + 0.9rem); }
  }
}

/* Global futuristic font stack */
body, button, input, textarea, select {
  font-family: 'Space Grotesk', 'Orbitron', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: .2px;
}

.time-ago {
  display: inline-block;
  width: calc(var(--time-ago-ch) * 1ch);
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Helpful utility if you have other numeric cells */
.numeric {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Responsive YouTube embed (16:9) */
.yt-embed {
  position: relative;
  padding-top: 56.25%;
  margin-bottom: 12px;
  background: #000;
  border-radius: 14px; /* match card softer radius */
  overflow: hidden;
}
.yt-embed .yt-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.yt-embed .yt-open {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0,0,0,.55);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}
.yt-embed .yt-open:hover { background: rgba(0,0,0,.75); }

/* Custom overlay badge */
.yt-embed .yt-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  background: linear-gradient(135deg, rgba(120,90,255,0.85), rgba(60,150,255,0.85));
  color: #fff;
  font-size: .65rem;
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 6px 10px 5px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 2px 6px -2px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,0.12);
  pointer-events: none;
  backdrop-filter: blur(2px) saturate(140%);
}


/* Enhanced dashboard hero layout */
/* Dashboard hero: permanently stacked & centered (remove wide-screen side-by-side) */
.dashboard-hero {
  display: block;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: .6rem;  /* increased breathing room above divider (was .05rem) */
  margin-bottom: .5rem;   /* space below divider before status line (was .18rem) */
}

/* Center icon block */
.dashboard-hero .hero-media {
  margin: 0 auto 1.05rem;
  zoom: 0.75;
}

/* Natural width text */
.dashboard-hero .hero-text { max-width: 100%; margin: 0 auto; }

* {
  font-family: 'Orbitron', 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: 1.5px;
  font-weight: 600;
  text-transform: uppercase;
}

.app-title {
  font-weight: 600;
  font-size: clamp(1.9rem, 2.6vw + 1rem, 2.55rem);
  line-height: 1.08;
}

.app-tagline {
  font-size: .95rem;
  letter-spacing: .25px;
  margin: 0 0 .12rem; /* even smaller gap below tagline */
}

/* Silhouette disc w/ layered glow */
.app-hero-icon {
  position: relative;
  margin: 0 auto;
  width: clamp(210px, 30vw, 280px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  text-align: center;
  isolation: isolate;
  overflow: visible;
}

.app-hero-icon::before,
.app-hero-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 0;
  transition: transform .5s ease, opacity .5s ease;
}

.app-hero-icon::before {
  inset: -10%;
  transform: scale(1.1);
  background: radial-gradient(circle, rgba(142,188,255,0.35), transparent 65%);
  filter: blur(14px);
  opacity: .85;
  animation: haloPulse 8s ease-in-out infinite;
}

.app-hero-icon::after {
  inset: 0;
  background:
    radial-gradient(circle at 34% 26%, rgba(170,204,255,0.85), rgba(96,140,255,0.5) 50%, rgba(24,34,64,0.82) 76%, rgba(6,9,22,0.9) 100%);
  border: 0px solid rgba(190,220,255,0.18);
  box-shadow:
    inset 0 0 32px rgba(64,104,198,0.55),
    inset 0 0 120px rgba(118,156,255,0.33),
    0 14px 38px rgba(3,5,18,0.7);
  backdrop-filter: blur(2px);
  animation: velaGlow 6.5s ease-in-out infinite;
}

/* Silhouette image styling */
.hero-icon-img {
  position: relative;
  z-index: 1;
  display: block;
  width: 85%;
  max-width: 85%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 18px 35px rgba(0,0,0,0.65)) saturate(1.08) contrast(1.05) brightness(1.08);
  transition: transform .45s cubic-bezier(.22,.8,.24,1), filter .45s;
  pointer-events: none;
}

@media (hover:hover) {
  .app-hero-icon:hover::before {
    opacity: 1;
    transform: scale(1.08);
  }
  .app-hero-icon:hover .hero-icon-img {
    transform: translateY(-3px) scale(1.03);
    filter: drop-shadow(0 22px 40px rgba(10,20,45,0.7)) saturate(1.15) contrast(1.1) brightness(1.12);
  }
}

@media (max-width: 640px) {
  /* Only scale sizes on small screens now */
  .app-title { font-size: 2rem; line-height: 1.12; margin-bottom: .4rem; }
  .app-tagline { font-size: .9rem; margin: 0; }
  .app-hero-icon { width: clamp(180px, 52vw, 230px); }
}

/* Fine tune spacing of status line and tabs */
#wsStatus { margin-top: 0 !important; margin-bottom: .25rem !important; line-height:1.05; font-size:.8rem; }
.nav-tabs { margin-bottom: .75rem; }

/* Slightly reduce top padding of card body overall */
.card > .card-body { padding-top: 1.4rem; }
@media (max-width: 640px) { .card > .card-body { padding-top: 1.1rem; } }

/* (Removed gradient spacer beneath hero to minimize visual gap) */

/* Ultra-small phones & rigorous space optimization */
@media (max-width: 480px) {
  .app-hero-icon { width: clamp(150px, 64vw, 190px); }
  .app-title { font-size: 1.72rem; }
  .app-tagline { font-size: .82rem; }
}

@media (max-width: 360px) {
  .app-hero-icon { width: clamp(125px, 72vw, 160px); }
  .app-title { font-size: 1.55rem; }
  .app-tagline { font-size: .78rem; }
}

/* Page ambient background enhancement (card remains primary) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 25% 18%, rgba(90,80,255,0.12), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(40,180,255,0.08), transparent 60%);
  opacity: .9;
  mix-blend-mode: plus-lighter;
  z-index: -1;
}

/* Card subtle glass refinement */
.card.shadow-sm {
  background: linear-gradient(150deg, rgba(35,35,45,0.88), rgba(25,25,32,0.88) 55%, rgba(22,26,32,0.9));
  backdrop-filter: blur(6px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.06);
}

/* Tabs refinement */
.nav-tabs .nav-link {
  border: none;
  color: #b5c2d6;
  font-weight: 500;
  position: relative;
  background: transparent;
}
.nav-tabs .nav-link:hover { color: #d7e2ef; }
.nav-tabs .nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(100,80,255,0.28), rgba(60,150,255,0.28));
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.05), 0 2px 6px -2px rgba(0,0,0,0.6);
}
.nav-tabs { border-bottom: 1px solid rgba(255,255,255,0.08); }

/* Table tweaks */
table.table { --row-accent-bg: rgba(255,255,255,0.03); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: rgba(255,255,255,0.015) !important; }
.table-active > * { background: rgba(255,255,255,0.04) !important; }
table.table td, table.table th { border-color: rgba(255,255,255,0.08) !important; }

/* Sticky section headers within scroll (if table becomes tall) */
.table-responsive { max-height: 68vh; overflow: auto; }
.table-responsive .table-active:first-child { position: sticky; top: 0; z-index: 2; }
.table-active { font-size: .8rem; letter-spacing: .5px; text-transform: uppercase; }

/* Metric value cell subtle background bar driven by data-sum (relative scaling) */
td.hm-value {
  position: relative;
  font-variant-numeric: tabular-nums;
}
td.hm-value::before {
  content: "";
  position: absolute;
  inset: 4px 4px 4px 0;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(100,140,255,0.18), rgba(100,140,255,0));
  opacity: 0; /* default hidden until JS sets scale var */
  transform-origin: left center;
  transform: scaleX(var(--bar-scale, 0));
  transition: transform .6s ease, opacity .4s ease;
  pointer-events: none;
}
td.hm-value[data-sum] { --max-sum: 1; }
/* We'll compute max dynamically in a future enhancement; for now approximate via attr() not supported for calc widths -> simple reveal */
td.hm-value[data-sum]::before { opacity: .55; }

/* Row hover */
tbody tr[data-hae-type-row="1"]:hover td { background-color: rgba(255,255,255,0.035) !important; }

/* Compact age column styling */
td.hm-age .time-ago { font-size: .75rem; opacity: .8; }

/* Status indicator inline */
#wsStatus::before {
  content: "";
  display: inline-block;
  width: .55rem;
  height: .55rem;
  margin-right: .4rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff7a45, #ffb070);
  box-shadow: 0 0 0 2px rgba(255,122,69,0.25);
  animation: pulse 1.2s ease-in-out infinite;
}
#wsStatus:contains('Connected')::before {
  background: linear-gradient(135deg, #28d058, #5ddcff);
  box-shadow: 0 0 0 2px rgba(70,200,120,0.25);
}

@keyframes pulse {
  0%,100% { transform: scale(.9); opacity: .65; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* Soft halo breathing */
@keyframes haloPulse {
  0% { transform: scale(.9); opacity: .65; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(.9); opacity: .65; }
}

/* Hero glow breathing */
@keyframes velaGlow {
  0% { box-shadow: 0 0 0 2px rgba(255,255,255,0.05), 0 0 28px 6px rgba(120,90,255,0.5), 0 0 50px 18px rgba(60,150,255,0.28); }
  45% { box-shadow: 0 0 0 2px rgba(255,255,255,0.07), 0 0 38px 12px rgba(140,110,255,0.7), 0 0 72px 28px rgba(60,170,255,0.45); }
  100% { box-shadow: 0 0 0 2px rgba(255,255,255,0.05), 0 0 28px 6px rgba(120,90,255,0.5), 0 0 50px 18px rgba(60,150,255,0.28); }
}

/* Utility: monospace-ish numeric columns already handled with .numeric */

/* Reduce bottom spacing when tables stack */
metrics-dashboard table { margin-bottom: 1.25rem; }

/* Footer app link styling */
.app-link {
  font-size: .85rem;
  letter-spacing: .5px;
  transition: color .3s ease, transform .2s ease;
  display: inline-block;
}
.app-link:hover {
  color: var(--bs-primary) !important;
  transform: translateX(3px);
}

/* Back Button (Upper Left) - Matches user menu styling */
.back-button-wrapper {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10000;
}

.back-btn {
  height: 44px;
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  transition: all 0.2s ease;
  text-transform: none;
  letter-spacing: 0.3px;
  font-weight: 500;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  transform: translateX(-2px);
}

.back-btn svg {
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .back-button-wrapper {
    top: 0.5rem;
    left: 0.5rem;
  }
}

@media (max-width: 480px) {
  .back-button-wrapper {
    top: 0.35rem;
    left: 0.35rem;
  }

  .back-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* User Menu Dropdown Styles (Upper Right) */
.user-menu-wrapper {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10000;
}

.user-signin-wrapper {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.user-signin-btn {
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  text-transform: none;
  letter-spacing: 0.3px;
}

.user-dropdown .user-menu-btn {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  color: #fff;
  text-decoration: none;
  transition: all 0.2s ease;
  text-transform: none;
  letter-spacing: 0.3px;
  font-weight: 500;
}

.user-dropdown .user-menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.user-avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.user-name-display {
  font-size: 0.9rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-menu {
  min-width: 280px;
  background: rgba(30, 30, 38, 0.98);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  padding: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  position: relative;
}

.user-dropdown-header {
  padding: 0.75rem 1rem;
  margin-bottom: 0.25rem;
}

.user-avatar-dropdown {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.user-dropdown-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  margin-bottom: 0.125rem;
  text-transform: none;
  letter-spacing: 0.3px;
}

.user-dropdown-email {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: none;
  letter-spacing: 0.2px;
  font-weight: 400;
}

.user-dropdown-menu .dropdown-item {
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  color: rgba(255, 255, 255, 0.85);
  transition: all 0.2s ease;
  text-transform: none;
  letter-spacing: 0.3px;
  font-weight: 500;
}

.user-dropdown-menu .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.user-dropdown-menu .dropdown-divider {
  border-color: rgba(255, 255, 255, 0.1);
  margin: 0.5rem 0;
}

/* Responsive adjustments for user menu */
@media (max-width: 640px) {
  .user-menu-wrapper {
    top: 0.5rem;
    right: 0.5rem;
  }

  .user-name-display {
    max-width: 100px;
    font-size: 0.85rem;
  }

  .user-dropdown-menu {
    min-width: 240px;
  }
}

@media (max-width: 480px) {
  .user-menu-wrapper {
    top: 0.35rem;
    right: 0.35rem;
  }

  .user-avatar-small {
    width: 24px;
    height: 24px;
  }

  .user-name-display {
    display: none;
  }
}

/* Users Page Styles */
.users-page-header {
  position: relative;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 1.5rem;
}

.users-page-header h2 {
  font-size: 1.75rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.5px;
}

.users-table thead th {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem;
}

.users-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background-color 0.2s ease;
}

.users-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.users-table tbody td {
  padding: 1rem;
  vertical-align: middle;
}

.user-table-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  object-fit: cover;
}

.user-table-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.users-table .badge {
  font-size: 0.9rem;
  padding: 0.4rem 0.7rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* MRI Viewer / DICOM Viewer Styles */
#viewer {
  width: 100%;
  height: 400px;
  position: relative;
  background: #000;
  border-radius: 0.5rem;
  overflow: hidden;
  touch-action: none; /* Prevent default touch scroll/zoom on viewer */
}

/* Camera View Presets */
.camera-presets {
  position: absolute;
  top: 50px;
  left: 5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1500;
}

.camera-preset-btn {
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 255, 0, 0.5);
  border-radius: 4px;
  color: #0f0;
  font-family: monospace;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-preset-btn:hover {
  background: rgba(0, 255, 0, 0.2);
  border-color: #0f0;
  transform: translateX(2px);
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.4);
}

.camera-preset-btn:active {
  background: rgba(0, 255, 0, 0.3);
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  top: 50px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1500;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 255, 0, 0.5);
  border-radius: 4px;
  color: #0f0;
  font-family: monospace;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.zoom-btn:hover {
  background: rgba(0, 255, 0, 0.2);
  border-color: #0f0;
  transform: translateX(2px);
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.4);
}

.zoom-btn:active {
  background: rgba(0, 255, 0, 0.3);
}

@media (max-width: 575px) {
  .camera-presets {
    top: 40px;
    gap: 3px;
  }

  .camera-preset-btn {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .zoom-controls {
    top: 40px;
    right: 8px;
    gap: 3px;
  }

  .zoom-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }
}

@media (min-width: 768px) {
  #viewer {
    height: 500px;
  }
}

@media (min-width: 1200px) {
  #viewer {
    height: 600px;
  }
}

/* LUT Editor - Collapsible Settings Panel */
.lut-editor-container {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2000;
  max-width: 340px;
}

.lut-toggle-btn {
  background: rgba(0, 255, 0, 0.15);
  border: 2px solid #0f0;
  border-radius: 0.5rem;
  padding: 0.5rem 0.85rem;
  color: #0f0;
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(0, 255, 0, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 100%;
  justify-content: center;
}

.lut-toggle-btn:hover {
  background: rgba(0, 255, 0, 0.25);
  box-shadow: 0 4px 16px rgba(0, 255, 0, 0.4);
}

.lut-toggle-btn svg {
  flex-shrink: 0;
}

.lut-content {
  margin-top: 0.5rem;
  background: rgba(20, 20, 30, 0.98);
  border: 2px solid #0f0;
  border-radius: 0.5rem;
  padding: 1rem;
  color: #fff;
  font-family: monospace;
  font-size: 0.75rem;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 255, 0, 0.3);
  backdrop-filter: blur(10px);
}

.lut-header {
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #0f0;
  padding-bottom: 0.5rem;
}

.lut-header strong {
  color: #0f0;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

/* Mobile optimizations for LUT editor */
@media (max-width: 767px) {
  .lut-editor-container {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    margin-bottom: 1rem;
  }

  .lut-toggle-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
    text-transform: none;
  }

  .lut-toggle-btn span {
    display: inline;
  }

  .lut-content {
    max-height: 40vh;
    font-size: 0.7rem;
  }

  #viewer {
    height: 400px;
  }

  /* Ensure viewer parent has relative positioning for absolute children */
  #mri-view {
    position: relative;
  }

}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1199px) {
  .lut-editor-container {
    max-width: 320px;
  }
}

/* Users Grid (Mobile Tile View) */
.users-grid {
  display: grid;
  gap: 1rem;
  padding: 1rem 0;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

@media (min-width: 768px) {
  .users-grid {
    display: none; /* Hide grid on desktop */
  }
}

@media (max-width: 767px) {
  .users-table-wrapper {
    display: none; /* Hide table on mobile */
  }
  .users-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.85rem;
  }
}

@media (max-width: 575px) {
  .users-grid {
    grid-template-columns: repeat(2, 1fr); /* Exactly 2 columns on small phones */
    gap: 0.75rem;
  }
}

/* User Card (Mobile Tile) */
.user-card {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.75rem;
  background: linear-gradient(135deg, rgba(50,50,60,0.4), rgba(35,35,45,0.4));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: default;
  position: relative;
}

.user-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  background: linear-gradient(135deg, rgba(60,60,75,0.5), rgba(45,45,55,0.5));
}

/* Role-specific border accents */
.user-card-admin {
  border-left: 3px solid rgba(255, 193, 7, 0.6);
}

.user-card-premium {
  border-left: 3px solid rgba(13, 110, 253, 0.6);
}

.user-card-basic {
  border-left: 3px solid rgba(108, 117, 125, 0.6);
}

/* User card avatar */
.user-card-avatar,
.user-card-avatar-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  object-fit: cover;
  margin-bottom: 0.75rem;
}

.user-card-avatar-placeholder {
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* User card name */
.user-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255,255,255,0.95);
  text-align: center;
  margin-bottom: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  padding: 0 0.25rem;
  text-transform: none;
  letter-spacing: 0.3px;
}

/* User card role */
.user-card-role {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

/* User card last login */
.user-card-login {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.4);
  position: absolute;
  bottom: 4px;
  right: 6px;
}

/* Small screens optimization */
@media (max-width: 575px) {
  .user-card {
    padding: 0.75rem 0.5rem;
    border-radius: 10px;
  }

  .user-card-avatar,
  .user-card-avatar-placeholder {
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
  }

  .user-card-name {
    font-size: 0.85rem;
  }

  .user-card-role {
    font-size: 0.7rem;
  }

  .user-card-login {
    font-size: 0.6rem;
  }
}
