:root {
  /* Light Theme (Default) */
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --header-bg: #ffffff;
  --footer-text: #94a3b8;
}

[data-theme="dark"] {
  --primary-color: #3b82f6;
  --primary-hover: #60a5fa;
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-color: #334155;
  --header-bg: #1e293b;
  --footer-text: #64748b;
}

body {
  font-family: 'Inter', sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  width: 100%;
  box-sizing: border-box;
}

/* Header Styles */
.main-header {
  margin-bottom: 1.5rem;
  background: var(--header-bg);
  padding: 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--primary-color);
  letter-spacing: -0.025em;
}

.theme-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  transition: all 0.2s;
  height: auto;
}

.theme-btn:hover {
  background-color: var(--bg-color);
  border-color: var(--primary-color);
}

/* Footer Styles */
.main-footer {
  margin-top: auto;
  padding: 1.5rem 0;
  text-align: center;
  color: var(--footer-text);
  font-size: 0.875rem;
}

.main-footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.main-footer a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.controls {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  transition: background-color 0.3s;
}

#trackForm {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.form-row {
  display: flex;
  gap: 1rem;
  width: 100%;
  align-items: flex-end;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input,
select {
  padding: 0.625rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background-color 0.3s, color 0.3s;
  background-color: var(--bg-color);
  color: var(--text-primary);
}

input:focus,
select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  height: 42px;
  /* Match input height approx */
}

button:hover {
  background-color: var(--primary-hover);
}

.metrics-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-card {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: background-color 0.3s;
}

.metric-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
}

.debug-panel {
  background: var(--card-bg);
  padding: 0.5rem;
  border-radius: 0.75rem;
  margin-top: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s;
}

.debug-panel summary {
  cursor: pointer;
  padding: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.table-container {
  overflow-x: auto;
  margin-top: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: var(--bg-color);
  color: var(--text-secondary);
  font-weight: 500;
  transition: background-color 0.3s;
}

tr:hover {
  background-color: var(--bg-color);
  /* Slight contrast */
}

.empty-row {
  text-align: center;
  color: var(--text-secondary);
}

#map-container {
  flex: 1;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  position: relative;
  min-height: 400px;
}

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

/* Custom Marker Styles */
.car-marker {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent !important;
  border: none !important;
}

.car-icon {
  z-index: 2;
  width: 36px;
  height: 36px;
  background: var(--card-bg);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 20px;
  border: 2px solid var(--primary-color);
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  opacity: 0.4;
  animation: pulse 2s infinite;
  z-index: 1;
}

@keyframes pulse {
  0% {
    width: 36px;
    height: 36px;
    opacity: 0.5;
  }

  100% {
    width: 100px;
    height: 100px;
    opacity: 0;
  }
}

.status-on {
  color: var(--primary-color) !important;
}

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