/* ==========================================================================
   Inline Visual Color Picker & Image Color Picker Styles
   Desktop & Touch-friendly Mobile Support
   ========================================================================== */

.visual-picker-layout {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

.picker-split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 20px;
}

.inline-color-picker {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px;
  background: #ffffff;
  border-radius: var(--radius-md, 12px);
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.picker-split-row .inline-color-picker {
  margin: 0;
  max-width: 100%;
  height: 100%;
}

.picker-title {
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
  color: #1e293b;
}

.picker-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.picker-hex-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

#hexValue {
  width: 120px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  font-size: 15px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s ease;
  text-transform: uppercase;
}

#hexValue:focus {
  border-color: #2563eb;
}

.color-preview {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: background-color 0.1s ease;
  flex-shrink: 0;
}

.picker-main {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  touch-action: none; /* Allows smooth touch dragging without page scroll interference */
  width: 100%;
}

.sv-picker {
  flex: 1 1 220px;
  width: 100%;
  min-width: 0;
  height: 220px;
  min-height: 220px;
  position: relative;
  cursor: crosshair;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.3);
  touch-action: none;
  background: linear-gradient(to top, #000000, transparent), linear-gradient(to right, #ffffff, hsl(352, 100%, 50%));
  display: block;
}

.hue-picker {
  width: 28px;
  height: 220px;
  position: relative;
  cursor: pointer;
  border-radius: 14px;
  background: linear-gradient(
    to bottom,
    #ff0000 0%,
    #ffff00 17%,
    #00ff00 33%,
    #00ffff 50%,
    #0000ff 67%,
    #ff00ff 83%,
    #ff0000 100%
  );
  box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.3);
  touch-action: none;
}

.sv-cursor {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.hue-cursor {
  position: absolute;
  width: 32px;
  height: 8px;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* ==========================================================================
   Image Color Picker Card & Canvas
   ========================================================================== */

.image-color-picker {
  width: 100%;
  height: 100%;
  padding: 20px;
  background: #ffffff;
  border-radius: var(--radius-md, 12px);
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  position: relative;
}

.image-picker-stage {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
  flex: 1;
}

.image-stage-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

#pickerSampleImage {
  width: 100%;
  height: 100%;
  max-height: 220px;
  object-fit: contain;
  display: block;
  cursor: crosshair;
  user-select: none;
  -webkit-user-drag: none;
}

/* Floating Magnifier Loupe */
.image-loupe {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  transition: opacity 0.08s ease;
}

.loupe-glass {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32), inset 0 0 2px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
  background: #0f172a;
}

#loupeCanvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  display: block;
}

.loupe-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.loupe-tag {
  margin-top: 6px;
  padding: 3px 8px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(4px);
  color: #ffffff;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  text-transform: uppercase;
  white-space: nowrap;
}

.loupe-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #ffffff;
  display: inline-block;
}

/* Pick Pin Marker */
.image-pick-marker {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 25;
}

.marker-dot {
  width: 8px;
  height: 8px;
  background: #ffffff;
  border: 2px solid #0f172a;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.marker-ring {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 20px;
  height: 20px;
  border: 2px solid #ef4444;
  border-radius: 50%;
  animation: markerPulse 1.8s infinite;
}

@keyframes markerPulse {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* Drag and Drop Overlay */
.image-drag-overlay {
  position: absolute;
  inset: 0;
  background: rgba(239, 246, 255, 0.94);
  border: 2px dashed #2563eb;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
  pointer-events: none;
}

.image-drag-overlay.active {
  display: flex;
}

.drag-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #1d4ed8;
  font-weight: 700;
  font-size: 14px;
}

.image-picker-footer-tip {
  margin-top: 14px;
  font-size: 12px;
  color: #64748b;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-picker-footer-tip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Bottom Upload Section
   ========================================================================== */

.picker-upload-section {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 18px 20px;
  text-align: center;
  margin: 0 0 20px 0;
  transition: all 0.2s ease;
}

.picker-upload-section.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.upload-headline {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

.upload-btn-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-upload-image {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f84251;
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  padding: 12px 28px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(248, 66, 81, 0.25);
  transition: all 0.2s ease;
}

.btn-upload-image:hover {
  background: #d92d3c;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(248, 66, 81, 0.35);
}

.btn-upload-image:active {
  transform: translateY(0);
}

.btn-reset-image {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
  font-weight: 600;
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset-image:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.uploaded-file-info {
  margin-top: 10px;
  font-size: 12px;
  color: #059669;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 900px) {
  .picker-split-row {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

@media (max-width: 600px) {
  .picker-split-row .inline-color-picker,
  .picker-split-row .image-color-picker {
    height: auto;
    min-height: auto;
  }
  .inline-color-picker,
  .image-color-picker {
    padding: 14px;
  }
  .picker-main {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    width: 100% !important;
    align-items: stretch !important;
  }
  .sv-picker {
    display: block !important;
    width: 100% !important;
    height: 210px !important;
    min-height: 210px !important;
    flex: 0 0 210px !important;
    max-width: 100% !important;
    position: relative !important;
    visibility: visible !important;
  }
  .image-picker-stage {
    height: 200px;
  }
  #pickerSampleImage {
    max-height: 200px;
  }
  .hue-picker {
    display: block !important;
    width: 100% !important;
    height: 28px !important;
    min-height: 28px !important;
    flex: 0 0 28px !important;
    border-radius: 14px !important;
    background: linear-gradient(
      to right,
      #ff0000 0%,
      #ffff00 17%,
      #00ff00 33%,
      #00ffff 50%,
      #0000ff 67%,
      #ff00ff 83%,
      #ff0000 100%
    ) !important;
  }
  .hue-cursor {
    width: 10px;
    height: 32px;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}
