/* ========================================
 * Prompt History View
 * ======================================== */
.prompt-history-view {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  min-height: 0;
}

.prompt-history-header {
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

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

.prompt-stat-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  transition: all 0.2s;
}

.prompt-stat-card:hover {
  border-color: hsl(var(--primary) / 0.3);
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.1);
}

.prompt-stat-card .stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: hsl(var(--primary) / 0.1);
  border-radius: 0.375rem;
  color: hsl(var(--primary));
}

.prompt-stat-card .stat-content {
  flex: 1;
}

.prompt-stat-card .stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1.2;
}

.prompt-stat-card .stat-label {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.125rem;
}

/* Quality Badges */
.quality-badge {
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.quality-badge.high {
  background: hsl(142, 71%, 90%);
  color: hsl(142, 71%, 35%);
}

.quality-badge.medium {
  background: hsl(48, 96%, 89%);
  color: hsl(48, 96%, 35%);
}

.quality-badge.low {
  background: hsl(0, 84%, 92%);
  color: hsl(0, 84%, 40%);
}

/* Content Layout */
.prompt-history-content {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1.5rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1200px) {
  .prompt-history-content {
    grid-template-columns: 1fr;
  }
}

/* Timeline Panel */
.prompt-history-left {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.prompt-timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.3);
  gap: 1rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.prompt-timeline-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.prompt-timeline-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-width: 0;
}

.prompt-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 120px;
  max-width: 280px;
}

.prompt-search-wrapper i {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
  z-index: 1;
}

.prompt-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  outline: none;
  transition: all 0.2s;
}

.prompt-search-input:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.1);
}

.prompt-filter-select {
  padding: 0.5rem 0.75rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  cursor: pointer;
  outline: none;
}

/* Timeline List */
.prompt-timeline-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  min-height: 0;
}

/* Session Groups */
.prompt-session-group {
  margin-bottom: 1rem;
}

.prompt-session-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--muted) / 0.2);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
}

.prompt-session-id {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  font-family: monospace;
}

.prompt-session-date {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.prompt-session-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.prompt-session-items {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 2rem;
}

/* Timeline axis - subtle vertical line */
.prompt-session-items::before {
  content: '';
  position: absolute;
  left: 0.4375rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: hsl(var(--border));
}

/* Prompt Items - Card style matching memory timeline */
.prompt-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem;
  margin-bottom: 0.625rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

/* Timeline dot - clean circle */
.prompt-item::before {
  content: '';
  position: absolute;
  left: -2rem;
  top: 1rem;
  width: 12px;
  height: 12px;
  background: hsl(var(--background));
  border: 2px solid hsl(var(--muted-foreground) / 0.4);
  border-radius: 50%;
  transform: translateX(50%);
  z-index: 1;
  transition: all 0.2s ease;
}

/* Timeline connector line to card */
.prompt-item::after {
  content: '';
  position: absolute;
  left: -1.25rem;
  top: 1.25rem;
  width: 1rem;
  height: 2px;
  background: hsl(var(--border));
}

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

.prompt-item:hover {
  border-color: hsl(var(--primary) / 0.3);
  background: hsl(var(--hover));
}

.prompt-item:hover::before {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
}

.prompt-item:hover::after {
  background: hsl(var(--primary) / 0.3);
}

.prompt-item-expanded {
  max-height: none;
  background: hsl(var(--muted) / 0.3);
  border-color: hsl(var(--primary) / 0.5);
}

.prompt-item-expanded::before {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.prompt-item-expanded::after {
  background: hsl(var(--primary) / 0.5);
}

/* Inner content layout */
.prompt-item-inner {
  flex: 1;
  min-width: 0;
}

.prompt-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.prompt-intent-tag {
  padding: 0.125rem 0.5rem;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.prompt-quality-badge {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.prompt-quality-badge.quality-high {
  background: hsl(142, 71%, 90%);
  color: hsl(142, 71%, 35%);
}

.prompt-quality-badge.quality-medium {
  background: hsl(48, 96%, 89%);
  color: hsl(48, 96%, 35%);
}

.prompt-quality-badge.quality-low {
  background: hsl(0, 84%, 92%);
  color: hsl(0, 84%, 40%);
}

.prompt-time {
  margin-left: auto;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.prompt-item-preview {
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  line-height: 1.5;
}

.prompt-item-full {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid hsl(var(--border));
}

.prompt-full-text {
  padding: 0.75rem;
  background: hsl(var(--muted) / 0.3);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: monospace;
  margin-bottom: 0.75rem;
}

.prompt-item-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.75rem;
}

.prompt-item-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.prompt-item-actions-full {
  display: flex;
  gap: 0.5rem;
}

/* Insights Panel */
.prompt-history-right {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.insights-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.3);
  flex-shrink: 0;
}

.insights-panel-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
}

.insights-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.insights-tool-select {
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.375rem;
  cursor: pointer;
  outline: none;
}

.insights-tool-select:focus {
  border-color: hsl(var(--primary));
}

.insights-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}

.insights-loading .loading-spinner {
  color: hsl(var(--primary));
  margin-bottom: 1rem;
}

.insights-loading p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.insights-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  flex: 1;
  min-height: 200px;
}

.insights-empty-state i {
  color: hsl(var(--muted-foreground));
  margin-bottom: 1rem;
}

.insights-empty-state p {
  margin: 0.25rem 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.insights-hint {
  font-size: 0.75rem !important;
}

.insights-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  min-height: 0;
}

.insights-section {
  margin-bottom: 1.5rem;
}

.insights-section:last-child {
  margin-bottom: 0;
}

.insights-section h4 {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 0 0 0.75rem 0.5rem;
}

/* Pattern Cards */
.pattern-card {
  padding: 0.875rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-left-width: 3px;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

.pattern-card.pattern-high {
  border-left-color: hsl(0, 84%, 60%);
  background: hsl(0, 84%, 97%);
}

.pattern-card.pattern-medium {
  border-left-color: hsl(48, 96%, 53%);
  background: hsl(48, 96%, 95%);
}

.pattern-card.pattern-low {
  border-left-color: hsl(142, 71%, 45%);
  background: hsl(142, 71%, 96%);
}

.pattern-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pattern-type {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: capitalize;
  color: hsl(var(--foreground));
}

.pattern-count {
  margin-left: auto;
  padding: 0.125rem 0.5rem;
  background: hsl(var(--muted));
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.pattern-description {
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.pattern-suggestion {
  display: flex;
  align-items: start;
  gap: 0.375rem;
  padding: 0.5rem;
  background: hsl(var(--background));
  border-radius: 0.375rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
}

.pattern-suggestion i {
  margin-top: 0.125rem;
  flex-shrink: 0;
}

/* Suggestion Cards */
.suggestion-card {
  padding: 0.875rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

.suggestion-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

.suggestion-description {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.suggestion-example {
  padding: 0.75rem;
  background: hsl(var(--muted) / 0.3);
  border-radius: 0.375rem;
  margin-top: 0.75rem;
}

.suggestion-example-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.375rem;
}

.suggestion-example code {
  display: block;
  font-size: 0.75rem;
  color: hsl(var(--foreground));
  line-height: 1.5;
  font-family: monospace;
  white-space: pre-wrap;
}

/* Similar Prompt Cards */
.similar-prompt-card {
  padding: 0.875rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.similar-prompt-card:hover {
  border-color: hsl(var(--primary) / 0.3);
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.1);
}

.similar-prompt-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.similar-prompt-similarity {
  padding: 0.125rem 0.5rem;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.similar-prompt-intent {
  padding: 0.125rem 0.5rem;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border-radius: 0.25rem;
  font-size: 0.75rem;
  text-transform: capitalize;
}

.similar-prompt-preview {
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.similar-prompt-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.similar-prompt-quality {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* Empty State */
.prompt-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  flex: 1;
  min-height: 200px;
}

.prompt-empty-state i {
  color: hsl(var(--muted-foreground));
  margin-bottom: 1rem;
}

.prompt-empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 0 0 0.5rem 0;
}

.prompt-empty-state p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

/* ========== Insights History Cards ========== */
.insights-history-container {
  padding: 0.75rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.insights-history-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.insight-history-card {
  padding: 0.875rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-left-width: 3px;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.insight-history-card:hover {
  background: hsl(var(--muted) / 0.5);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px hsl(var(--foreground) / 0.08);
}

.insight-history-card.high {
  border-left-color: hsl(0, 84%, 60%);
}

.insight-history-card.medium {
  border-left-color: hsl(48, 96%, 53%);
}

.insight-history-card.low {
  border-left-color: hsl(142, 71%, 45%);
}

.insight-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.insight-card-tool {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.insight-card-tool i {
  color: hsl(var(--primary));
}

.insight-card-time {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
}

.insight-card-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.625rem;
}

.insight-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
}

.insight-stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.insight-stat-label {
  font-size: 0.625rem;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.insight-card-preview {
  margin-top: 0.5rem;
}

.pattern-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  overflow: hidden;
}

.pattern-preview.high {
  background: hsl(0, 84%, 95%);
}

.pattern-preview.medium {
  background: hsl(48, 96%, 95%);
}

.pattern-preview.low {
  background: hsl(142, 71%, 95%);
}

.pattern-preview .pattern-type {
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.pattern-preview .pattern-desc {
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Insight Detail Panel */
.insight-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: hsl(var(--card));
  border-left: 1px solid hsl(var(--border));
  box-shadow: -4px 0 16px hsl(var(--foreground) / 0.1);
  z-index: 1000;
  overflow-y: auto;
  animation: slideInRight 0.2s ease;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.insight-detail {
  padding: 1.25rem;
}

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

.insight-detail-header h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.insight-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.insight-detail-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.insight-patterns,
.insight-suggestions {
  margin-bottom: 1.25rem;
}

.insight-patterns h5,
.insight-suggestions h5 {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
}

.patterns-list,
.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.pattern-item {
  padding: 0.75rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-left-width: 3px;
  border-radius: 0.5rem;
}

.pattern-item.high {
  border-left-color: hsl(0, 84%, 60%);
}

.pattern-item.medium {
  border-left-color: hsl(48, 96%, 53%);
}

.pattern-item.low {
  border-left-color: hsl(142, 71%, 45%);
}

.pattern-item .pattern-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pattern-type-badge {
  padding: 0.125rem 0.5rem;
  background: hsl(var(--muted));
  border-radius: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.pattern-severity {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  text-transform: capitalize;
}

.pattern-occurrences {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.pattern-item .pattern-description {
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.pattern-item .pattern-suggestion {
  display: flex;
  align-items: start;
  gap: 0.375rem;
  padding: 0.5rem;
  background: hsl(var(--muted) / 0.5);
  border-radius: 0.375rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.suggestion-item {
  padding: 0.75rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
}

.suggestion-item .suggestion-title {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.suggestion-item .suggestion-description {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.suggestion-item .suggestion-example {
  padding: 0.5rem;
  background: hsl(var(--muted) / 0.5);
  border-radius: 0.375rem;
}

.suggestion-item .suggestion-example code {
  font-size: 0.75rem;
  font-family: monospace;
  color: hsl(var(--foreground));
}

.insight-detail-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
}
