/* ============================================
   HEATMAP PAGE STYLES
   Extends variables from style.css
   ============================================ */

/* Inherit base variables from main stylesheet */
@import url('./style.css');

/* Apply Outfit font */
body {
  font-family: 'Outfit', sans-serif;
}

/* ============================================
   HEATMAP COLOR SCALE (Orange Theme)
   ============================================ */
:root {
  /* Light Mode - Orange Intensity Scale (6 levels) */
  --heat-0: #ebedf0;
  /* No sales (grey) */
  --heat-1: #fff7ed;
  /* Very low - 0-20th percentile */
  --heat-2: #ffedd5;
  /* Low - 20-40th percentile */
  --heat-3: #fed7aa;
  /* Medium - 40-60th percentile */
  --heat-4: #fdba74;
  /* Medium-high - 60-80th percentile */
  --heat-5: #f97316;
  /* High - 80th+ percentile */

  /* Heatmap specific */
  --cell-size: 14px;
  --cell-gap: 3px;
  --cell-radius: 3px;
}

body.dark-mode {
  /* Dark Mode - Adjusted Orange Scale (6 levels) */
  --heat-0: #2d2d2d;
  --heat-1: #3d3228;
  --heat-2: #4a3728;
  --heat-3: #6b4423;
  --heat-4: #8c511e;
  --heat-5: #f97316;
}

/* ============================================
   PAGE LAYOUT
   ============================================ */
.heatmap-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
}

/* ============================================
   HEADER
   ============================================ */
.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.back-link:hover {
  background: var(--primary-orange-light);
  border-color: var(--primary-orange);
}

.heatmap-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-dark);
  letter-spacing: -0.5px;
}

/* ============================================
   WIDGET CARDS
   ============================================ */
.widget-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-color);
  overflow: visible;
}

.widget-card h2 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-grey);
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.widget-header h2 {
  margin-bottom: 0;
}

.detail-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================
   MODE TABS
   ============================================ */
.mode-tabs {
  display: flex;
  background: var(--bg-color);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border-color);
}

.mode-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-grey);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.2s;
}

.mode-tab:hover {
  color: var(--text-dark);
}

.mode-tab.active {
  background: var(--primary-orange);
  color: white;
}

/* ============================================
   NAVIGATION PICKER (Year/Month)
   ============================================ */
.nav-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-picker.hidden {
  display: none;
}

.nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--primary-orange-light);
  border-color: var(--primary-orange);
}

.nav-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  min-width: 80px;
  text-align: center;
}

/* ============================================
   HEATMAP GRID
   ============================================ */
.heatmap-scroll-container {
  overflow-x: auto;
  padding-bottom: 24px;
  /* Space for month labels */
}

.heatmap-grid {
  display: flex;
  gap: var(--cell-gap);
  width: fit-content;
}

/* Weekday labels column */
.weekday-labels {
  display: flex;
  flex-direction: column;
  gap: var(--cell-gap);
  flex-shrink: 0;
  padding-right: 8px;
  position: sticky;
  left: 0;
  background: var(--card-bg);
  z-index: 2;
}

.weekday-label {
  height: var(--cell-size);
  font-size: 10px;
  color: var(--text-grey);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
}

/* Week columns */
.weeks-container {
  display: flex;
  gap: var(--cell-gap);
}

.week-column {
  display: flex;
  flex-direction: column;
  gap: var(--cell-gap);
}

/* Weekday averages column */
.weekday-averages {
  display: flex;
  flex-direction: column;
  gap: var(--cell-gap);
  padding-left: 12px;
  flex-shrink: 0;
}

.weekday-avg {
  height: var(--cell-size);
  font-size: 9px;
  color: var(--text-grey);
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* Individual cells */
.heatmap-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: var(--cell-radius);
  background-color: var(--heat-0);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}

.heatmap-cell:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.heatmap-cell.level-0 {
  background-color: var(--heat-0);
}

.heatmap-cell.level-1 {
  background-color: var(--heat-1);
}

.heatmap-cell.level-2 {
  background-color: var(--heat-2);
}

.heatmap-cell.level-3 {
  background-color: var(--heat-3);
}

.heatmap-cell.level-4 {
  background-color: var(--heat-4);
}

.heatmap-cell.level-5 {
  background-color: var(--heat-5);
}

/* Empty cells (outside date range) - invisible */
.heatmap-cell.empty {
  background-color: transparent;
  cursor: default;
  visibility: hidden;
}

.heatmap-cell.empty:hover {
  transform: none;
  box-shadow: none;
}

/* Month labels row - inside scroll container */
.month-labels-row {
  display: flex;
  gap: 0;
  margin-top: 8px;
  padding-left: 32px;
  height: 16px;
  position: relative;
  width: fit-content;
  min-width: 100%;
}

.month-marker {
  font-size: 10px;
  color: var(--text-grey);
  white-space: nowrap;
  position: absolute;
}

/* ============================================
   TOOLTIP
   ============================================ */
.heatmap-tooltip {
  position: fixed;
  background: var(--text-dark);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}

body.dark-mode .heatmap-tooltip {
  background: #f5f5f5;
  color: #1a1a1a;
}

.heatmap-tooltip.visible {
  opacity: 1;
}

.heatmap-tooltip .tooltip-date {
  font-weight: 600;
  margin-bottom: 4px;
}

.heatmap-tooltip .tooltip-sales {
  color: var(--primary-orange);
  font-weight: 700;
}

body.dark-mode .heatmap-tooltip .tooltip-sales {
  color: #ea580c;
}

/* ============================================
   LEGEND
   ============================================ */
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

.legend-label {
  font-size: 11px;
  color: var(--text-grey);
}

.legend-cells {
  display: flex;
  gap: 3px;
}

.legend-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  cursor: pointer;
}

/* ============================================
   MONTHLY TOTALS STRIP
   ============================================ */
.monthly-strip-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.monthly-strip {
  display: flex;
  gap: 12px;
  min-width: min-content;
}

.monthly-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
  flex-shrink: 0;
}

.monthly-bar-visual {
  height: 60px;
  width: 40px;
  background: var(--border-color);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.monthly-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--primary-orange), var(--heat-3));
  border-radius: 6px;
  transition: height 0.3s ease;
}

.monthly-bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-grey);
  margin-top: 8px;
}

.monthly-bar-value {
  font-size: 10px;
  color: var(--text-dark);
  font-weight: 700;
  margin-top: 2px;
}

/* ============================================
   LOADER
   ============================================ */
.heatmap-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.dark-mode .heatmap-loader {
  background: rgba(26, 26, 26, 0.8);
}

.heatmap-loader.active {
  opacity: 1;
  pointer-events: all;
}

/* No data state */
.no-data {
  padding: 40px;
  text-align: center;
  color: var(--text-grey);
  font-size: 14px;
}

/* ============================================
   MOBILE ADJUSTMENTS
   ============================================ */
@media (max-width: 600px) {
  .heatmap-container {
    padding: 12px;
  }

  .heatmap-header h1 {
    font-size: 20px;
  }

  :root {
    --cell-size: 12px;
    --cell-gap: 2px;
  }

  .widget-card {
    padding: 16px;
  }

  .widget-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-controls {
    width: 100%;
    justify-content: space-between;
  }

  .monthly-bar {
    min-width: 50px;
  }

  .monthly-bar-visual {
    height: 50px;
    width: 32px;
  }

  .month-labels-row {
    margin-left: calc(20px + 8px);
  }
}