.snake-bar-graph {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 200px;
  padding: 20px;
  padding-bottom: 60px; /* Extra padding for labels */
  background: transparent;
  border: 1px solid var(--color-border);
  font-family: var(--font-family);
  color: var(--color-text-primary);
  box-sizing: border-box;
}

/* Horizontal variant needs more width for labels and scale */
.snake-bar-graph--horizontal {
  padding-left: 100px; /* Extra space for Y-axis labels */
  padding-right: 40px; /* Balance the layout */
  min-width: 600px; /* Ensure minimum width for readability */
  width: 100%;
}

/* Corner accents */
.snake-bar-graph__corner {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--color-text-muted);
}

.snake-bar-graph__corner--top-left {
  top: -1px;
  left: -1px;
  border-right: none;
  border-bottom: none;
}

.snake-bar-graph__corner--top-right {
  top: -1px;
  right: -1px;
  border-left: none;
  border-bottom: none;
}

.snake-bar-graph__corner--bottom-left {
  bottom: -1px;
  left: -1px;
  border-right: none;
  border-top: none;
}

.snake-bar-graph__corner--bottom-right {
  bottom: -1px;
  right: -1px;
  border-left: none;
  border-top: none;
}

/* Content wrapper */
.snake-bar-graph__content {
  position: relative;
  display: flex;
}

.snake-bar-graph--horizontal .snake-bar-graph__content {
  margin-left: 0; /* No extra margin needed, padding is on container */
  width: 100%;
  min-width: 400px; /* Minimum width for the bars area */
}

/* Grid */
.snake-bar-graph__grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.snake-bar-graph--vertical .snake-bar-graph__grid {
  bottom: 40px; /* Space for labels */
}

.snake-bar-graph__grid-line {
  position: absolute;
  border-style: solid;
  opacity: 0.3;
}

/* Vertical orientation grid */
.snake-bar-graph--vertical .snake-bar-graph__grid-line {
  left: 0;
  right: 0;
  border-width: 1px 0 0 0;
}

/* Horizontal orientation grid */
.snake-bar-graph--horizontal .snake-bar-graph__grid-line {
  top: 0;
  bottom: 0;
  border-width: 0 0 0 1px;
}

/* Scale */
.snake-bar-graph__scale {
  position: absolute;
  font-size: 11px;
  font-family: var(--font-family-mono);
  color: var(--color-text-muted);
}

/* Vertical scale (Y-axis) */
.snake-bar-graph--vertical .snake-bar-graph__scale {
  position: absolute;
  left: -45px;
  top: 0;
  bottom: 40px; /* Account for label space */
  width: 40px;
  text-align: right;
}

.snake-bar-graph--vertical .snake-bar-graph__scale-value {
  position: absolute;
  transform: translateY(50%);
}

/* Horizontal scale (X-axis) */
.snake-bar-graph--horizontal .snake-bar-graph__scale {
  position: absolute;
  bottom: -30px;
  left: 0;
  right: 0;
  height: 25px;
}

.snake-bar-graph--horizontal .snake-bar-graph__scale-value {
  position: absolute;
  transform: translateX(-50%);
}

/* Bars container */
.snake-bar-graph__bars {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
}

/* Vertical bars */
.snake-bar-graph--vertical .snake-bar-graph__bars {
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-evenly;
}

/* Horizontal bars */
.snake-bar-graph--horizontal .snake-bar-graph__bars {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
}

/* Bar container */
.snake-bar-graph__bar-container {
  position: relative;
  display: flex;
  flex-direction: column;
}

.snake-bar-graph--vertical .snake-bar-graph__bar-container {
  height: 100%;
  justify-content: flex-end;
  align-items: center;
  flex: 1;
  max-width: 80px;
}

.snake-bar-graph--horizontal .snake-bar-graph__bar-container {
  width: 100%;
  flex-direction: row;
  align-items: center;
}

/* Bar */
.snake-bar-graph__bar {
  position: relative;
  transition: all var(--transition-base);
  border: 1px solid;
  border-color: inherit;
  background-clip: padding-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.snake-bar-graph--vertical .snake-bar-graph__bar {
  width: 100%;
  min-height: 2px;
}

.snake-bar-graph--horizontal .snake-bar-graph__bar {
  height: 100%;
  min-width: 2px;
}

.snake-bar-graph__bar:hover {
  filter: brightness(1.2);
  transform: scale(1.02);
}

/* Animated bars */
.snake-bar-graph--animated .snake-bar-graph__bar {
  animation: snake-bar-graph-grow 0.5s ease-out forwards;
  animation-fill-mode: both;
}

.snake-bar-graph--animated.snake-bar-graph--vertical .snake-bar-graph__bar {
  transform-origin: bottom;
}

.snake-bar-graph--animated.snake-bar-graph--horizontal .snake-bar-graph__bar {
  transform-origin: left;
}

@keyframes snake-bar-graph-grow {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

.snake-bar-graph--horizontal .snake-bar-graph--animated .snake-bar-graph__bar {
  animation-name: snake-bar-graph-grow-horizontal;
}

@keyframes snake-bar-graph-grow-horizontal {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Value */
.snake-bar-graph__value {
  position: absolute;
  font-size: 11px;
  font-family: var(--font-family-mono);
  color: var(--color-text-primary);
  white-space: nowrap;
  text-shadow: 0 0 4px var(--color-bg-base);
  font-weight: 600;
}

.snake-bar-graph--vertical .snake-bar-graph__value {
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
}

.snake-bar-graph--horizontal .snake-bar-graph__value {
  right: -5px;
  top: 50%;
  transform: translate(100%, -50%);
}

/* Labels */
.snake-bar-graph__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.snake-bar-graph--vertical .snake-bar-graph__label {
  position: absolute;
  bottom: -45px; /* More space for labels */
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
}

.snake-bar-graph--horizontal .snake-bar-graph__label {
  position: absolute;
  left: -90px;
  width: 85px;
  text-align: right;
  align-items: flex-end;
}

.snake-bar-graph__label-text {
  font-weight: 500;
}

.snake-bar-graph__sublabel {
  font-size: 10px;
  color: var(--color-text-muted);
  font-family: var(--font-family-mono);
}

/* Variants */

/* Minimal variant */
.snake-bar-graph--minimal {
  background: transparent;
  border: none;
  padding: 10px;
}

.snake-bar-graph--minimal .snake-bar-graph__corner {
  display: none;
}

.snake-bar-graph--minimal .snake-bar-graph__bar {
  border: none;
}

/* Detailed variant */
.snake-bar-graph--detailed {
  padding: 30px;
  background: rgba(31, 29, 32, 0.3);
}

.snake-bar-graph--detailed .snake-bar-graph__bar {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border-width: 2px;
}

.snake-bar-graph--detailed .snake-bar-graph__value {
  font-size: 13px;
  font-weight: bold;
}

/* Interactive variant */
.snake-bar-graph--interactive .snake-bar-graph__bar-container {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.snake-bar-graph--interactive .snake-bar-graph__bar {
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.snake-bar-graph--interactive .snake-bar-graph__bar:hover,
.snake-bar-graph--interactive .snake-bar-graph__bar--hovered {
  filter: brightness(1.2);
  transform: scale(1.02);
  outline: 2px solid #ffffff;
  outline-offset: -2px;
  z-index: 10;
}

.snake-bar-graph--interactive .snake-bar-graph__bar--selected {
  filter: brightness(1.4);
  outline: 2px solid #ffffff;
  outline-offset: -2px;
  transform: scale(1.05);
  z-index: 11;
}

/* Tooltip */
.snake-bar-graph__tooltip {
  pointer-events: none;
  z-index: 1000;
  animation: tooltipExpand var(--transition-base) ease-out;
}

@keyframes tooltipExpand {
  from {
    opacity: 0;
    transform: translate(-50%, -100%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1);
  }
}

.snake-bar-graph__tooltip-content {
  background: #000000;
  padding: 12px 18px;
  font-family: var(--font-family-mono);
  font-size: 12px;
  white-space: nowrap;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

.snake-bar-graph__tooltip-label {
  color: var(--color-text-primary);
  font-weight: 600;
  margin-bottom: 4px;
  position: relative;
}

.snake-bar-graph__tooltip-value {
  color: var(--color-success);
  font-size: 14px;
  font-weight: bold;
}

.snake-bar-graph__tooltip-sublabel {
  color: var(--color-text-muted);
  font-size: 10px;
  margin-top: 4px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .snake-bar-graph--vertical .snake-bar-graph__label {
    font-size: 10px;
  }

  .snake-bar-graph--horizontal .snake-bar-graph__label {
    min-width: 60px;
    font-size: 10px;
  }

  .snake-bar-graph__value {
    font-size: 10px;
  }
}
