.snake-colorpicker {
  position: relative;
  display: inline-block;
  font-family: var(--font-family);
}

.snake-colorpicker--inline {
  display: block;
}

.snake-colorpicker--disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Trigger */
.snake-colorpicker__trigger {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 8px 12px;
  background-color: #1f1d20;
  border: 1px solid #3a3a3a;
  color: var(--color-text-primary);
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.snake-colorpicker--small .snake-colorpicker__trigger {
  padding: 6px 10px;
  font-size: var(--font-size-sm);
}

.snake-colorpicker--large .snake-colorpicker__trigger {
  padding: 10px 16px;
  font-size: var(--font-size-base);
}

.snake-colorpicker__trigger:hover:not(:disabled) {
  border-color: #4a4a4a;
  background-color: #252325;
}

.snake-colorpicker__trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.snake-colorpicker__trigger-color {
  width: 24px;
  height: 24px;
  border: 1px solid #3a3a3a;
  position: relative;
  overflow: hidden;
}

.snake-colorpicker--small .snake-colorpicker__trigger-color {
  width: 20px;
  height: 20px;
}

.snake-colorpicker--large .snake-colorpicker__trigger-color {
  width: 28px;
  height: 28px;
}

.snake-colorpicker__trigger-value {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  color: #bdbdbd;
  text-transform: uppercase;
}

.snake-colorpicker__trigger-arrow {
  margin-left: auto;
  font-size: 10px;
  color: #8e8e90;
  transition: transform var(--transition-fast);
}

/* Panel */
.snake-colorpicker__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1000;
  background-color: #1f1d20;
  border: 1px solid #3a3a3a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  padding: var(--spacing-md);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition:
    opacity var(--transition-fast),
    transform var(--transition-fast);
}

.snake-colorpicker--inline .snake-colorpicker__panel {
  position: static;
  box-shadow: none;
  opacity: 1;
  transform: none;
  pointer-events: all;
}

.snake-colorpicker__panel--open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Size variants for panel */
.snake-colorpicker--small .snake-colorpicker__panel {
  padding: var(--spacing-sm);
}

.snake-colorpicker--medium .snake-colorpicker__panel {
  width: 280px;
}

.snake-colorpicker--large .snake-colorpicker__panel {
  width: 320px;
  padding: var(--spacing-lg);
}

/* Saturation picker */
.snake-colorpicker__saturation {
  position: relative;
  width: 100%;
  height: 150px;
  margin-bottom: var(--spacing-md);
  cursor: crosshair;
  overflow: hidden;
}

.snake-colorpicker--small .snake-colorpicker__saturation {
  height: 120px;
}

.snake-colorpicker--large .snake-colorpicker__saturation {
  height: 180px;
}

.snake-colorpicker__saturation-white {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to right, #fff, transparent);
}

.snake-colorpicker__saturation-black {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent, #000);
}

.snake-colorpicker__saturation-pointer {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  box-shadow:
    0 0 0 1px #000,
    0 2px 4px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Controls */
.snake-colorpicker__controls {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.snake-colorpicker__slider {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.snake-colorpicker__slider label {
  font-size: var(--font-size-sm);
  color: #8e8e90;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Slider styling */
.snake-colorpicker__hue-slider,
.snake-colorpicker__alpha-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  background: linear-gradient(
    to right,
    #ff0000 0%,
    #ffff00 17%,
    #00ff00 33%,
    #00ffff 50%,
    #0000ff 67%,
    #ff00ff 83%,
    #ff0000 100%
  );
  outline: none;
  cursor: pointer;
}

.snake-colorpicker__alpha-slider {
  background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 100%);
}

.snake-colorpicker__hue-slider::-webkit-slider-thumb,
.snake-colorpicker__alpha-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid #000;
  cursor: pointer;
}

.snake-colorpicker__hue-slider::-moz-range-thumb,
.snake-colorpicker__alpha-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid #000;
  cursor: pointer;
}

/* Hex input */
.snake-colorpicker__input-wrapper {
  margin-bottom: var(--spacing-md);
}

.snake-colorpicker__hex-input {
  width: 100%;
  padding: 8px 12px;
  background-color: #0b0b0d;
  border: 1px solid #3a3a3a;
  color: var(--color-text-primary);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-base);
  text-transform: uppercase;
  transition: all var(--transition-fast);
}

.snake-colorpicker__hex-input:focus {
  outline: none;
  border-color: #4a4a4a;
  background-color: #141416;
}

.snake-colorpicker__hex-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Presets */
.snake-colorpicker__presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 6px;
}

.snake-colorpicker__preset {
  width: 28px;
  height: 28px;
  border: 1px solid #3a3a3a;
  padding: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.snake-colorpicker__preset:hover:not(:disabled) {
  border-color: #4a4a4a;
  transform: scale(1.1);
}

.snake-colorpicker__preset:active:not(:disabled) {
  transform: scale(0.95);
}

.snake-colorpicker__preset:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Corner decorations */
.snake-colorpicker__corner {
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid #3a3a3a;
  pointer-events: none;
}

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

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

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

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

/* Focus styles */
.snake-colorpicker__trigger:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--color-bg-base),
    0 0 0 4px rgba(189, 189, 189, 0.3);
}
