/* Stats Styles */

.stats-container {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  padding: 0;
}

/* Header */
.stats-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
}

.stats-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.title-icon {
  font-size: 1.5rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.last-updated {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

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

.btn-secondary:hover {
  background: var(--card);
}

.btn-outline {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--btn);
  color: var(--text);
}

.btn-icon {
  font-size: 1rem;
}

/* Sections */
section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1.5rem 0;
  color: var(--text);
}

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

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.stat-card.primary {
  border-left: 4px solid var(--blue);
}

.stat-card.secondary {
  border-left: 4px solid var(--amber);
}

.stat-card.accent {
  border-left: 4px solid var(--red);
}

.stat-card.info {
  border-left: 4px solid #10b981;
}

.stat-icon {
  font-size: 2rem;
  opacity: 0.8;
}

.stat-content {
  flex: 1;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

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

.stat-sublabel {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Performance Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.metric-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.metric-period {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--chip);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.metric-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--blue);
}

.metric-unit {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 500;
}

.metric-description {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.metric-efficiency {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
}

.efficiency-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.efficiency-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--amber);
  background: rgba(245, 158, 11, 0.1);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

.chart-header {
  margin-bottom: 1rem;
}

.chart-header h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.chart-subtitle {
  font-size: 0.875rem;
  color: var(--muted);
}

.chart-container {
  position: relative;
  height: 300px;
}

.chart-card.full-width .chart-container {
  height: 400px;
}

/* Activity Section */
.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.activity-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

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

.activity-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.activity-count {
  background: var(--blue);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.activity-list {
  max-height: 400px;
  overflow-y: auto;
}

.activity-loading {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
  font-style: italic;
}

.activity-item {
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

.activity-item:hover {
  background: var(--btn);
}

.activity-item:last-child {
  margin-bottom: 0;
}

.incident-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.incident-details h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.incident-meta {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  gap: 1rem;
}

.incident-status {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.incident-status.critical {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.incident-status.active {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

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

.crew-callsign {
  font-weight: 600;
  color: var(--text);
}

.crew-status {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.crew-status.on-case {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.crew-status.roaming {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.crew-status.at-post {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.crew-status.off-duty {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 18, 32, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

.loading-text {
  color: var(--text);
  font-size: 0.875rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .stats-header {
    padding: 1rem;
  }
  
  .header-content {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .header-actions {
    justify-content: center;
  }
  
  section {
    padding: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .activity-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-container {
    height: 250px;
  }
}