/* =========================
   KFY Motif Calculator Modal
   Scoped styles
   ========================= */

/* lock scroll when modal open */
body.kfy-modal-open {
  overflow: hidden !important;
}

/* Modal wrapper (fullscreen) */
#kfy-motif-calculator-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100000 !important;
  display: none; /* JS sets display:flex */
  align-items: center !important;
  justify-content: center !important;
  padding: 24px !important;
  box-sizing: border-box !important;
}

/* overlay */
#kfy-motif-calculator-modal .kfy-calculator-overlay {
  position: absolute !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.6) !important;
}

/* content card */
#kfy-motif-calculator-modal .kfy-calculator-content {
  position: relative !important;
  z-index: 1 !important;
  width: min(1100px, calc(100% - 48px)) !important;
  max-height: calc(100vh - 48px) !important;
  overflow: auto !important;
  overflow-x: hidden !important;
  background: #fff !important;
  border-radius: 16px !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4) !important;
}

/* header */
#kfy-motif-calculator-modal .kfy-calculator-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 2 !important;
  padding: 18px 22px !important;
  border-bottom: 2px solid #e2e8f0 !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 12px !important;
  background: #f7fafc !important;
}

#kfy-motif-calculator-modal .kfy-calculator-header h2 {
  margin: 0 !important;
  font-size: 22px !important;
  color: #2d3748 !important;
  font-weight: 800 !important;
  line-height: 1.2 !important;
}

/* close button */
#kfy-motif-calculator-modal .kfy-calculator-close {
  background: #e2e8f0 !important;
  border: none !important;
  font-size: 28px !important;
  color: #4a5568 !important;
  cursor: pointer !important;
  line-height: 1 !important;
  padding: 0 !important;
  width: 40px !important;
  height: 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 999px !important;
  transition: all 0.2s !important;
  flex-shrink: 0 !important;
}

#kfy-motif-calculator-modal .kfy-calculator-close:hover {
  background: #cbd5e0 !important;
  color: #2d3748 !important;
}

/* body grid */
#kfy-motif-calculator-modal .kfy-calculator-body {
  padding: 22px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 24px !important;
}

/* left controls */
#kfy-motif-calculator-modal .kfy-calculator-controls {
  display: flex !important;
  flex-direction: column !important;
  gap: 22px !important;
}

#kfy-motif-calculator-modal .kfy-control-group {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

#kfy-motif-calculator-modal .kfy-control-label {
  font-size: 16px !important;
  font-weight: 700 !important;
  color: #2d3748 !important;
  line-height: 1.35 !important;
  margin: 0 !important;
}

#kfy-motif-calculator-modal .kfy-control-hint {
  font-size: 13px !important;
  color: #718096 !important;
  font-style: italic !important;
  margin: -6px 0 0 0 !important;
}

/* container panels */
#kfy-motif-calculator-modal .kfy-slider-container {
  background: #f7fafc !important;
  padding: 16px !important;
  border-radius: 10px !important;
  border: 1px solid #e2e8f0 !important;
}

#kfy-motif-calculator-modal .kfy-slider-row {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  margin-bottom: 14px !important;
}

#kfy-motif-calculator-modal .kfy-slider-row:last-child {
  margin-bottom: 0 !important;
}

#kfy-motif-calculator-modal .kfy-slider-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 10px !important;
}

#kfy-motif-calculator-modal .kfy-slider-name {
  font-size: 13px !important;
  color: #4a5568 !important;
  font-weight: 700 !important;
}

#kfy-motif-calculator-modal .kfy-slider-value-display {
  font-size: 13px !important;
  color: #2d7a6e !important;
  font-weight: 800 !important;
}

/* base range styling */
#kfy-motif-calculator-modal input[type="range"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 100% !important;
  height: 8px !important;
  border-radius: 999px !important;
  outline: none !important;
  cursor: pointer !important;
  border: none !important;
  background: #2d7a6e !important;
  box-shadow: none !important;
}

/* thumbs */
#kfy-motif-calculator-modal input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 22px !important;
  height: 22px !important;
  border-radius: 50% !important;
  background: #2d7a6e !important;
  cursor: pointer !important;
  border: 3px solid #fff !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}

#kfy-motif-calculator-modal input[type="range"]::-moz-range-thumb {
  width: 22px !important;
  height: 22px !important;
  border-radius: 50% !important;
  background: #2d7a6e !important;
  cursor: pointer !important;
  border: 3px solid #fff !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}

/* =========================
   AREA sliders (pct fill + dots)
   ========================= */
#kfy-motif-calculator-modal .kfy-area-slider-wrap {
  position: relative !important;
  padding-bottom: 18px !important;
}

#kfy-motif-calculator-modal .kfy-area-dots {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  height: 14px !important;
  pointer-events: none !important;
}

#kfy-motif-calculator-modal .kfy-area-dot {
  position: absolute !important;
  top: 50% !important;
  width: 6px !important;
  height: 6px !important;
  transform: translate(-50%, -50%) !important;
  border-radius: 50% !important;
  background: transparent !important;
  opacity: 0 !important;
}

#kfy-motif-calculator-modal .kfy-area-dot.is-active {
  background: #2d7a6e !important;
  opacity: 1 !important;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08) !important;
}

/* area sliders with pct background */
#kfy-area-width-slider,
#kfy-area-height-slider {
  -webkit-appearance: none !important;
  appearance: none !important;
  height: 10px !important;
  border-radius: 999px !important;
  outline: none !important;
  cursor: pointer !important;

  --pct: 50%;
  background: linear-gradient(
    to right,
    #2d7a6e 0%,
    #2d7a6e var(--pct),
    #e5e7eb var(--pct),
    #e5e7eb 100%
  ) !important;

  border: 1px solid #d1d5db !important;
}

/* custom "arrow" thumb for area */
#kfy-area-width-slider::-webkit-slider-thumb,
#kfy-area-height-slider::-webkit-slider-thumb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 34px !important;
  height: 18px !important;
  background: #ffffff !important;
  border: 2px solid #2d7a6e !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18) !important;
  cursor: pointer !important;
  border-radius: 999px !important;
  clip-path: polygon(
    0% 50%,
    10% 0%,
    90% 0%,
    100% 50%,
    90% 100%,
    10% 100%
  ) !important;
}

#kfy-area-width-slider::-moz-range-thumb,
#kfy-area-height-slider::-moz-range-thumb {
  width: 34px !important;
  height: 18px !important;
  background: #ffffff !important;
  border: 2px solid #2d7a6e !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18) !important;
  cursor: pointer !important;
  border-radius: 999px !important;
}

#kfy-area-width-slider::-moz-range-track,
#kfy-area-height-slider::-moz-range-track {
  height: 10px !important;
  border-radius: 999px !important;
  background: transparent !important;
}

/* =========================
   Tension ruler
   ========================= */
#kfy-motif-calculator-modal .kfy-tension-topline {
  display: flex !important;
  align-items: baseline !important;
  gap: 10px !important;
  margin-bottom: 10px !important;
}

#kfy-motif-calculator-modal .kfy-tension-title {
  font-size: 13px !important;
  font-weight: 800 !important;
  color: #2d3748 !important;
}

#kfy-motif-calculator-modal .kfy-tension-values {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #2d3748 !important;
}

#kfy-motif-calculator-modal .kfy-tension-ruler {
  position: relative !important;
  height: 34px !important;
  user-select: none !important;
}

#kfy-motif-calculator-modal .kfy-tension-track {
  position: absolute !important;
  left: 10px !important;
  right: 10px !important;
  top: 50% !important;
  height: 6px !important;
  transform: translateY(-50%) !important;
  border-radius: 999px !important;
  background: #e5e7eb !important;
  border: 1px solid #d1d5db !important;
}

#kfy-motif-calculator-modal .kfy-tension-ticks {
  position: absolute !important;
  left: 10px !important;
  right: 10px !important;
  top: 50% !important;
  height: 6px !important;
  transform: translateY(-50%) !important;
  pointer-events: none !important;
}

#kfy-motif-calculator-modal .kfy-tension-tick {
  position: absolute !important;
  top: 50% !important;
  width: 4px !important;
  height: 4px !important;
  transform: translate(-50%, -50%) !important;
  border-radius: 50% !important;
  background: #cbd5e1 !important;
}

#kfy-motif-calculator-modal .kfy-tension-handle {
  position: absolute !important;
  top: 50% !important;
  width: 18px !important;
  height: 18px !important;
  transform: translate(-50%, -50%) !important;
  border-radius: 3px !important;
  background: #ffffff !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18) !important;
  cursor: ew-resize !important;
}

#kfy-motif-calculator-modal .kfy-handle-sts {
  border: 2px solid #9ca3af !important;
}

#kfy-motif-calculator-modal .kfy-handle-rows {
  border: 2px solid #111827 !important;
}

#kfy-motif-calculator-modal .kfy-tension-help {
  margin-top: 10px !important;
  font-size: 12px !important;
  color: #718096 !important;
  font-style: italic !important;
}

/* =========================
   Right side - preview/result/button
   ========================= */
#kfy-motif-calculator-modal .kfy-preview-panel {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
}

#kfy-motif-calculator-modal .kfy-calculator-preview {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%) !important;
  border-radius: 12px !important;
  padding: 28px !important;
  min-height: 380px !important;
  border: 2px solid #e2e8f0 !important;
}

#kfy-preview-container {
  width: 100% !important;
  max-width: 450px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#kfy-outer-area {
  border: 4px solid #4a5568 !important;
  background: #ffffff !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.3s ease !important;
  position: relative !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
}

#kfy-inner-motif {
  border: 3px dashed #2d7a6e !important;
  background: #e6f4f1 !important;
  border-radius: 6px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.3s ease !important;
  padding: 15px !important;
}

#kfy-inner-motif svg {
  width: 100% !important;
  height: 100% !important;
  opacity: 0.6 !important;
}

/* result box */
#kfy-motif-calculator-modal .kfy-result-section {
  margin-top: 10px !important;
  padding: 26px !important;
  background: linear-gradient(135deg, #2d7a6e 0%, #236156 100%) !important;
  border-radius: 12px !important;
  text-align: center !important;
  box-shadow: 0 4px 15px rgba(45, 122, 110, 0.3) !important;
}

#kfy-motif-calculator-modal .kfy-result-title {
  font-size: 16px !important;
  color: #fff !important;
  margin: 0 0 12px 0 !important;
  font-weight: 700 !important;
  opacity: 0.95 !important;
}

#kfy-motif-calculator-modal .kfy-result-value {
  font-size: 40px !important;
  font-weight: 900 !important;
  color: #fff !important;
  padding: 14px !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border-radius: 8px !important;
  font-family: "Courier New", monospace !important;
  letter-spacing: 2px !important;
}

#kfy-motif-calculator-modal .kfy-result-label {
  margin-top: 10px !important;
  font-size: 13px !important;
  color: #fff !important;
  opacity: 0.85 !important;
}

/* save button */
#kfy-motif-calculator-modal .kfy-save-search-btn {
  width: 100% !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 14px 16px !important;
  font-size: 16px !important;
  font-weight: 800 !important;
  cursor: pointer !important;
  background: #2d7a6e !important;
  color: #fff !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 8px 22px rgba(45, 122, 110, 0.22) !important;
}

#kfy-motif-calculator-modal .kfy-save-search-btn:hover {
  background: #236156 !important;
  transform: translateY(-1px) !important;
}

/* ===== FIX: AREA sliders thumb style (force) ===== */
#kfy-motif-calculator-modal #kfy-area-width-slider,
#kfy-motif-calculator-modal #kfy-area-height-slider {
  -webkit-appearance: none !important;
  appearance: none !important;
  height: 10px !important;
  border-radius: 999px !important;
  outline: none !important;
  cursor: pointer !important;

  --pct: 50%;
  background: linear-gradient(
    to right,
    #2d7a6e 0%,
    #2d7a6e var(--pct),
    #e5e7eb var(--pct),
    #e5e7eb 100%
  ) !important;

  border: 1px solid #d1d5db !important;
}

/* WebKit (Chrome/Edge/Safari) thumb */
#kfy-motif-calculator-modal #kfy-area-width-slider::-webkit-slider-thumb,
#kfy-motif-calculator-modal #kfy-area-height-slider::-webkit-slider-thumb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 34px !important;
  height: 18px !important;
  background: #ffffff !important;
  border: 2px solid #2d7a6e !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18) !important;
  cursor: pointer !important;
  border-radius: 999px !important;
  clip-path: polygon(
    0% 50%,
    10% 0%,
    90% 0%,
    100% 50%,
    90% 100%,
    10% 100%
  ) !important;
}

/* Firefox thumb */
#kfy-motif-calculator-modal #kfy-area-width-slider::-moz-range-thumb,
#kfy-motif-calculator-modal #kfy-area-height-slider::-moz-range-thumb {
  width: 34px !important;
  height: 18px !important;
  background: #ffffff !important;
  border: 2px solid #2d7a6e !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18) !important;
  cursor: pointer !important;
  border-radius: 999px !important;
}

/* Firefox track (avoid gray bar override) */
#kfy-motif-calculator-modal #kfy-area-width-slider::-moz-range-track,
#kfy-motif-calculator-modal #kfy-area-height-slider::-moz-range-track {
  height: 10px !important;
  border-radius: 999px !important;
  background: transparent !important;
}

/* =========================
   Responsive
   ========================= */
@media (max-width: 992px) {
  #kfy-motif-calculator-modal {
    padding: 12px !important;
  }
  #kfy-motif-calculator-modal .kfy-calculator-content {
    width: calc(100% - 24px) !important;
    max-height: calc(100vh - 24px) !important;
  }
  #kfy-motif-calculator-modal .kfy-calculator-header {
    padding: 14px 14px !important;
  }
  #kfy-motif-calculator-modal .kfy-calculator-header h2 {
    font-size: 18px !important;
  }
  #kfy-motif-calculator-modal .kfy-calculator-body {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
    padding: 14px !important;
  }
  #kfy-motif-calculator-modal .kfy-calculator-preview {
    min-height: 260px !important;
  }
}
