/**
 * Settings Panel Styles
 * Right-side drawer on desktop, bottom sheet on mobile
 */

/* Overlay */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.settings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Panel — desktop: right drawer */
.settings-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10001;
  width: 380px;
  height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  background: rgba(28, 28, 32, 0.85);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  transform: translateX(calc(100% + 24px));
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  color: rgba(255, 255, 255, 0.9);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

.settings-panel.open {
  transform: translateX(0);
}

/* Keep cursor visible when settings open */
body.cursor-hidden .settings-panel,
body.cursor-hidden .settings-overlay {
  cursor: auto;
}

/* Ensure pointer shows on settings panel even when cursor hidden */
.settings-panel * {
  cursor: auto;
}

/* Header */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.settings-header-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.settings-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
}

.settings-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: scale(1.05);
}

.settings-close:active {
  transform: scale(0.95);
}

.settings-close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
}

/* Scrollable body */
.settings-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  scrollbar-width: none;
}

.settings-body::-webkit-scrollbar {
  display: none;
}

/* Section */
.settings-section {
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 14px;
  padding-left: 4px;
}

/* Text input */
.settings-text-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.settings-text-input:focus {
  border-color: rgba(0, 230, 118, 0.4);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 0 4px rgba(0, 230, 118, 0.1);
}

/* Theme chip grid */
.settings-theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.settings-theme-chip {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-theme-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  transform: translateY(-1px);
}

.settings-theme-chip.active {
  background: #00e676;
  border-color: #00e676;
  color: #000;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 230, 118, 0.3);
}

/* Field row */
.settings-field {
  margin-bottom: 18px;
}

.settings-field:last-child {
  margin-bottom: 0;
}

.settings-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.settings-field-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #00e676;
  background: rgba(0, 230, 118, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Color input wrapper */
.settings-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-color-input {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.settings-color-input:hover {
  transform: scale(1.05);
}

.settings-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.settings-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

.settings-color-hex {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.settings-color-hex:focus {
  border-color: rgba(0, 230, 118, 0.4);
  background: rgba(0, 0, 0, 0.3);
}

/* Range slider */
.settings-range {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease, background 0.2s ease;
}

.settings-range::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  background: #00e676;
}

.settings-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Select dropdown */
.settings-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.settings-select:focus {
  border-color: rgba(0, 230, 118, 0.4);
  background-color: rgba(0, 0, 0, 0.3);
}

.settings-select option {
  background: #1e1e22;
  color: #fff;
}

/* Toggle switch */
.settings-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.settings-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.settings-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-toggle input:checked + .settings-toggle-track {
  background: #00e676;
}

.settings-toggle input:checked + .settings-toggle-track::after {
  transform: translateX(20px);
}

/* Text field for string params */
.settings-string-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.settings-string-input:focus {
  border-color: rgba(0, 230, 118, 0.4);
  background: rgba(0, 0, 0, 0.3);
}

/* Font custom input spacing */
.settings-font-custom {
  margin-top: 8px;
}

/* ===== Mobile: bottom sheet ===== */
@media (max-width: 640px) {
  .settings-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 85vh;
    border-left: none;
    border-radius: 32px 32px 0 0;
    transform: translateY(100%);
  }

  .settings-panel.open {
    transform: translateY(0);
  }

  /* Bottom sheet drag handle */
  .settings-header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.15);
  }

  .settings-header {
    position: relative;
    padding-top: 28px;
    padding-bottom: 16px;
  }

  .settings-body {
    padding: 20px;
    padding-bottom: 40px;
  }

  .settings-section {
    padding: 14px;
  }
}

/* ===== Landing page builder ===== */
.landing-builder {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              padding 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              margin-top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s ease;
}

.landing-builder.builder-open {
  max-height: 600px;
  opacity: 1;
  overflow: visible;
  padding: 12px 16px;
  margin-top: 16px;
  border-color: rgba(255, 255, 255, 0.06);
}

.builder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.builder-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
  white-space: nowrap;
}

.builder-select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
}

.builder-select-narrow {
  flex: 0 0 auto;
  width: 90px;
}

.builder-select option {
  background: #1e1e22;
  color: #fff;
}

.builder-color-input {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
}

.builder-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.builder-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.builder-color-input::-moz-color-swatch {
  border: none;
  border-radius: 4px;
}

.builder-range {
  flex: 1;
  min-width: 60px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.builder-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00e676;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.3);
}

.builder-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00e676;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.3);
}

.builder-range-short {
  max-width: 80px;
}

.builder-range-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  min-width: 24px;
  text-align: right;
  flex-shrink: 0;
}

/* Builder toggle switch (compact) */
.builder-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.builder-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.builder-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: background 0.2s ease;
}

.builder-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.builder-toggle input:checked + .builder-toggle-track {
  background: #00e676;
}

.builder-toggle input:checked + .builder-toggle-track::after {
  transform: translateX(16px);
}

/* Builder string input */
.builder-string-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}

.builder-string-input:focus {
  border-color: rgba(0, 230, 118, 0.4);
}

/* Theme params separator */
#builder-theme-params:not(:empty) {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.builder-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.builder-url-preview {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}

.builder-copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: all 0.2s ease;
}

.builder-copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.builder-copy-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.builder-copy-btn.copied {
  color: #00e676;
  border-color: rgba(0, 230, 118, 0.3);
}

@media (max-width: 600px) {
  .landing-builder.builder-open {
    padding: 10px 12px;
  }

  .builder-row {
    gap: 6px;
  }

  .builder-select-narrow {
    width: 76px;
  }
}
