/* Core Variables & Design System */
:root {
  --color-bg: #0b0f19;
  --color-surface: rgba(17, 24, 39, 0.7);
  --color-surface-hover: rgba(31, 41, 55, 0.85);
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-focus: rgba(99, 102, 241, 0.4);
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-accent: #06b6d4;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-text-primary: #f8fafc;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --font-sans: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

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

html,
body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* Background animated glow orbs */
.glow-orb {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(6, 182, 212, 0) 70%);
  filter: blur(40px);
  z-index: -1;
  pointer-events: none;
  animation: float 20s infinite ease-in-out alternate;
}

.glow-orb-1 {
  top: 10%;
  left: 15%;
}

.glow-orb-2 {
  bottom: 20%;
  right: 10%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.15) 0%, rgba(99, 102, 241, 0) 70%);
  animation-delay: -5s;
}

.glow-orb-3 {
  top: 60%;
  left: 50%;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.12) 0%, rgba(99, 102, 241, 0) 70%);
  animation-delay: -10s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }

  50% {
    transform: translate(30px, -40px) scale(1.1);
  }

  100% {
    transform: translate(-20px, 20px) scale(0.95);
  }
}

/* Glassmorphism Utilities */
.glass-panel {
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.glass-panel-hover:hover {
  background: var(--color-surface-hover);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
}

.glass-input {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  transition: all 0.3s ease;
}

.glass-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-border-focus);
}

/* Fix browser autofill styling for dark mode */
.glass-input:-webkit-autofill,
.glass-input:-webkit-autofill:hover, 
.glass-input:-webkit-autofill:focus, 
.glass-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #0f172a inset !important;
    -webkit-text-fill-color: #f8fafc !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Dynamic Leaflet Map Dark Theme Filter */
.leaflet-container {
  background: var(--color-bg) !important;
}

.leaflet-layer,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  filter: invert(90%) hue-rotate(185deg) brightness(85%) contrast(110%);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #1e293b !important;
  color: var(--color-text-primary) !important;
  border: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
}

.leaflet-control-attribution {
  display: none !important;
}

/* Custom form validations visual hints */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 1px;
}

input:invalid:user-invalid,
select:invalid:user-invalid,
textarea:invalid:user-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Custom switch / toggle classes */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #374151;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--color-success);
}

input:checked+.slider:before {
  transform: translateX(24px);
}

/* Page transitions */
.page-section {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pulse animation for alerts / IoT warnings */
.alert-pulse {
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% {
    transform: scale(0.98);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }

  100% {
    transform: scale(0.98);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.beacon-pulse {
  position: relative;
}

.beacon-pulse::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border-radius: 50%;
  background: inherit;
  animation: beacon 1.5s infinite;
  opacity: 0.6;
}

@keyframes beacon {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }

  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Glass table styles */
.glass-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.glass-table th {
  background: rgba(15, 23, 42, 0.4);
  color: var(--color-text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.glass-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

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

/* Mobile responsive menu overlays */
@media (max-width: 768px) {
  .sidebar-collapsed {
    transform: translateX(-100%);
  }
}