/* Repository Explorer Component Styles */

:root {
  --repo-bg: #fafaf9;
  --repo-card-bg: white;
  --repo-border: #e2e8f0;
  --repo-primary: #2c5282;
  --repo-text: #1a1a1a;
  --repo-text-muted: #718096;
  --repo-shadow: rgba(0, 0, 0, 0.05);
  --repo-hover-shadow: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --repo-bg: #1a202c;
    --repo-card-bg: #2d3748;
    --repo-border: #4a5568;
    --repo-primary: #63b3ed;
    --repo-text: #e2e8f0;
    --repo-text-muted: #a0aec0;
    --repo-shadow: rgba(0, 0, 0, 0.3);
    --repo-hover-shadow: rgba(0, 0, 0, 0.5);
  }
}

.repo-explorer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem;
  color: var(--repo-text-muted);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--repo-border);
  border-top-color: var(--repo-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.repo-explorer-error {
  padding: 2rem;
  background: rgba(239, 68, 68, 0.05);
  border: 2px solid rgba(239, 68, 68, 0.2);
  border-radius: 4px;
  color: #e53e3e;
}

.repo-explorer-content {
  padding: 1.5rem;
  background: var(--repo-bg);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--repo-shadow);
}

/* Actions */
.repo-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}

.btn-export {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--repo-primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-export:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--repo-hover-shadow);
}

/* Metrics Cards */
.repo-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--repo-card-bg);
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--repo-border);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px var(--repo-hover-shadow);
  border-color: var(--repo-primary);
}

.metric-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--repo-primary);
  margin-bottom: 0.5rem;
}

.metric-label {
  font-size: 0.875rem;
  color: var(--repo-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.metric-sparkline {
  width: 100%;
  height: 30px;
  margin-top: 0.75rem;
  opacity: 0.6;
  color: var(--repo-primary);
}

/* Heatmap */
.repo-heatmap {
  margin-bottom: 2rem;
}

.repo-heatmap h4 {
  margin-bottom: 1rem;
  color: var(--repo-text);
  font-size: 1.1rem;
  font-weight: 600;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.5rem;
}

.heatmap-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.75rem;
  color: white;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.heatmap-cell:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px var(--repo-hover-shadow);
  z-index: 10;
}

.heatmap-cell:hover .heatmap-tooltip {
  opacity: 1;
  transform: translateY(-100%) translateX(-50%) scale(1);
  pointer-events: auto;
}

.heatmap-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateY(-80%) translateX(-50%) scale(0.9);
  background: var(--repo-text);
  color: var(--repo-card-bg);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 100;
}

.heatmap-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--repo-text);
}

.week-label {
  font-weight: 600;
}

.week-count {
  font-size: 0.7rem;
  opacity: 0.9;
}

/* Timeline */
.repo-timeline {
  margin-bottom: 2rem;
}

.repo-timeline h4 {
  margin-bottom: 1rem;
  color: #1a1a1a;
  font-size: 1.1rem;
}

.timeline-day {
  margin-bottom: 1.5rem;
  border-left: 3px solid #2c5282;
  padding-left: 1rem;
}

.timeline-date {
  font-weight: 600;
  color: #2c5282;
  margin-bottom: 0.5rem;
}

.timeline-commit {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid #e2e8f0;
}

.timeline-commit:last-child {
  border-bottom: none;
}

.commit-sha {
  font-family: monospace;
  color: #718096;
  flex-shrink: 0;
}

.commit-message {
  color: #1a1a1a;
  flex: 1;
}

/* Productivity Analysis */
.productivity-analysis {
  margin-bottom: 2rem;
  background: var(--repo-card-bg);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--repo-border);
}

.productivity-analysis h4 {
  margin-bottom: 1rem;
  color: var(--repo-text);
  font-size: 1.1rem;
  font-weight: 600;
}

.productivity-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--repo-bg);
  border-radius: 6px;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--repo-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--repo-primary);
}

.top-days-section h5 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: var(--repo-text-muted);
}

.top-days-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.productive-day {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--repo-bg);
  border-radius: 6px;
  transition: all 0.2s;
}

.productive-day:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px var(--repo-shadow);
}

.day-rank {
  font-weight: 700;
  color: var(--repo-primary);
  font-size: 1.1rem;
}

.day-info {
  flex: 1;
}

.day-date {
  font-size: 0.875rem;
  color: var(--repo-text);
  margin-bottom: 0.25rem;
}

.day-bar {
  height: 6px;
  background: var(--repo-primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.day-count {
  font-weight: 600;
  color: var(--repo-text-muted);
  font-size: 0.875rem;
}

/* Recent Commits */
.recent-commits {
  background: var(--repo-card-bg);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--repo-border);
}

.recent-commits h4 {
  margin-bottom: 1rem;
  color: var(--repo-text);
  font-size: 1.1rem;
  font-weight: 600;
}

.commits-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.commit-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--repo-bg);
  border-radius: 6px;
  transition: all 0.2s;
}

.commit-row:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px var(--repo-shadow);
}

.commit-sha {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
  color: var(--repo-text-muted);
  font-size: 0.75rem;
  background: var(--repo-card-bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.commit-message {
  color: var(--repo-text);
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.commit-date {
  color: var(--repo-text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Insights */
.repo-insights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.insights-section h4 {
  margin-bottom: 1rem;
  color: var(--repo-text);
  font-size: 1.1rem;
}

.insights-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.insight-item {
  padding: 0.75rem;
  border-radius: 4px;
  border-left: 4px solid;
  font-size: 0.875rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.insight-item.challenge {
  background: rgba(239, 68, 68, 0.05);
  border-left-color: #e53e3e;
}

.insight-item.solution {
  background: rgba(56, 161, 105, 0.05);
  border-left-color: #38a169;
}

.insight-sha {
  font-family: monospace;
  color: #718096;
  font-size: 0.75rem;
}

.insight-message {
  color: #1a1a1a;
}

.insight-date {
  color: #718096;
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Scrollbar Styling */
.commits-list::-webkit-scrollbar {
  width: 8px;
}

.commits-list::-webkit-scrollbar-track {
  background: var(--repo-bg);
  border-radius: 4px;
}

.commits-list::-webkit-scrollbar-thumb {
  background: var(--repo-border);
  border-radius: 4px;
}

.commits-list::-webkit-scrollbar-thumb:hover {
  background: var(--repo-text-muted);
}

/* Accessibility */
.heatmap-cell:focus {
  outline: 2px solid var(--repo-primary);
  outline-offset: 2px;
}

.btn-export:focus {
  outline: 2px solid var(--repo-primary);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .btn-export {
    display: none;
  }

  .heatmap-tooltip {
    display: none;
  }

  .metric-card,
  .productive-day,
  .commit-row {
    break-inside: avoid;
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .productivity-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .repo-explorer-content {
    padding: 1rem;
  }

  .repo-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .metric-card {
    padding: 1rem;
  }

  .metric-value {
    font-size: 1.5rem;
  }

  .heatmap-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 0.35rem;
  }

  .week-label,
  .week-count {
    font-size: 0.65rem;
  }

  .repo-insights {
    grid-template-columns: 1fr;
  }

  .insight-item {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .insight-date {
    grid-column: 2;
    justify-self: end;
  }

  .commit-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .commit-sha {
    width: fit-content;
  }

  .btn-export {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .repo-metrics {
    grid-template-columns: 1fr;
  }

  .heatmap-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .productive-day {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .day-count {
    grid-column: 2;
    justify-self: end;
  }
}

/* Animation Performance */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
