/* Zone Pulse Drawer - Intelligent Analytics Dashboard */

#zonePulseDrawer {
  position: fixed;
  right: -400px;
  top: 0;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: var(--background-color, #fff);
  box-shadow: -2px 0 16px rgba(0, 0, 0, 0.15);
  z-index: 10002;
  /* Behind menu panel (z-index: 10001) - slides to menu then closes */
  transition: right 0.3s ease;
  overflow-y: auto;
}

#zonePulseDrawer.active {
  right: 0;
}

.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  backdrop-filter: blur(2px);
}

/* Drawer Header */
.drawer-header {
  position: sticky;
  top: 0;
  background: var(--primary-color, #4a90e2);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.drawer-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.drawer-header .close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 2rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.drawer-header .close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Drawer Content */
.drawer-content {
  padding: 20px;
}

/* Zone Info */
.zone-pulse-info {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.zone-address {
  font-size: 0.95rem;
  color: var(--text-secondary, #666);
  margin: 0 0 8px 0;
}

.zone-radius {
  font-size: 0.85rem;
  color: var(--text-tertiary, #999);
  margin: 0;
}

/* Stats Grid */
.pulse-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-background, #f8f9fa);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color, #4a90e2);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary, #333);
  margin-bottom: 2px;
}

.stat-sublabel {
  font-size: 0.75rem;
  color: var(--text-tertiary, #999);
}

/* Trend Colors */
.stat-card.trend-increasing {
  background: #fff3e0;
}

.stat-card.trend-increasing .stat-value {
  color: #f57c00;
}

.stat-card.trend-decreasing {
  background: #e8f5e9;
}

.stat-card.trend-decreasing .stat-value {
  color: #43a047;
}

.stat-card.trend-stable {
  background: #e3f2fd;
}

.stat-card.trend-stable .stat-value {
  color: #1976d2;
}

/* Pulse Sections */
.pulse-section {
  margin-bottom: 32px;
}

.pulse-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text-primary, #333);
}

.no-data {
  color: var(--text-tertiary, #999);
  font-style: italic;
  text-align: center;
  padding: 16px;
}

/* Sparkline Chart */
.sparkline-container {
  background: var(--card-background, #f8f9fa);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 8px;
}

.sparkline {
  display: flex;
  align-items: flex-end;
  height: 120px;
  gap: 1px;
}

.sparkline-bar-wrapper {
  display: flex;
  align-items: flex-end;
  height: 100%;
}

.sparkline-bar {
  width: 100%;
  background: var(--border-color, #e0e0e0);
  border-radius: 2px 2px 0 0;
  transition: background 0.2s;
  min-height: 2px;
}

.sparkline-bar.has-activity {
  background: var(--primary-color, #4a90e2);
}

.sparkline-bar:hover {
  background: var(--primary-color-dark, #357abd);
  cursor: pointer;
}

.sparkline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-tertiary, #999);
}

/* Category Breakdown */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-item {
  background: var(--card-background, #f8f9fa);
  border-radius: 12px;
  padding: 12px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.category-emoji {
  font-size: 1.3rem;
}

.category-name {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary, #333);
}

.category-count {
  font-weight: 600;
  color: var(--primary-color, #4a90e2);
  background: rgba(74, 144, 226, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.85rem;
}

.category-bar-bg {
  height: 6px;
  background: var(--border-color, #e0e0e0);
  border-radius: 3px;
  overflow: hidden;
}

.category-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color, #4a90e2), var(--primary-color-dark, #357abd));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Insights Grid */
.insights-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.insight-card {
  display: flex;
  gap: 12px;
  background: var(--card-background, #f8f9fa);
  border-radius: 12px;
  padding: 12px;
  border-left: 3px solid var(--primary-color, #4a90e2);
}

.insight-card.warning {
  border-left-color: #f57c00;
  background: #fff3e0;
}

.insight-card.positive {
  border-left-color: #43a047;
  background: #e8f5e9;
}

.insight-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.insight-text {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-primary, #333);
}

.insight-text strong {
  font-weight: 600;
  color: var(--text-primary, #000);
}

/* Last Notification */
.last-notified {
  font-size: 0.95rem;
  color: var(--text-secondary, #666);
  font-weight: 500;
  margin: 0;
}

/* Actions */
.pulse-actions {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color, #e0e0e0);
  margin-top: 24px;
}

.pulse-actions .btn {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pulse-actions .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pulse-actions .btn-secondary {
  background: var(--secondary-color, #e0e0e0);
  color: var(--text-primary, #333);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #zonePulseDrawer {
    width: 100vw;
    right: -100vw;
  }

  .pulse-stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat-card {
    display: flex;
    align-items: center;
    padding: 12px;
    text-align: left;
  }

  .stat-value {
    font-size: 1.5rem;
    margin-right: 12px;
    margin-bottom: 0;
  }

  .stat-label,
  .stat-sublabel {
    text-align: left;
  }

  .pulse-actions {
    flex-direction: column;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  #zonePulseDrawer {
    background: #1e1e1e;
    color: #e0e0e0;
  }

  .stat-card {
    background: #2a2a2a;
  }

  .sparkline-container,
  .category-item,
  .insight-card {
    background: #2a2a2a;
  }

  .insight-card.warning {
    background: #332200;
  }

  .insight-card.positive {
    background: #002211;
  }

  .sparkline-bar {
    background: #444;
  }

  .category-bar-bg {
    background: #444;
  }
}
