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

:root {
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-glass: rgba(17, 24, 39, 0.7);
  --bg-glass-hover: rgba(31, 41, 55, 0.8);
  
  --color-primary: #10b981; /* Neon green */
  --color-primary-glow: rgba(16, 185, 129, 0.2);
  --color-accent: #3b82f6; /* Electric blue */
  --color-danger: #ef4444; /* Crimson red */
  --color-warning: #f59e0b; /* Amber */
  
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.5);
  
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.3);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Glassmorphism utility */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-premium);
}

/* Text Stylings */
h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  font-weight: 600;
}

.text-gradient {
  background: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Buttons */
.btn {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #042f2e;
  font-weight: 600;
  box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(16, 185, 129, 0.5), var(--shadow-glow);
  background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
  color: #ffffff;
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* Inputs */
.input-field {
  width: 100%;
  padding: 0.875rem 1.25rem;
  background: rgba(17, 24, 39, 0.5);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: all 0.2s ease;
}

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

/* Animations */
@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.pulse-dot {
  width: 10px;
  height: 10px;
  background-color: var(--color-primary);
  border-radius: 50%;
  display: inline-block;
  animation: pulse-glow 2s infinite;
}

.pulse-dot.offline {
  background-color: var(--color-danger);
  animation: none;
}

/* Leaflet Dark Map Customization */
.leaflet-container {
  background: var(--bg-primary) !important;
  font-family: var(--font-sans) !important;
}

/* Inject dark mode filters into the map images */
.dark-map .leaflet-tile-container img {
  filter: invert(100%) hue-rotate(180deg) brightness(85%) contrast(90%);
}

.leaflet-bar {
  border: 1px solid var(--border-glass) !important;
  box-shadow: var(--shadow-premium) !important;
}

.leaflet-bar a {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-glass) !important;
  transition: all 0.2s ease;
}

.leaflet-bar a:hover {
  background-color: var(--bg-glass-hover) !important;
  color: var(--color-primary) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-glass) !important;
  color: var(--text-primary) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass);
  border-radius: 12px !important;
  box-shadow: var(--shadow-premium) !important;
}

.leaflet-popup-tip {
  background: var(--bg-glass) !important;
  border: 1px solid var(--border-glass);
}

/* Tracking Page styling */
.tracker-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  padding: 2rem;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  gap: 2rem;
}

.status-card {
  width: 100%;
  padding: 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.tracker-title {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.tracker-desc {
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
}

.tracking-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  width: 100%;
  margin-top: 1rem;
}

.info-item {
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.info-value {
  font-size: 1.1rem;
  font-weight: 500;
}

#map-container {
  width: 100%;
  height: 350px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-premium);
}

/* Admin Auth Screen */
.admin-auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 3rem 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.auth-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-header h1 {
  font-size: 2rem;
}

.pin-input-group {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.pin-inputs {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.pin-box {
  width: 50px;
  height: 60px;
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-display);
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  color: var(--text-primary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pin-box:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary-glow);
  transform: scale(1.05);
}

.error-message {
  color: var(--color-danger);
  font-size: 0.875rem;
  font-weight: 500;
  min-height: 20px;
}

/* Admin Dashboard Screen */
.admin-dashboard {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  box-shadow: 5px 0 25px rgba(0, 0, 0, 0.4);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  font-size: 1.35rem;
}

.devices-list-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.device-card {
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.2s ease;
}

.device-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.device-card.active-focus {
  border-color: var(--color-primary);
  background: rgba(16, 185, 129, 0.05);
}

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.device-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
}

.device-status {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.device-ip {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

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

.device-updated-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.5rem;
}

.main-map-area {
  position: relative;
  height: 100%;
  width: 100%;
}

#admin-map {
  width: 100%;
  height: 100%;
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  text-align: center;
  color: var(--text-muted);
  gap: 0.75rem;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .admin-dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: 250px 1fr;
  }
  
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-glass);
    height: 250px;
  }
  
  .tracker-title {
    font-size: 2rem;
  }
}
