/**
 * Dashboard Phase 2 CSS
 * Sparklines, stat drill-down modals, anomaly awareness card
 */

/* === Sparkline Containers === */

.sparkline-container {
  display: block;
  width: 100%;
  height: 30px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sparkline-container.loaded {
  opacity: 1;
}

.sparkline-container svg {
  width: 100%;
  height: 100%;
}

.sparkline-line {
  fill: none;
  stroke: var(--color-primary, #14b8a6);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-area {
  fill: var(--color-primary, #14b8a6);
  opacity: 0.1;
}

/* === Quick Stat Click Affordance === */

.quick-stat[data-clickable] {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.quick-stat[data-clickable]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.15);
}

.quick-stat[data-clickable]:active {
  transform: translateY(0);
}

.quick-stat[data-clickable]::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--color-primary, #14b8a6);
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.quick-stat[data-clickable]:hover::after {
  opacity: 0.5;
}

/* === Stats Detail Modal === */

.stats-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.stats-detail-modal {
  background: var(--bg-card, #ffffff);
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  animation: statsModalSlideUp 0.25s ease-out;
}

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

.stats-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.stats-detail-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a2e);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stats-detail-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  padding: 0.25rem;
  line-height: 1;
  border-radius: 6px;
  transition: background 0.15s;
}

.stats-detail-close:hover {
  background: var(--bg-hover, #f3f4f6);
}

.stats-detail-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

/* Summary stats row */
.stats-summary-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stats-summary-item {
  flex: 1;
  min-width: 80px;
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-secondary, #f8fafc);
  border-radius: 10px;
}

.stats-summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary, #14b8a6);
}

.stats-summary-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* Recent items list */
.stats-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stats-recent-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.stats-recent-list li:last-child {
  border-bottom: none;
}

.stats-recent-title {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary, #1a1a2e);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-recent-meta {
  font-size: 0.75rem;
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
}

/* Section heading within modal */
.stats-section-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #6b7280);
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

/* Role/folder breakdown pills */
.stats-breakdown-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.stats-breakdown-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: var(--bg-secondary, #f8fafc);
  border-radius: 999px;
  font-size: 0.8125rem;
}

.stats-breakdown-pill .pill-count {
  font-weight: 600;
  color: var(--color-primary, #14b8a6);
}

.stats-breakdown-pill .pill-label {
  color: var(--text-secondary, #6b7280);
}

/* Loading spinner in modal */
.stats-detail-loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary, #6b7280);
}

/* === Anomaly Awareness Card === */

.awareness-card-anomaly {
  border-left: 3px solid #f59e0b;
}

.awareness-card-anomaly .awareness-badge {
  background: #f59e0b;
  color: #fff;
}

/* === Anomaly Detail Modal === */

.anomaly-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.anomaly-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--bg-secondary, #f8fafc);
}

.anomaly-item.severity-error {
  border-left: 3px solid #ef4444;
}

.anomaly-item.severity-warning {
  border-left: 3px solid #f59e0b;
}

.anomaly-item.severity-info {
  border-left: 3px solid #3b82f6;
}

.anomaly-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.anomaly-content {
  flex: 1;
  min-width: 0;
}

.anomaly-person {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary, #1a1a2e);
}

.anomaly-message {
  font-size: 0.8125rem;
  color: var(--text-secondary, #6b7280);
  margin-top: 0.125rem;
}

.anomaly-suggestion {
  font-size: 0.75rem;
  color: var(--color-primary, #14b8a6);
  margin-top: 0.25rem;
  font-style: italic;
}

/* === Dark Theme === */

[data-theme="dark"] .stats-detail-modal {
  background: var(--bg-card, #1e1e2e);
}

[data-theme="dark"] .stats-summary-item {
  background: var(--bg-secondary, #2a2a3a);
}

[data-theme="dark"] .anomaly-item {
  background: var(--bg-secondary, #2a2a3a);
}

[data-theme="dark"] .stats-breakdown-pill {
  background: var(--bg-secondary, #2a2a3a);
}

/* === Mobile === */

@media (max-width: 480px) {
  .stats-detail-modal {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    max-height: 90vh;
  }

  .stats-detail-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .stats-summary-row {
    gap: 0.5rem;
  }

  .stats-summary-item {
    min-width: 60px;
    padding: 0.5rem;
  }

  .stats-summary-value {
    font-size: 1.25rem;
  }
}
