/* History and chart styles for the Flow State app */

/* Session history styling */
#historyList {
  list-style: none;
  max-height: 500px;
  /* Increased from 300px to 400px to make it taller */
  overflow-y: auto;
}

#historyList li {
  padding: 12px;
  margin-bottom: 10px;
  border-left: 3px solid var(--accent);
  background: rgba(41, 121, 255, 0.1);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.history-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 500;
}

.history-header span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.history-duration {
  background: var(--accent);
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.history-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.9rem;
}

.history-label {
  color: var(--muted);
}

.history-value {
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chart styles */
#chartContainer {
  width: 100%;
  height: 250px;
  /* Increased height from 200px to 250px */
  margin-top: 12px;
  position: relative;
}

.chart-bar {
  position: absolute;
  bottom: 0;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height 0.5s ease;
}

/* Bar container for animation purposes */
.bar-container {
  position: absolute;
  bottom: 0;
  overflow: visible;
  transform-origin: bottom;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  /* Add pointer cursor to indicate clickable */
  transition: all 0.3s ease;
  /* Add transition for hover and highlight effects */
  border: 2px solid transparent;
  /* Prepare for highlight border */
}

/* Bar container hover effect - subtle brightening instead of scaling */
.bar-container:hover {
  filter: brightness(1.05);
  /* Slightly brighter on hover instead of scaling */
}

/* Highlighted bar (clicked) state - using border instead of transform */
.bar-container-highlighted {
  border: 2px solid var(--accent-bright, #4d9fff);
  /* Bright border for highlighted bars */
  z-index: 10;
  /* Keep highlighted bars on top */
  filter: brightness(1.05);
  /* Make highlighted bars slightly brighter */
  /* Remove the transform scale that was making it taller */
}

/* Paused state - bars at height 0 */
.bar-container-paused {
  transform: scaleY(0);
  opacity: 0;
}

/* Animated state - trigger the animation */
.bar-container-animated {
  animation: bar-grow 2.5s cubic-bezier(0.075, 0.82, 0.165, 1) forwards;
  animation-delay: calc(0.1s * var(--bar-index, 0));
  /* Sequential animation based on index */
}

/* New chart bar segment for stacked bars */
.chart-bar-segment {
  position: absolute;
  bottom: 0;
  /* Add a subtle border at the top of each segment */
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease-out;
  /* Smooth transition for hover effects */
}

/* Segment hover effect */
.chart-bar-segment:hover {
  filter: brightness(1.15);
  /* Brighten segment on hover */
}

/* When bar is highlighted, dim non-hovered segments slightly */
.bar-container-highlighted .chart-bar-segment:not(:hover) {
  filter: brightness(1);
  /* Reset brightness for non-hovered segments */
}

/* Project highlighting styles */
.chart-bar-segment.project-highlighted {
  filter: brightness(1.2) !important;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  z-index: 20;
  /* Ensure highlighted segments stay on top */
  border: 1px solid rgba(255, 255, 255, 0.4);
  transform: scale(1.03);
  /* Subtle scaling for emphasis */
  transition: all 0.2s ease-out;
}

/* Reset document-level click handler */
body.chart-highlight-active {
  cursor: default;
}

/* Bar animation */
@keyframes bar-grow {
  0% {
    transform: scaleY(0);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* Only apply border radius to the top of the top-most segment in a stack */
.chart-bar-segment:last-child {
  border-radius: 3px 3px 0 0;
}

/* No border radius for segments that are not at the top */
.chart-bar-segment:not(:last-child) {
  border-radius: 0;
}

/* For the bottom segment, only round the bottom corners if it's alone */
.chart-bar-segment:first-child:last-child {
  border-radius: 3px 3px 0 0;
  /* Remove border from the first/only segment */
  border-top: none;
}

.chart-label {
  position: absolute;
  bottom: -20px;
  font-size: 0.75rem;
  text-align: center;
  color: var(--muted);
}

.chart-grid-line {
  position: absolute;
  width: 100%;
  height: 1px;
  background: var(--shadow);
}

.chart-y-label {
  position: absolute;
  left: -25px;
  font-size: 0.75rem;
  color: var(--muted);
  transform: translateY(-50%);
}

.chart-title {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 14px;
  text-align: center;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 1em;
}

#chartContainer::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--muted);
}

/* Chart comparison indicators */
.chart-comparison {
  display: inline-block;
  font-size: 0.8rem;
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: 400;
}

.chart-comparison.positive {
  background-color: rgba(0, 180, 0, 0.1);
  color: rgb(0, 140, 0);
}

.chart-comparison.negative {
  background-color: rgba(255, 0, 0, 0.1);
  color: rgb(200, 0, 0);
}

/* Chart legend styles */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 15px;
  justify-content: center;
  padding: 8px;
  background: var(--bg-alt);
  border-radius: var(--radius);
  max-width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--fg);
  background: var(--bg);
  padding: 3px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.legend-item:hover {
  background-color: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Active/clicked legend item */
.legend-item.active {
  background-color: var(--accent);
  color: white;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.legend-item.active .legend-color {
  border: 2px solid white;
}

.legend-color {
  position: relative;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-item span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Deleted project styling */
.legend-item[data-deleted="true"] {
  font-style: italic;
  opacity: 0.8;
}

.legend-item.deleted-project span:not(.color-x-mark) {
  text-decoration: line-through;
  color: var(--muted);
}

.legend-item.deleted-project {
  opacity: 0.7;
  background-color: rgba(0, 0, 0, 0.05);
}

/* X mark inside the color dot */
.color-x-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8px;
  font-weight: bold;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.7);
}

.deleted-icon {
  font-size: 0.7rem;
  color: #888888;
  margin-left: 4px;
}

/* Custom tooltip for immediate feedback */
.custom-tooltip {
  position: absolute;
  background: var(--bg-alt);
  color: var(--fg);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  border: 1px solid var(--muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  z-index: 1000;
  max-width: 200px;
  white-space: normal;
  /* Allow text to wrap */
  word-wrap: break-word;
  /* Break long words if necessary */
  transition: opacity 0.2s ease, transform 0.2s ease;
  /* Smooth tooltip animation */
  transform-origin: top left;
}

/* Tooltip animation when appearing */
.custom-tooltip.tooltip-show {
  animation: tooltip-pop 0.25s ease-out forwards;
}

/* Enhanced tooltip style for day summary */
.custom-tooltip.day-summary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 500;
}

/* Project tooltip when highlighted */
.custom-tooltip.project-summary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 500;
  max-width: 250px;
  padding: 8px 12px;
}

.custom-tooltip.project-summary .project-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
  display: block;
}

.custom-tooltip.project-summary .project-stat {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
}

.custom-tooltip.project-summary .stat-trend {
  display: inline-block;
  padding: 4px;
  border-radius: 3px;
  margin-left: 4px;
  font-size: 0.75rem;
}

.custom-tooltip.project-summary .stat-trend.positive {
  background-color: rgba(255, 255, 255, 0.2);
}

.custom-tooltip.project-summary .stat-trend.negative {
  background-color: rgba(255, 0, 0, 0.2);
}

/* Tooltip pop animation */
@keyframes tooltip-pop {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }

  70% {
    transform: scale(1.05);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* View control buttons for switching between weekly/monthly view */
.view-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
  font-size: 0.85rem;
}

.view-btn {
  padding: 3px 10px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.8rem;
}

.view-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Monthly view specific styles */
.monthly-label {
  font-size: 0.65rem;
  /* Smaller font size for monthly labels */
  white-space: nowrap;
}

/* Hide certain labels in monthly view to avoid cluttering */
.chart-label:empty {
  display: none;
}

/* Chart header with title and view controls */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.chart-title {
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Chart navigation */
.chart-navigation {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 5px;
}

.nav-btn {
  padding: 3px 1em;
  border: 1px solid var(--border);
  background: var(--bg-alt);
}

justify-contPeriodBtn {
  min-width: 60px;
}

/* View mode buttons pill */
.view-pill {
  display: flex;
  align-items: center;
  background: var(--bg-alt);
  border-radius: 20px;
  padding: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.view-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  position: relative;
  z-index: 1;
  color: var(--fg);
  border-radius: 18px;
}

.view-btn.active {
  background: var(--accent);
  color: white;
}

@media (max-width: 600px) {
  .view-btn:last-child {
    flex-direction: column;
    align-items: flex-start;
  }

  .view-controls {
    display: flex;
    justify-items: end;
    align-items: end;
    flex-direction: column-reverse;
    gap: 2px;
  }

  .chart-header {
    /* flex-direction: column; */
    align-items: flex-start;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .view-controls {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    flex-direction: column-reverse;
    gap: 4px;
  }
}

/* Define a brighter accent color if it doesn't exist in theme */
:root {
  --accent-bright: #4d9fff;
  /* Brighter version of the default accent color */
}