/* Base Styles */
:root {
  --primary-color: #1a365d;
  --primary-light: #2c5282;
  --secondary-color: #2d3748;
  --success-color: #38a169;
  --warning-color: #d69e2e;
  --danger-color: #e53e3e;
  --background-color: #f7fafc;
  --card-background: #ffffff;
  --text-color: #2d3748;
  --text-muted: #718096;
  --border-color: #e2e8f0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* Header */
.header {
  background-color: var(--primary-color);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-nav a {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.header-nav a:hover {
  background-color: var(--primary-light);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  font-weight: 500;
}

/* Notification Bell */
.notification-bell {
  position: relative;
  cursor: pointer;
  padding: 0.5rem;
}

.notification-bell svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--danger-color);
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
}

.notification-dropdown.show {
  display: block;
}

.notification-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  color: var(--text-color);
}

.notification-item:hover {
  background-color: var(--background-color);
}

.notification-item.unread {
  background-color: #ebf8ff;
}

.notification-item .message {
  font-size: 0.875rem;
}

.notification-item .time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Main Content */
.main-content {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* Cards */
.card {
  background: var(--card-background);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-badge.success {
  background-color: #c6f6d5;
  color: #276749;
}

.status-badge.warning {
  background-color: #fefcbf;
  color: #975a16;
}

.status-badge.danger {
  background-color: #fed7d7;
  color: #c53030;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary:hover {
  background-color: var(--primary-light);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
}

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

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

/* Map Container */
.map-container {
  height: 400px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.map-container.dashboard-map {
  width: 800px !important;
  height: 800px !important;
  min-width: 800px;
  min-height: 800px;
}

.map-container.fullscreen {
  height: calc(100vh - 80px);
}

/* Location Selector */
.location-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .location-selector {
    grid-template-columns: 1fr;
  }
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-background);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  background-color: var(--background-color);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover {
  background-color: var(--background-color);
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

.login-card {
  background: white;
  padding: 3rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.login-card h1 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.login-info {
  background: #ebf8ff;
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--primary-color);
}

.back-link {
  margin-top: 1.5rem;
}

.back-link a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.875rem;
}

.back-link a:hover {
  text-decoration: underline;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.alert-info {
  background-color: #ebf8ff;
  border-left: 4px solid #3182ce;
  color: #2c5282;
}

.alert-success {
  background-color: #c6f6d5;
  border-left: 4px solid #38a169;
  color: #276749;
}

.alert-warning {
  background-color: #fefcbf;
  border-left: 4px solid #d69e2e;
  color: #975a16;
}

.alert-danger {
  background-color: #fed7d7;
  border-left: 4px solid #e53e3e;
  color: #c53030;
}

/* Loading Spinner */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Legend */
.legend {
  display: flex;
  gap: 1.5rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-dot.current {
  background-color: var(--success-color);
}

.legend-dot.stale {
  background-color: var(--warning-color);
}

.legend-dot.never {
  background-color: var(--danger-color);
}

/* Sortable table headers */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover {
  background-color: #e2e8f0;
}

.sort-icon {
  display: inline-block;
  margin-left: 0.25rem;
  color: var(--text-muted);
}

.sort-icon::after {
  content: '⇅';
  font-size: 0.75rem;
}

th.sortable.asc .sort-icon::after {
  content: '↑';
}

th.sortable.desc .sort-icon::after {
  content: '↓';
}

/* Collapsible sections */
.collapsible-header {
  cursor: pointer;
  user-select: none;
}

.collapsible-header:hover {
  background-color: var(--background-color);
}

.collapse-icon {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.collapse-icon.collapsed {
  transform: rotate(-90deg);
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 2000px;
  opacity: 1;
}

.collapsible-content.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
