/* All-Time Sales Page Styles */

:root {
  --bg-primary: #f5f6fa;
  --bg-card: #ffffff;
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --accent: #FF9F43;
  --accent-light: #fff3e6;
  --border: #eee;
  --pill-bg: #f0f0f0;
  --pill-active-bg: #2c3e50;
  --pill-active-text: #fff;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --track-bg: #f0f1f5;
}

body.dark-mode {
  --bg-primary: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #e0e0e0;
  --text-secondary: #8899aa;
  --accent: #FF9F43;
  --accent-light: #2a2040;
  --border: #2a2a4a;
  --pill-bg: #2a2a4a;
  --pill-active-bg: #FF9F43;
  --pill-active-text: #1a1a2e;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --track-bg: #1e2a45;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

.alltime-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.alltime-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 20px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.back-link:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Widget Cards */
.widget-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.widget-card h2 {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Channel Selector */
.channel-selector {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.channel-selector::-webkit-scrollbar {
  display: none;
}

.channel-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  background: var(--pill-bg);
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.channel-pill:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.channel-pill.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
}

/* Chart Container */
.chart-container {
  position: relative;
  height: 400px;
}

@media (max-width: 768px) {
  .chart-container {
    height: 280px;
  }
}

/* MA Toggle Selector */
.ma-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 12px;
}

.ma-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-right: 4px;
  white-space: nowrap;
}

.ma-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.ma-pill:hover {
  border-color: var(--text-secondary);
}

.ma-pill.active {
  border-color: currentColor;
  background: var(--accent-light);
}

.ma-pill.active[data-ma="ma3"] { color: #2ecc71; border-color: #2ecc71; }
.ma-pill.active[data-ma="ma6"] { color: #3498db; border-color: #3498db; }
.ma-pill.active[data-ma="ma12"] { color: #e74c3c; border-color: #e74c3c; }

.ma-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.ma-pill.active .ma-dot {
  opacity: 1;
}

/* ============================================
   YEARLY BAR CHART
   ============================================ */
.yearly-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Scroll fade-in */
.year-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  transition: all 0.25s ease;
  cursor: default;
  position: relative;
  opacity: 0;
  transform: translateY(20px);
}

.year-bar-row.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease, background 0.25s ease;
}

.year-bar-row:hover {
  background: var(--accent-light);
}

.year-bar-row.visible:hover {
  transform: translateY(0) translateX(4px);
}

/* Current year */
.year-bar-row.current {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
}

.year-bar-row.current:hover {
  box-shadow: 0 4px 20px rgba(255, 159, 67, 0.2);
}

/* Past & Future */
.year-bar-row.past {
  background: transparent;
}

.year-bar-row.future {
  opacity: 0;
}

.year-bar-row.future.visible {
  opacity: 0.5;
}

.year-bar-row.future:hover {
  opacity: 0.8 !important;
}

/* Left label */
.year-bar-label {
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.year-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.year-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.year-bar-row.current .year-value {
  color: var(--accent);
}

/* Right side — goal + increment */
.year-bar-right {
  min-width: 120px;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.year-right-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.year-goal-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.year-goal-monthly {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Forecast section (current year, floats over bar track) */
.year-forecast {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  z-index: 2;
}

.forecast-velocity {
  font-size: 0.75rem;
  font-weight: 600;
  color: #2ecc71;
}

.forecast-total {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Increment badge */
.year-increment {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  white-space: nowrap;
}

.year-increment.ahead {
  color: #27ae60;
  background: rgba(39, 174, 96, 0.1);
}

.year-increment.behind {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

/* Track */
.year-bar-track {
  flex: 1;
  height: 32px;
  background: transparent;
  border-radius: 6px;
  position: relative;
  overflow: visible;
}

.year-bar-target-bg {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--track-bg);
  border-radius: 6px;
  z-index: 0;
}

.year-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  z-index: 1;
}

.bar-accent {
  background: linear-gradient(90deg, #FF9F43, #e67e22);
}

.bar-green {
  background: linear-gradient(90deg, #2ecc71, #27ae60);
}

.bar-orange {
  background: linear-gradient(90deg, #FF9F43, #f39c12);
}

.bar-red {
  background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.bar-muted {
  background: var(--border);
}

.year-bar-row:hover .year-bar-fill {
  filter: brightness(1.12);
  box-shadow: 0 0 10px rgba(255, 159, 67, 0.25);
}

/* Celebration emoji */
.celebration {
  position: absolute;
  right: -32px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.year-bar-row.current:hover .celebration {
  opacity: 1;
  animation: celebrateBounce 0.6s ease;
}

@keyframes celebrateBounce {
  0% {
    transform: translateY(-50%) scale(0);
  }

  50% {
    transform: translateY(-50%) scale(1.4);
  }

  70% {
    transform: translateY(-50%) scale(0.9);
  }

  100% {
    transform: translateY(-50%) scale(1);
  }
}

/* Green glow on current year hover */
.year-bar-row.current::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 14px;
  background: transparent;
  pointer-events: none;
  z-index: -1;
  transition: box-shadow 0.3s;
}

.year-bar-row.current:hover::after {
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.3), 0 0 40px rgba(46, 204, 113, 0.15);
}

/* Status badge */
.bar-status {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  z-index: 3;
  padding: 1px 6px;
  border-radius: 8px;
}

.bar-status.ahead {
  color: #27ae60;
  background: rgba(39, 174, 96, 0.1);
}

.bar-status.behind {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

@media (max-width: 768px) {
  .year-bar-label {
    min-width: 100px;
  }

  .year-value {
    font-size: 0.95rem;
  }

  .year-bar-track {
    height: 22px;
  }

  .year-bar-right {
    min-width: 80px;
  }

  .year-goal-value {
    font-size: 0.75rem;
  }
}

/* Loader */
.alltime-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.alltime-loader.active {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   CORRELATION SECTION
   ============================================ */
.correlation-grid {
  padding: 8px 0;
}

.corr-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.corr-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.corr-card {
  background: var(--bg-primary);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.corr-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.corr-value {
  font-size: 24px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.corr-strength {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}