/* --- CSS Custom Properties & Core Design System --- */
:root {
  --bg-primary: #0a0b0e;
  --bg-secondary: #12141c;
  --bg-card: rgba(22, 25, 35, 0.75);
  --bg-card-hover: rgba(28, 32, 45, 0.9);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.3);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.3);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.3);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);
  
  --sidebar-width: 456px;
  --test-panel-width: 360px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-highlight: rgba(0, 0, 0, 0.16);
  
  --accent-blue-glow: rgba(59, 130, 246, 0.15);
}

body.light-theme .custom-dialog-card,
body.light-theme .pac-container {
  background-color: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .custom-dialog-title {
  color: #0f172a !important;
}

body.light-theme .custom-dialog-message {
  color: #475569 !important;
}

body.light-theme .login-container,
body.light-theme .user-container {
  background: radial-gradient(circle at center, #f8fafc, #cbd5e1) !important;
}

body.light-theme .login-card,
body.light-theme .user-card {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .waypoint-item input,
body.light-theme .device-select {
  background-color: rgba(255, 255, 255, 0.9) !important;
  color: #0f172a !important;
}

body.light-theme .device-select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

body.light-theme .device-select option:checked,
body.light-theme .device-select option:hover {
  background-color: #3b82f6 !important;
  color: #ffffff !important;
}

/* --- Base Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* --- Layout --- */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* --- Sidebar Style --- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
  z-index: 10;
  flex-shrink: 0;
  overflow-y: auto;
}

/* Stylized scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(59, 130, 246, 0.5);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo i {
  color: var(--accent-blue);
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px var(--accent-blue-glow));
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
}

.status-indicator.connected .dot {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-indicator.disconnected .dot {
  background-color: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-text {
  color: var(--text-secondary);
}

/* --- Card Styles (Glassmorphism) --- */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: var(--border-highlight);
  background: var(--bg-card-hover);
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.card h3 i {
  color: var(--accent-blue);
}

/* --- Input Groups --- */
.input-group {
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.input-wrapper input {
  width: 100%;
  padding: 12px 14px 12px 38px;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-smooth);
}

.input-wrapper input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px var(--accent-blue-glow);
  background-color: rgba(0, 0, 0, 0.4);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  width: 100%;
  transition: var(--transition-smooth);
}

.btn-primary {
  background-color: var(--accent-blue);
  color: white;
}

.btn-primary:hover {
  background-color: #2563eb;
  box-shadow: 0 0 15px var(--accent-blue-glow);
  transform: translateY(-1px);
}

.btn-success {
  background-color: var(--accent-green);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background-color: #059669;
  box-shadow: 0 0 15px var(--accent-green-glow);
  transform: translateY(-1px);
}

.btn-danger {
  background-color: var(--accent-red);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
  box-shadow: 0 0 15px var(--accent-red-glow);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  color: var(--accent-red);
}

/* --- Devices List --- */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h3 {
  margin-bottom: 0;
}

.devices-panel {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 250px;
}

.devices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-list {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 30px 0;
  border: 1px dashed rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
}

/* Device Item Card */
.device-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.device-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.device-item-id {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.device-item-tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 12px;
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.device-item-tag.simulated {
  background-color: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.2);
}

.device-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.device-badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.device-badge-status.normal {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.device-badge-status.deviated {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* --- Map Container --- */
.map-container {
  flex-grow: 1;
  height: 100%;
  position: relative;
}

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

/* --- Floating Button --- */
.btn-floating {
  position: absolute;
  top: 100px;
  right: 20px;
  width: auto;
  z-index: 10;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px 18px;
}

.btn-floating:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.25);
  transform: translateY(-2px);
}

/* --- Simulation Test Panel (Drawer Style) --- */
.test-panel {
  position: absolute;
  top: 160px;
  right: 20px;
  width: var(--test-panel-width);
  background: rgba(18, 20, 28, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.test-panel.hidden {
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
  pointer-events: none;
}

.test-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
}

.test-panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.test-panel-header h3 i {
  color: var(--accent-green);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-close:hover {
  color: var(--text-primary);
}

.test-panel-content {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.test-panel-content .description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-row .input-group input {
  width: 100%;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
}

.input-row .input-group input:focus {
  border-color: var(--accent-green);
}

/* Switch Toggle Button */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  user-select: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

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

input:focus + .slider {
  box-shadow: 0 0 1px var(--accent-green);
}

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

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.test-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

/* Simulated devices mini-panel */
.simulated-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.simulated-list-container h4 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.simulated-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.simulated-list::-webkit-scrollbar {
  width: 3px;
}

.simulated-list::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.05);
}

.simulated-device-item {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.simulated-device-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.simulated-device-actions {
  display: flex;
  gap: 6px;
}

.btn-pill-action {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.btn-pill-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-pill-action.deviated {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-pill-action.deviated:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Custom device select styles for better visualization */
.device-select {
  width: 100%;
  padding: 12px 38px 12px 38px;
  background-color: rgba(0, 0, 0, 0.3) !important;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

.device-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px var(--accent-blue-glow);
}

.device-select option {
  background-color: #1a1e2e !important;
  color: #cbd5e1 !important;
  padding: 12px !important;
}

.device-select option:checked,
.device-select option:hover {
  background-color: #2563eb !important;
  color: #ffffff !important;
}

/* Google Places Autocomplete dropdown dark styles */
.pac-container {
  background-color: #12141c !important; /* Dark background */
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 10px !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6) !important;
  font-family: 'Inter', sans-serif !important;
  z-index: 999999 !important; /* Ensure it draws on top of panels */
  margin-top: 4px !important;
}

.pac-item {
  border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
  padding: 10px 14px !important;
  color: #9ca3af !important; /* --text-secondary */
  cursor: pointer !important;
  font-size: 0.85rem !important;
}

.pac-item:hover, .pac-item-selected {
  background-color: rgba(28, 32, 45, 0.9) !important; /* Hover card bg */
}

.pac-item-query {
  color: #f3f4f6 !important; /* --text-primary */
  font-size: 0.85rem !important;
}

.pac-matched {
  color: #3b82f6 !important; /* --accent-blue */
  font-weight: 600 !important;
}

.pac-icon {
  display: none !important; /* Hide generic icons for cleaner aesthetic */
}

/* Waypoint items styles */
.waypoint-item {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.waypoint-item input {
  flex-grow: 1;
  padding: 10px 12px 10px 34px !important; /* Margin for icon */
  background-color: rgba(0, 0, 0, 0.2) !important;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.825rem;
  outline: none;
}

.waypoint-item input:focus {
  border-color: var(--accent-blue);
}

.btn-remove-waypoint {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 6px;
  transition: var(--transition-smooth);
}

.btn-remove-waypoint:hover {
  color: var(--accent-red);
}

/* Custom Dialog Overlay and Card Styles */
.custom-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100000000 !important; /* Above everything including Google Maps overlays */
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.2s ease;
}

.custom-dialog-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.custom-dialog-card {
  background-color: #12141c; /* matches --bg-secondary */
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
  animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.custom-dialog-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f3f4f6;
  margin-bottom: 12px;
}

.custom-dialog-message {
  font-size: 0.9rem;
  color: #9ca3af;
  line-height: 1.5;
  margin-bottom: 24px;
}

.custom-dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.custom-dialog-buttons .btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.custom-dialog-buttons .btn-primary {
  background-color: #3b82f6;
  color: #ffffff;
}

.custom-dialog-buttons .btn-primary:hover {
  background-color: #2563eb;
}

.custom-dialog-buttons .btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: #9ca3af;
}

.custom-dialog-buttons .btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #f3f4f6;
}

.custom-dialog-buttons .hidden {
  display: none !important;
}

/* --- LOGIN & USER VIEWS --- */
.login-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, #141722, #0d0f17);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20000;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  padding: 32px 24px;
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-top: 12px;
}

/* User Container (USR) */
.user-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, #141722, #0d0f17);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 15000;
  padding: 16px;
}

.user-card {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  padding: 24px;
}

.user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 16px;
}

.user-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.user-role-badge {
  font-size: 0.7rem;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Web Tracker Status */
.web-tracker-status.active {
  color: #10b981;
}
.web-tracker-status.active .status-dot {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}
.web-tracker-status.inactive {
  color: #ef4444;
}
.web-tracker-status.inactive .status-dot {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* User Items List for Admin */
.user-list-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition-smooth);
}

.user-list-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.user-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-item-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #fff;
}

.user-item-details {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-item-role {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.user-item-role.adm {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.user-item-role.usr {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.user-actions {
  display: flex;
  gap: 6px;
}

.user-actions button {
  padding: 6px;
  font-size: 0.8rem;
}

.hidden {
  display: none !important;
}

/* --- USR Operator Logout Styling --- */
#btn-user-logout {
  background: none !important;
  border: 1px solid rgba(239, 68, 68, 0.2) !important;
  color: #ef4444 !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  padding: 6px 12px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  border-radius: var(--radius-sm) !important;
  transition: var(--transition-smooth) !important;
  align-self: center !important;
  width: auto !important;
}

#btn-user-logout:hover {
  background-color: rgba(239, 68, 68, 0.1) !important;
  border-color: #ef4444 !important;
  box-shadow: none !important;
}

/* --- Responsive Layout for Mobile/Tablet --- */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column !important;
    height: 100vh !important;
    overflow-y: auto !important;
  }
  
  .sidebar {
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 20px 16px !important;
  }
  
  .map-container {
    width: 100% !important;
    height: 500px !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
  }
  
  .test-panel {
    width: 92% !important;
    right: 4% !important;
    left: 4% !important;
    bottom: 20px !important;
    top: auto !important;
    max-height: 80vh !important;
  }
}

/* --- PWA Install Widget Style (Mobile Floating Button) --- */
.pwa-install-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999999;
  font-family: 'Inter', sans-serif;
  display: none; /* Hidden on desktop */
}

#btn-pwa-install {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pwa-btn-text {
  background: var(--accent-blue);
  color: white;
  padding: 8px 25px 8px 16px;
  border-radius: 20px 0 0 20px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: -2px 4px 10px rgba(0, 0, 0, 0.3);
  margin-right: -15px;
  position: relative;
  z-index: 1;
}

.pwa-btn-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 2;
}

#btn-pwa-install:hover {
  transform: scale(1.08);
}

#btn-pwa-install:hover .pwa-btn-text,
#btn-pwa-install:hover .pwa-btn-icon {
  background: #2563eb;
}

/* Show only on small screens (mobile/tablet) */
@media (max-width: 768px) {
  .pwa-install-widget {
    display: block;
  }
}

/* Device Item Selected State */
.device-item.selected-active {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.05);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Device Route Details in Sidebar Card */
.device-route-details {
  margin-top: 10px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid var(--accent-blue);
  border-radius: 4px;
  font-size: 0.8rem;
  animation: fadeInDown 0.25s ease-out;
}

.device-route-details.empty {
  border-left-color: var(--text-muted);
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

.route-details-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}

.route-details-row {
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.route-details-row strong {
  color: var(--text-muted);
  flex-shrink: 0;
}

.route-details-row span {
  color: #fff;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-details-waypoints-container {
  margin-top: 6px;
  margin-bottom: 6px;
}

.route-details-waypoints-container strong {
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.route-details-waypoints {
  list-style: none;
  padding-left: 8px;
  margin: 0;
}

.route-details-waypoints li {
  margin-bottom: 3px;
  color: #fff;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.route-details-waypoints li i {
  font-size: 0.5rem;
  color: var(--accent-blue);
}

.route-details-no-waypoints {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.75rem;
  padding-left: 8px;
}

.route-details-row.route-distance {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 6px;
  margin-top: 6px;
}

.route-details-row.route-distance span {
  color: var(--accent-blue);
  font-weight: 600;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.btn-input-icon:hover:not(:disabled) {
  color: var(--accent-blue) !important;
  transform: translateY(-50%) scale(1.15) !important;
}

/* Translucent Dark InfoWindow (Google Maps override) */
.gm-style-iw-c {
  background-color: rgba(18, 20, 28, 0.75) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
  padding: 12px 16px !important;
  border-radius: 12px !important;
}

.gm-style-iw-d {
  overflow: hidden !important;
}

.gm-ui-hover-effect {
  top: 4px !important;
  right: 4px !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border-radius: 50% !important;
  width: 24px !important;
  height: 24px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.gm-ui-hover-effect span {
  background-color: #9ca3af !important;
  margin: 0 !important;
}

.gm-ui-hover-effect:hover span {
  background-color: #fff !important;
}

.gm-style-iw-t::after {
  background: rgba(18, 20, 28, 0.75) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.map-infowindow {
  color: #fff !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 0.8rem !important;
  line-height: 1.5 !important;
  text-align: left !important;
}

.map-infowindow strong {
  color: var(--accent-blue) !important;
}

/* Floating Banner for Map Selection Mode */
#map-selection-banner {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 20, 28, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--accent-blue);
  color: #fff;
  padding: 12px 20px;
  border-radius: 30px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  animation: bannerFadeInDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#map-selection-banner.hidden {
  display: none !important;
}

#map-selection-banner i {
  color: var(--accent-blue);
  font-size: 1rem;
}

#map-selection-banner button {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  transition: all 0.2s ease;
}

#map-selection-banner button:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

@keyframes bannerFadeInDown {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Small Border-Only Remove Device Icon Button */
.btn-remove-device-icon {
  background: transparent !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  color: #ef4444 !important;
  padding: 5px 8px !important;
  border-radius: var(--radius-sm) !important;
  cursor: pointer !important;
  font-size: 0.8rem !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
}

.btn-remove-device-icon:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  border-color: #ef4444 !important;
  transform: scale(1.05);
}
