/* Beautiful Heatmap Styles */
.heatmap-container {
  background: var(--panel);
  border-radius: 12px;
  padding: 24px;
  margin: 20px 0;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Heatmap Color Levels */
.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.heatmap-cell:hover {
  transform: scale(1.2);
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Activity Level Colors */
.heatmap-cell.level-0 {
  background-color: #ebedf0;
  border-color: #d1d5da;
}

.heatmap-cell.level-1 {
  background-color: #c6e48b;
  border-color: #9be9a8;
}

.heatmap-cell.level-2 {
  background-color: #7bc96f;
  border-color: #40c463;
}

.heatmap-cell.level-3 {
  background-color: #239a3b;
  border-color: #30a14e;
}

.heatmap-cell.level-4 {
  background-color: #196127;
  border-color: #216e39;
}

.heatmap-cell.today {
  border: 2px solid #ff6b6b;
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
}

.heatmap-cell.has-data {
  border-color: rgba(255, 255, 255, 0.2);
}

.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.heatmap-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.heatmap-title::before {
  content: "📈";
  font-size: 1.2rem;
}

.heatmap-stats {
  display: flex;
  gap: 16px;
  align-items: center;
}

.heatmap-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  background: var(--panel2);
  border-radius: 8px;
  border: 1px solid var(--border);
  min-width: 60px;
}

.heatmap-stat-number {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.heatmap-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--panel2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.heatmap-legend-title {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.heatmap-legend-items {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heatmap-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.heatmap-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.heatmap-legend-color.less {
  background: #161b22;
}

.heatmap-legend-color.low {
  background: #0e4429;
}

.heatmap-legend-color.medium {
  background: #006d32;
}

.heatmap-legend-color.high {
  background: #26a641;
}

.heatmap-legend-color.more {
  background: #39d353;
}

.heatmap-layout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 8px;
}

/* Month labels row - above everything */
.heatmap-months {
  display: flex;
  flex-direction: row;
  gap: 2px;
  margin-bottom: 4px;
  padding-left: 28px; /* Space for day labels */
  min-height: 20px;
  align-items: center;
  position: relative;
}

.heatmap-month {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 20px;
  text-align: center;
  padding: 2px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Day labels row - below months */
.heatmap-days {
  display: flex;
  flex-direction: row;
  gap: 2px;
  margin-bottom: 4px;
  min-height: 20px;
  justify-content: flex-start;
  padding-left: 28px; /* Space for day labels */
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

.heatmap-day-label {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Main heatmap content */
.heatmap-content {
  display: flex;
  flex-direction: row;
  gap: 2px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
}

.heatmap-grid {
  display: flex;
  flex-direction: row;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
}

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

.heatmap-cell {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: transparent;
}

.heatmap-cell:hover {
  transform: scale(1.2);
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-color: var(--accent);
}

.heatmap-cell:hover .heatmap-cell-text {
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.heatmap-cell-text {
  transition: color 0.2s ease;
}

/* Activity levels */
.heatmap-cell.level-0 {
  background: #161b22;
}

.heatmap-cell.level-1 {
  background: #0e4429;
}

.heatmap-cell.level-2 {
  background: #006d32;
}

.heatmap-cell.level-3 {
  background: #26a641;
}

.heatmap-cell.level-4 {
  background: #39d353;
}

/* Special states */
.heatmap-cell.today {
  border: 2px solid var(--accent);
  box-shadow: 0 0 8px rgba(74, 158, 255, 0.3);
}

.heatmap-cell.selected {
  border: 2px solid #ff6b6b;
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
}

.heatmap-cell.has-data {
  position: relative;
}

.heatmap-cell.has-data::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.7;
}

/* Tooltip */
.heatmap-tooltip {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  min-width: 200px;
}

.heatmap-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.heatmap-tooltip-date {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.heatmap-tooltip-activity {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 8px;
}

.heatmap-tooltip-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.heatmap-tooltip-detail {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
}

.heatmap-tooltip-detail-label {
  color: var(--text-muted);
}

.heatmap-tooltip-detail-value {
  color: var(--text);
  font-weight: 500;
}

/* Responsive design */
@media (max-width: 768px) {
  .heatmap-container {
    padding: 12px;
    margin: 12px 0;
    border-radius: 8px;
  }
  
  .heatmap-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 16px;
  }
  
  .heatmap-title {
    font-size: 1.25rem;
  }
  
  .heatmap-stats {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    justify-content: space-between;
  }
  
  .heatmap-stat {
    min-width: 45px;
    padding: 6px 8px;
    flex: 1;
    max-width: 80px;
  }
  
  .heatmap-stat-number {
    font-size: 0.9rem;
  }
  
  .heatmap-stat-label {
    font-size: 0.65rem;
  }
  
  .heatmap-legend {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  
  .heatmap-legend-items {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .heatmap-legend-item {
    font-size: 0.7rem;
  }
  
  .heatmap-legend-color {
    width: 10px;
    height: 10px;
  }
  
  .heatmap-layout {
    gap: 6px;
  }
  
  .heatmap-months {
    padding-left: 24px;
    gap: 1px;
  }
  
  .heatmap-month {
    min-width: 14px;
    font-size: 0.65rem;
    padding: 1px 0;
  }
  
  .heatmap-days {
    padding-left: 24px;
    gap: 1px;
  }
  
  .heatmap-day-label {
    width: 14px;
    height: 14px;
    font-size: 0.65rem;
  }
  
  .heatmap-cell {
    width: 14px;
    height: 14px;
    border-radius: 2px;
  }
  
  .heatmap-week {
    gap: 1px;
  }
  
  .heatmap-grid {
    gap: 1px;
  }
  
  .heatmap-content {
    gap: 1px;
  }
}

@media (max-width: 480px) {
  .heatmap-container {
    padding: 8px;
    margin: 8px 0;
  }
  
  .heatmap-header {
    margin-bottom: 12px;
  }
  
  .heatmap-title {
    font-size: 1.1rem;
  }
  
  .heatmap-stats {
    gap: 4px;
  }
  
  .heatmap-stat {
    min-width: 40px;
    padding: 4px 6px;
    max-width: 70px;
  }
  
  .heatmap-stat-number {
    font-size: 0.8rem;
  }
  
  .heatmap-stat-label {
    font-size: 0.6rem;
  }
  
  .heatmap-legend {
    padding: 8px;
  }
  
  .heatmap-legend-title {
    font-size: 0.8rem;
  }
  
  .heatmap-legend-items {
    gap: 4px;
  }
  
  .heatmap-legend-item {
    font-size: 0.65rem;
  }
  
  .heatmap-legend-color {
    width: 8px;
    height: 8px;
  }
  
  .heatmap-months {
    padding-left: 20px;
  }
  
  .heatmap-month {
    min-width: 12px;
    font-size: 0.6rem;
  }
  
  .heatmap-days {
    padding-left: 20px;
  }
  
  .heatmap-day-label {
    width: 12px;
    height: 12px;
    font-size: 0.6rem;
  }
  
  .heatmap-cell {
    width: 12px;
    height: 12px;
    border-radius: 1px;
  }
  
  .heatmap-cell:hover {
    transform: scale(1.3);
  }
  
  /* Better touch targets for mobile */
  .heatmap-cell {
    min-width: 16px;
    min-height: 16px;
  }
  
  .heatmap-tooltip {
    font-size: 0.8rem;
    padding: 8px;
    min-width: 150px;
  }
  
  .heatmap-tooltip-date {
    font-size: 0.9rem;
  }
  
  .heatmap-tooltip-detail {
    font-size: 0.7rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .heatmap-cell {
    min-width: 18px;
    min-height: 18px;
  }
  
  .heatmap-cell:hover {
    transform: none;
  }
  
  .heatmap-cell:active {
    transform: scale(0.95);
  }
  
  .heatmap-tooltip {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 90vw;
    z-index: 1001;
  }
}

/* Animation for loading */
.heatmap-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.heatmap-loading::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Fade in animation */
.heatmap-grid {
  animation: fadeInUp 0.6s ease-out;
}

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

/* Custom scrollbar for heatmap */
.heatmap-layout::-webkit-scrollbar {
  height: 6px;
}

.heatmap-layout::-webkit-scrollbar-track {
  background: var(--panel2);
  border-radius: 3px;
}

.heatmap-layout::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.heatmap-layout::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Modal styles for date details */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 12px 12px 0 0;
}

.modal-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  color: var(--text);
  background: var(--panel);
}

.modal-body {
  padding: 24px;
}

.date-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.stat-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border-radius: 8px;
  color: white;
}

.stat-content {
  flex: 1;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Responsive modal */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 20px;
  }
  
  .modal-header {
    padding: 16px 20px;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  .date-stats {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .stat-item {
    padding: 12px;
  }
  
  .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
  }
  
  .stat-number {
    font-size: 1.25rem;
  }
}
