/* ============================================================
 * Rooted Revival — Theme Editor CSS
 *
 * Self-contained dark-themed popup.
 * Does NOT depend on any page theme variables.
 * ============================================================ */

/* ---- Overlay ---- */
.rr-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rr-ed-fade-in 0.15s ease;
}
@keyframes rr-ed-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Panel ---- */
.rr-editor-panel {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background: #141416;
  color: #e4e4e7;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}
@supports (width: 100dvw) {
  .rr-editor-panel {
    width: 100dvw;
    height: 100dvh;
  }
}

/* ---- Header ---- */
.rr-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  min-height: 52px;
  border-bottom: 1px solid #27272a;
  background: #18181b;
}
.rr-editor-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: #fafafa;
  letter-spacing: -0.01em;
}
.rr-editor-close {
  background: none;
  border: none;
  color: #71717a;
  font-size: 22px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.rr-editor-close:hover {
  color: #fafafa;
  background: #27272a;
}

/* ---- Body (two columns) ---- */
.rr-editor-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ---- Left panel — controls ---- */
.rr-editor-left {
  width: 440px;
  min-width: 380px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #27272a;
  background: #1a1a1e;
  overflow: hidden;
}

.rr-editor-toolbar {
  display: flex;
  gap: 8px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #27272a;
  flex-shrink: 0;
}
.rr-toolbar-name {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid #3f3f46;
  border-radius: 7px;
  background: #18181b;
  color: #fafafa;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.rr-toolbar-name::placeholder { color: #52525b; }
.rr-toolbar-name:focus { border-color: #6b7280; }

.rr-toolbar-load {
  width: 180px;
  padding: 7px 10px;
  border: 1px solid #3f3f46;
  border-radius: 7px;
  background: #18181b;
  color: #e4e4e7;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.rr-toolbar-load option { background: #18181b; color: #e4e4e7; }

/* ---- Fields ---- */
.rr-editor-fields {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 18px;
  scroll-behavior: smooth;
}

/* Scrollbar */
.rr-editor-fields::-webkit-scrollbar { width: 6px; }
.rr-editor-fields::-webkit-scrollbar-track { background: transparent; }
.rr-editor-fields::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 3px; }

.rr-edit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  padding: 6px 8px;
  margin-top: 2px;
  border-radius: 8px;
  transition: background 0.12s;
}
.rr-edit-row:hover {
  background: rgba(255,255,255,0.03);
}
.rr-edit-row--active {
  background: rgba(255,255,255,0.06);
}

/* ---- Swatch ---- */
.rr-swatch {
  position: relative;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 2px solid #3f3f46;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  margin-right: 10px;
  flex-shrink: 0;
  transition: border-color 0.15s, transform 0.12s;
  overflow: hidden;
}
.rr-swatch:hover {
  border-color: #71717a;
  transform: scale(1.08);
}
.rr-swatch:active {
  transform: scale(0.95);
}
.rr-native-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ---- Label ---- */
.rr-edit-label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
.rr-edit-label span:first-child {
  font-size: 13px;
  font-weight: 500;
  color: #d4d4d8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rr-edit-var {
  font-size: 10.5px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  color: #52525b;
  margin-top: 1px;
}
.rr-edit-label--color {
  cursor: pointer;
}

/* ---- Text input ---- */
.rr-edit-text {
  width: 130px;
  min-width: 100px;
  padding: 5px 8px;
  border: 1px solid #3f3f46;
  border-radius: 5px;
  background: #18181b;
  color: #e4e4e7;
  font-size: 12px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  outline: none;
  transition: border-color 0.15s;
}
.rr-edit-text:focus {
  border-color: #6b7280;
}

/* ---- HSL sliders ---- */
.rr-hsl {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  margin-left: 38px;
  padding: 8px 10px 8px 12px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  border: 1px solid #27272a;
}
.rr-hsl-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rr-hsl-label {
  font-size: 10px;
  font-weight: 700;
  color: #71717a;
  width: 12px;
  text-align: center;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
}
.rr-hsl-range {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 5px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.rr-hsl-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
}
.rr-hsl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fafafa;
  border: 2px solid #52525b;
  cursor: pointer;
  margin-top: -4.5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.rr-hsl-range::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  border: none;
}
.rr-hsl-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fafafa;
  border: 2px solid #52525b;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Hue: rainbow track */
.rr-hsl-range--hue::-webkit-slider-runnable-track {
  background: linear-gradient(to right,
    #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%,
    #00f 67%, #f0f 83%, #f00 100%);
}
.rr-hsl-range--hue::-moz-range-track {
  background: linear-gradient(to right,
    #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%,
    #00f 67%, #f0f 83%, #f00 100%);
}

/* Saturation: gray → current color */
.rr-hsl-range--sat { background: #3f3f46; border-radius: 3px; }

/* Lightness: gradient from black → color → white */
.rr-hsl-range--lum { background: #3f3f46; border-radius: 3px; }

.rr-hsl-val {
  font-size: 10.5px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  color: #a1a1aa;
  width: 38px;
  text-align: right;
}

/* ---- Right panel — preview ---- */
.rr-editor-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 32px;
  background: #0e0e10;
}
.rr-editor-right::-webkit-scrollbar { width: 6px; }
.rr-editor-right::-webkit-scrollbar-track { background: transparent; }
.rr-editor-right::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 3px; }

.rr-preview-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #52525b;
  margin-bottom: 16px;
}

.rr-preview-wrap {
  flex: 1;
  background: var(--rr-pv-bg);
  color: var(--rr-pv-text);
  font-family: var(--rr-pv-font-sans);
  border-radius: 12px;
  padding: 28px;
  transition: background 0.15s, color 0.15s;
  min-height: 0;
  overflow-y: auto;
}

/* ---- Preview: header bar ---- */
.rr-pv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  margin: -28px -28px 24px;
  background: var(--rr-pv-surface);
  border-bottom: 1px solid var(--rr-pv-border);
  border-radius: 12px 12px 0 0;
}
.rr-pv-logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--rr-pv-text);
}
.rr-pv-nav {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--rr-pv-muted);
}

/* ---- Preview: card ---- */
.rr-pv-card {
  background: var(--rr-pv-surface);
  border: 1px solid var(--rr-pv-border);
  border-radius: var(--rr-pv-radius);
  padding: 24px;
  margin-bottom: 16px;
  transition: background 0.15s, border-color 0.15s, border-radius 0.15s;
}
.rr-pv-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--rr-pv-text);
  margin-bottom: 6px;
}
.rr-pv-muted {
  font-size: 14px;
  color: var(--rr-pv-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ---- Preview: buttons ---- */
.rr-pv-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.rr-pv-btn-primary {
  padding: 8px 20px;
  background: var(--rr-pv-accent);
  color: #fff;
  border: none;
  border-radius: var(--rr-pv-radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-radius 0.15s;
}
.rr-pv-btn-secondary {
  padding: 8px 20px;
  background: transparent;
  color: var(--rr-pv-text);
  border: 1px solid var(--rr-pv-border);
  border-radius: var(--rr-pv-radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, border-radius 0.15s, color 0.15s;
}

/* ---- Preview: badges ---- */
.rr-pv-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.rr-pv-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--rr-pv-radius);
  font-size: 11px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-radius 0.15s;
}
.rr-pv-badge--warn {
  background: var(--rr-pv-amber-dim);
  color: var(--rr-pv-amber);
}
.rr-pv-badge--err {
  background: var(--rr-pv-red-dim);
  color: var(--rr-pv-red);
}
.rr-pv-badge--ok {
  background: var(--rr-pv-sage-dim);
  color: var(--rr-pv-sage);
}

/* ---- Preview: monospace ---- */
.rr-pv-mono {
  font-family: var(--rr-pv-font-mono);
  font-size: 13px;
  color: var(--rr-pv-muted);
  padding: 10px 14px;
  background: rgba(0,0,0,0.08);
  border-radius: var(--rr-pv-radius);
  transition: font-family 0.15s, border-radius 0.15s;
}

/* ---- Preview: elevated ---- */
.rr-pv-elevated {
  background: var(--rr-pv-elevated);
  border: 1px solid var(--rr-pv-border);
  border-radius: var(--rr-pv-radius);
  padding: 20px;
  transition: background 0.15s, border-color 0.15s, border-radius 0.15s;
}
.rr-pv-el-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--rr-pv-text);
  margin-bottom: 4px;
}
.rr-pv-el-text {
  font-size: 13px;
  color: var(--rr-pv-muted);
  line-height: 1.5;
}

/* ---- Footer ---- */
.rr-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  min-height: 52px;
  border-top: 1px solid #27272a;
  background: #18181b;
  gap: 12px;
}
.rr-footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rr-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.rr-editor-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #a1a1aa;
  cursor: pointer;
  user-select: none;
}
.rr-editor-check input {
  margin: 0;
  accent-color: #71717a;
}

/* ---- Buttons ---- */
.rr-btn-save,
.rr-btn-default,
.rr-btn-cancel {
  padding: 7px 18px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.rr-btn-save:disabled,
.rr-btn-default:disabled,
.rr-btn-cancel:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rr-btn-save {
  background: #7a3e1d;
  color: #fff;
}
.rr-btn-save:hover:not(:disabled) { background: #8e4a24; }

.rr-btn-default {
  background: #1e4620;
  color: #fff;
  font-size: 12px;
}
.rr-btn-default:hover:not(:disabled) { background: #245626; }

.rr-btn-cancel {
  background: #27272a;
  color: #d4d4d8;
  border: 1px solid #3f3f46;
}
.rr-btn-cancel:hover { background: #3f3f46; }

/* ---- Flash message ---- */
.rr-flash-msg {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 5px;
  animation: rr-flash-in 0.2s ease;
}
@keyframes rr-flash-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rr-flash-msg--ok  { color: #86efac; background: rgba(34,197,94,0.12); }
.rr-flash-msg--err { color: #fca5a5; background: rgba(239,68,68,0.12); }

/* ---- Responsive ---- */
@media (max-width: 850px) {
  .rr-editor-body {
    flex-direction: column;
  }
  .rr-editor-left {
    width: 100%;
    min-width: 0;
    max-height: 55%;
    border-right: none;
    border-bottom: 1px solid #27272a;
  }
  .rr-editor-right {
    padding: 16px 18px;
  }
  .rr-preview-wrap {
    padding: 20px;
  }
  .rr-pv-header {
    margin: -20px -20px 16px;
    padding: 10px 14px;
  }
  .rr-edit-text {
    width: 90px;
    min-width: 80px;
    font-size: 11px;
  }
}

@media (max-width: 500px) {
  .rr-editor-toolbar {
    flex-direction: column;
  }
  .rr-toolbar-load {
    width: 100%;
  }
  .rr-editor-left {
    max-height: 50%;
  }
  .rr-edit-row {
    flex-wrap: wrap;
  }
  .rr-edit-text {
    width: 100%;
    margin-top: 4px;
  }
  .rr-hsl {
    margin-left: 0;
  }
}
