/* =========================================================
   ANTMODDER ADMIN PANEL - ULTRA PREMIUM MODERN CSS SYSTEM
   Desktop & Mobile Perfect Dark Glassmorphism Design
   ========================================================= */

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

:root {
  --bg-dark: #070913;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(26, 36, 64, 0.85);
  --bg-input: rgba(7, 10, 20, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(236, 72, 153, 0.4);
  --border-glow: 0 0 20px rgba(236, 72, 153, 0.25);
  
  --primary: #ec4899;
  --primary-glow: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  --secondary: #8b5cf6;
  --secondary-glow: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  
  --shadow-main: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  
  --header-height: 72px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Ambient Glow FX */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  left: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  animation: pulseGlow 10s ease-in-out infinite alternate;
}

body::after {
  content: '';
  position: fixed;
  bottom: -200px;
  right: -200px;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  animation: pulseGlow 12s ease-in-out infinite alternate-reverse;
}

@keyframes pulseGlow {
  0% { transform: scale(1) translate(0, 0); opacity: 0.7; }
  100% { transform: scale(1.2) translate(50px, 30px); opacity: 1; }
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

/* Glassmorphism Panel Container */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

/* Top Navigation Bar */
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 1.5rem;
  background: rgba(7, 9, 19, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.2rem;
}

.admin-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(236, 72, 153, 0.4));
}

/* Navigation Tabs (Perfect 4x2 Desktop & 2x4 Mobile Equal Grid) */
.nav-tabs-wrapper {
  margin-bottom: 1.5rem;
}

.nav-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 0.8rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.6);
}

.tab-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.tab-btn.active {
  background: var(--primary-glow);
  color: #fff;
  border-color: rgba(236, 72, 153, 0.5);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.45);
}

/* Mobile Toggle Hamburger */
.mobile-nav-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* User Badges */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-admin { background: rgba(236, 72, 153, 0.15); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.35); }
.badge-operator { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.35); }
.badge-member { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }

/* App Layout Container */
.admin-container {
  max-width: 1440px;
  margin: 1.5rem auto;
  padding: 0 1.25rem 3rem 1.25rem;
  position: relative;
  z-index: 1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: tabSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Stat Cards Banner Widget Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.stat-icon.pink { background: rgba(236, 72, 153, 0.15); color: #ec4899; border: 1px solid rgba(236, 72, 153, 0.3); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; border: 1px solid rgba(139, 92, 246, 0.3); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: #06b6d4; border: 1px solid rgba(6, 182, 212, 0.3); }

.stat-val {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.stat-lbl {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

/* Map Grid Layout */
.map-card-wrapper {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
}

#map-container {
  width: 100%;
  height: 620px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-main);
}

.map-sidebar {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 620px;
  overflow-y: auto;
}

.user-map-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.25s ease;
}

.user-map-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  transform: translateX(4px);
}

.user-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Responsive Table Component */
.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

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

table.admin-table th {
  background: rgba(255, 255, 255, 0.04);
  padding: 1.1rem 1.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
}

table.admin-table td {
  padding: 1.1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  vertical-align: middle;
}

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

/* Form Controls & Inputs */
.input-field {
  width: 100%;
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.25s ease;
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.2);
  background: rgba(15, 23, 42, 0.9);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-glow);
  color: #fff;
  box-shadow: 0 4px 15px rgba(236, 72, 153, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(236, 72, 153, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5);
}

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

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(3, 5, 12, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.modal-box {
  width: 100%;
  max-width: 580px;
  padding: 2.25rem;
  border-radius: var(--radius-lg);
  background: #0f172a;
  border: 1px solid var(--border-color);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .modal-box {
  transform: scale(1) translateY(0);
}

/* Leaflet Map Custom Marker Glow & Permanent Labels */
.custom-map-pin {
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-user-label {
  background: rgba(15, 23, 42, 0.88) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff !important;
  border: 1px solid rgba(139, 92, 246, 0.5) !important;
  border-radius: 8px !important;
  padding: 3px 8px !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4) !important;
  white-space: nowrap !important;
  pointer-events: none !important;
}

.map-user-label::before {
  border-top-color: rgba(15, 23, 42, 0.88) !important;
}

/* Mobile Responsiveness Overhauls */
@media (max-width: 640px) {
  .modal-box {
    width: 94% !important;
    max-width: 100% !important;
    padding: 1.25rem 1rem !important;
  }
  .input-field, .field {
    font-size: 0.92rem !important;
    padding: 0.75rem 0.85rem !important;
  }
  #admin-login-overlay .modal-box {
    margin: 1rem auto;
  }
}

@media (max-width: 1024px) {
  .map-card-wrapper {
    grid-template-columns: 1fr;
  }
  #map-container {
    height: 400px;
  }
  .map-sidebar {
    max-height: 300px;
  }
}

@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  .admin-container {
    padding: 0.85rem 0.6rem 2.5rem 0.6rem !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  /* Admin Header Bar Mobile Styling */
  .admin-nav {
    padding: 0.6rem 0.85rem !important;
    height: auto !important;
    min-height: 60px !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    gap: 0.6rem !important;
  }

  .admin-brand {
    font-size: 0.95rem !important;
    gap: 0.5rem !important;
  }

  .admin-brand div {
    font-size: 0.68rem !important;
  }

  .admin-logo {
    height: 32px !important;
  }

  /* Navigation Tabs: 2 Equal Columns Grid */
  .nav-tabs {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    padding: 0.5rem !important;
    margin-bottom: 1rem !important;
    box-sizing: border-box !important;
  }

  .tab-btn {
    padding: 0.6rem 0.4rem !important;
    font-size: 0.78rem !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: normal !important;
    word-break: break-word !important;
    text-align: center !important;
    line-height: 1.2 !important;
  }

  /* Stats Cards Grid: 2 Equal Columns */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    margin-bottom: 1.2rem !important;
  }

  .stat-card {
    padding: 0.75rem 0.65rem !important;
    gap: 0.5rem !important;
    border-radius: 14px !important;
  }

  .stat-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 1rem !important;
    flex-shrink: 0 !important;
  }

  .stat-val {
    font-size: 1.15rem !important;
  }

  .stat-lbl {
    font-size: 0.68rem !important;
    line-height: 1.25 !important;
  }

  h1 {
    font-size: 1.25rem !important;
    line-height: 1.35 !important;
  }

  /* Headers and Action Button rows */
  .tab-content > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .tab-content > div:first-child input,
  .tab-content > div:first-child select,
  .tab-content > div:first-child button {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Geofence Map Control Bar on Mobile */
  #tab-map .glass-panel div[style*="display: flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  #tab-map .glass-panel div[style*="display: flex"] > div {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
  }

  #tab-map .glass-panel div[style*="display: flex"] button {
    flex: 1 1 calc(50% - 0.4rem) !important;
    font-size: 0.75rem !important;
    padding: 0.55rem 0.4rem !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* Universal Inline Grid Overrides on Mobile (QR cards, Scanner, Forms, Settings) */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 2fr"] {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Bulk Upload Form inputs */
  #tab-gallery form div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* Admin Gallery photos grid */
  #admin-gallery-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem !important;
  }

  /* Tables: Smooth Touch Scroll & Formatting */
  .admin-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    border-radius: 14px !important;
  }

  .admin-table {
    min-width: 620px !important;
    width: 100% !important;
  }

  table.admin-table th, table.admin-table td {
    padding: 0.7rem 0.55rem !important;
    font-size: 0.78rem !important;
  }

  /* Modals on Mobile */
  .modal-backdrop {
    padding: 0.5rem !important;
  }

  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.25rem 1rem !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
  }

  .modal-box div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* QR Codes Sizing on Mobile */
  #qr-code-operator img, #qr-code-staff img {
    max-width: 160px !important;
    height: auto !important;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.45rem !important;
  }

  .stat-card {
    padding: 0.6rem 0.5rem !important;
  }

  .stat-val {
    font-size: 1.1rem !important;
  }

  .stat-lbl {
    font-size: 0.65rem !important;
  }
}
