/* Dashboard Modal Overlay */
.dashboard-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: var(--z-modal);
  display: none;
  justify-content: center;
  align-items: center;
}

.dashboard-modal-content {
  position: relative;
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--color-base);
  border-radius: var(--fjm-border-radius);
  border: 1px solid var(--color-secondary);
}

.dashboard-modal-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 20px;
  cursor: pointer;
  z-index: 3;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--fjm-button-border-radius);
}

.dashboard-modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Dashboard Styles */
.dashboard-container {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  padding-right: 36px;
  border-bottom: 1px solid var(--color-secondary);
  position: sticky;
  top: -16px;
  z-index: 2;
  background: var(--color-base);
  margin: -16px -16px 20px -16px;
  padding: 16px 52px 12px 16px;
}

.dashboard-header h3 {
  margin: 0;
  color: #00bcd4;
  font-size: 18px;
}

.dashboard-clear-btn {
  background: #f44336;
  color: var(--color-text-primary);
  border: none;
  padding: 6px 12px;
  border-radius: var(--fjm-button-border-radius);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.dashboard-clear-btn:hover {
  background: #d32f2f;
}

/* Summary Cards */
.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--color-base);
  border-radius: var(--fjm-border-radius);
  padding: 8px 10px;
  text-align: center;
  border: 1px solid var(--color-secondary);
}

.summary-value {
  font-size: 16px;
  font-weight: bold;
  color: #00bcd4;
  margin-bottom: 2px;
}

.summary-label {
  font-size: 10px;
  color: var(--slider-accent);
}

/* Dashboard Sections */
.dashboard-section {
  background: var(--color-base);
  border-radius: var(--fjm-border-radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--color-secondary);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h4 {
  margin: 0;
  color: var(--color-text-primary);
  font-size: 14px;
}

/* Mode Selector */
.mode-selector {
  background: var(--color-base);
  color: var(--color-text-primary);
  border: 1px solid var(--color-tertiary);
  padding: 4px 8px;
  border-radius: var(--textarea-border-radius);
  font-size: 12px;
  cursor: pointer;
}

.mode-selector:focus {
  outline: none;
  border-color: #00bcd4;
}

/* Stats Table */
.stats-table-container {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.stats-table th,
.stats-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-secondary);
}

.stats-table th {
  color: var(--slider-accent);
  font-weight: normal;
  font-size: 10px;
}

.stats-table td {
  color: var(--color-text-primary);
}

.stats-table tbody tr:hover {
  background: var(--color-secondary);
}

/* Chart Container */
.chart-container {
  background: var(--color-base);
  border-radius: var(--fjm-button-border-radius);
  padding: 8px;
}

#dashboardChart {
  width: 100%;
  height: 200px;
}

/* Top Tags */
.top-tags-container {
  max-height: 300px;
  overflow-y: auto;
}

.tag-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-secondary);
}

.tag-item:last-child {
  border-bottom: none;
}

.tag-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.tag-name {
  color: var(--color-text-primary);
  font-size: 13px;
  word-break: break-all;
}

.tag-count {
  color: #00bcd4;
  font-size: 12px;
  font-weight: bold;
  min-width: 30px;
  text-align: right;
}

.tag-bar-container {
  background: var(--color-secondary);
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
}

.tag-bar {
  height: 100%;
  background: linear-gradient(90deg, #00bcd4, #4caf50);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.no-tags {
  color: var(--slider-accent);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* Heatmap Styles */
.heatmap-container {
  overflow-x: auto;
  padding: 8px 0;
}

.heatmap-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: fit-content;
}

.heatmap-row {
  display: flex;
  gap: 2px;
  align-items: center;
}

.heatmap-header {
  margin-bottom: 4px;
}

.heatmap-label {
  width: 40px;
  font-size: 10px;
  color: var(--slider-accent);
  text-align: right;
  padding-right: 8px;
  flex-shrink: 0;
}

.heatmap-hour {
  width: 20px;
  height: 16px;
  font-size: 9px;
  color: var(--slider-accent);
  text-align: center;
  flex-shrink: 0;
}

.heatmap-cell {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.1s;
}

.heatmap-cell:hover {
  transform: scale(1.2);
  z-index: 1;
}

/* Trend Chart */
#dashboardTrendChart {
  width: 100%;
  height: 200px;
}

/* Small Clear Button */
.dashboard-clear-btn-small {
  background: #f44336;
  color: var(--color-text-primary);
  border: none;
  padding: 4px 8px;
  border-radius: var(--fjm-button-border-radius);
  cursor: pointer;
  font-size: 11px;
  transition: background 0.2s;
}

.dashboard-clear-btn-small:hover {
  background: #d32f2f;
}

/* Download Button */
.dashboard-download-btn {
  background: #00bcd4;
  color: var(--color-base);
  border: none;
  padding: 4px 8px;
  border-radius: var(--fjm-button-border-radius);
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
  transition: background 0.2s;
}

.dashboard-download-btn:hover {
  background: #00acc1;
}

/* Wordcloud */
.wordcloud-container {
  background: var(--color-base);
  border-radius: var(--fjm-button-border-radius);
  padding: 8px;
  overflow: visible;
}

#dashboardWordcloud {
  width: 100%;
  height: 300px;
  display: block;
  max-width: 100%;
}

/* Streak & Session Row */
.streak-session-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.streak-card {
  flex: 1;
  min-width: 80px;
  background: var(--color-base);
  border-radius: var(--fjm-border-radius);
  padding: 12px;
  text-align: center;
  border: 1px solid var(--color-secondary);
}

.streak-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.streak-value {
  font-size: 22px;
  font-weight: bold;
  color: #00bcd4;
}

.streak-label {
  font-size: 10px;
  color: var(--slider-accent);
  margin-top: 2px;
}

/* GitHub Calendar */
.calendar-container {
  overflow-x: auto;
  padding: 8px 0;
}

.calendar-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: fit-content;
}

.calendar-months {
  display: flex;
  gap: 0;
  padding-left: 28px;
  margin-bottom: 4px;
}

.calendar-month-label {
  font-size: 9px;
  color: var(--slider-accent);
  text-align: left;
}

.calendar-body {
  display: flex;
  gap: 0;
}

.calendar-day-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: 4px;
}

.calendar-day-label {
  width: 24px;
  height: 11px;
  font-size: 9px;
  color: var(--slider-accent);
  text-align: right;
  line-height: 11px;
}

.calendar-grid {
  display: flex;
  gap: 2px;
}

.calendar-week {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  cursor: pointer;
}

.calendar-cell:hover {
  outline: 1px solid var(--color-text-primary);
  outline-offset: -1px;
}

.calendar-cell-empty {
  width: 11px;
  height: 11px;
}

.calendar-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  justify-content: flex-end;
  font-size: 9px;
  color: var(--slider-accent);
}

.calendar-legend-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
}

/* Success Rate */
.success-rate-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
}

#dashboardSuccessRateChart {
  max-width: 250px;
  max-height: 150px;
}

/* Prompt Length Chart */
#dashboardPromptLengthChart {
  width: 100%;
  height: 200px;
}

/* Co-occurrence Table */
.cooccurrence-table td:first-child {
  max-width: 300px;
  word-break: break-all;
}

/* Model Chart */
.model-chart-container {
  min-height: 120px;
}

#dashboardModelChart {
  width: 100%;
  height: 200px;
}

/* Goals */
.goal-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.goal-label {
  color: var(--color-text-primary);
  font-size: 12px;
  min-width: 80px;
}

.goal-input {
  width: 70px;
  background: var(--color-base);
  color: var(--color-text-primary);
  border: 1px solid var(--color-tertiary);
  padding: 4px 8px;
  border-radius: var(--textarea-border-radius);
  font-size: 12px;
}

.goal-input:focus {
  outline: none;
  border-color: #00bcd4;
}

.goal-save-btn {
  padding: 4px 10px;
}

.goal-progress-wrap {
  background: var(--color-secondary);
  border-radius: 4px;
  height: 20px;
  overflow: hidden;
  position: relative;
}

.goal-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #00bcd4, #4caf50);
  border-radius: 4px;
  transition: width 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.goal-progress-bar span {
  font-size: 10px;
  color: var(--color-text-primary);
  white-space: nowrap;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Badges */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.badge-item {
  background: var(--color-base);
  border-radius: var(--fjm-border-radius);
  padding: 10px 6px;
  text-align: center;
  border: 1px solid var(--color-secondary);
  transition: transform 0.2s;
}

.badge-item:hover {
  transform: scale(1.05);
}

.badge-item.badge-locked {
  opacity: 0.4;
  filter: grayscale(1);
}

.badge-icon {
  font-size: 28px;
  margin-bottom: 4px;
}

.badge-name {
  font-size: 10px;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.badge-item.badge-locked .badge-name {
  color: var(--slider-accent);
}

/* Export */
.export-section {
  display: flex;
  gap: 8px;
}

/* Scrollbar Styles */
.dashboard-container::-webkit-scrollbar,
.top-tags-container::-webkit-scrollbar {
  width: 6px;
}

.dashboard-container::-webkit-scrollbar-track,
.top-tags-container::-webkit-scrollbar-track {
  background: var(--color-base);
}

.dashboard-container::-webkit-scrollbar-thumb,
.top-tags-container::-webkit-scrollbar-thumb {
  background: var(--color-tertiary);
  border-radius: 3px;
}

.dashboard-container::-webkit-scrollbar-thumb:hover,
.top-tags-container::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent-hover);
}

/* Light theme */
body:not(.dark-mode) .dashboard-modal-content {
  background: #fff;
  border-color: #ddd;
}

body:not(.dark-mode) .dashboard-header {
  border-color: #ddd;
  background: #fff;
}

body:not(.dark-mode) .dashboard-header h3 {
  color: #0097a7;
}

body:not(.dark-mode) .dashboard-section {
  background: #f5f5f5;
  border-color: #ddd;
}

body:not(.dark-mode) .section-header h4 {
  color: #333;
}

body:not(.dark-mode) .summary-card {
  background: #f5f5f5;
  border-color: #ddd;
}

body:not(.dark-mode) .summary-value {
  color: #0097a7;
}

body:not(.dark-mode) .summary-label {
  color: #767676;
}

body:not(.dark-mode) .streak-card {
  background: #fff;
  border-color: #ddd;
}

body:not(.dark-mode) .streak-value {
  color: #0097a7;
}

body:not(.dark-mode) .streak-label {
  color: #767676;
}

body:not(.dark-mode) .chart-container {
  background: #fff;
}

body:not(.dark-mode) .mode-selector {
  background: #fff;
  color: #333;
  border-color: #ccc;
}

body:not(.dark-mode) .stats-table th {
  color: #767676;
}

body:not(.dark-mode) .stats-table td {
  color: #333;
}

body:not(.dark-mode) .stats-table th,
body:not(.dark-mode) .stats-table td {
  border-color: #ddd;
}

body:not(.dark-mode) .stats-table tbody tr:hover {
  background: #eee;
}

body:not(.dark-mode) .tag-name {
  color: #333;
}

body:not(.dark-mode) .tag-count {
  color: #0097a7;
}

body:not(.dark-mode) .tag-bar-container {
  background: #ddd;
}

body:not(.dark-mode) .no-tags {
  color: #767676;
}

body:not(.dark-mode) .goal-input {
  background: #fff;
  color: #333;
  border-color: #ccc;
}

body:not(.dark-mode) .goal-label {
  color: #333;
}

body:not(.dark-mode) .goal-progress-wrap {
  background: #ddd;
}

body:not(.dark-mode) .badge-item {
  background: #fff;
  border-color: #ddd;
}

body:not(.dark-mode) .badge-name {
  color: #333;
}

body:not(.dark-mode) .badge-item.badge-locked .badge-name {
  color: #767676;
}

body:not(.dark-mode) .wordcloud-container {
  background: #fff;
}

body:not(.dark-mode) .dashboard-modal-close-btn {
  color: #333;
}

body:not(.dark-mode) .dashboard-modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

body:not(.dark-mode) .calendar-month-label,
body:not(.dark-mode) .calendar-day-label,
body:not(.dark-mode) .calendar-legend {
  color: #767676;
}

body:not(.dark-mode) .heatmap-label {
  color: #767676;
}

body:not(.dark-mode) .heatmap-hour {
  color: #767676;
}

body:not(.dark-mode) .dashboard-container::-webkit-scrollbar-track,
body:not(.dark-mode) .top-tags-container::-webkit-scrollbar-track {
  background: #f5f5f5;
}

body:not(.dark-mode) .dashboard-container::-webkit-scrollbar-thumb,
body:not(.dark-mode) .top-tags-container::-webkit-scrollbar-thumb {
  background: #ccc;
}

/* Responsive */
@media (max-width: 768px) {
  .dashboard-summary {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .summary-card {
    padding: 6px 8px;
  }

  .summary-value {
    font-size: 14px;
  }

  .stats-table {
    font-size: 11px;
  }

  .stats-table th,
  .stats-table td {
    padding: 6px 8px;
  }

  .streak-session-row {
    gap: 6px;
  }

  .streak-card {
    padding: 8px;
  }

  .badge-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 6px;
  }
}
