/* ─────────────────────────────────────────────────────────────────────────────
   theme-editor.css — Estilos para o Editor Visual do VipControl
───────────────────────────────────────────────────────────────────────────── */

/* ── LAYOUT PRINCIPAL ── */
#page-theme-editor {
  display: none;
  padding: 0;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  background: var(--liquid-bg);
}

#page-theme-editor.active {
  display: flex;
}

.te-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--liquid-surface-strong);
  border-bottom: 1px solid var(--liquid-border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  z-index: 10;
}

.te-toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.te-toolbar-title {
  margin: 0;
  font-size: 1.25rem;
  color: var(--liquid-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.te-unsaved-badge {
  font-size: 0.75rem;
  color: var(--liquid-warning);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,174,87,0.1);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,174,87,0.2);
  animation: te-pulse 2s infinite;
}

@keyframes te-pulse {
  0% { opacity: 0.8; }
  50% { opacity: 1; box-shadow: 0 0 8px rgba(255,174,87,0.4); }
  100% { opacity: 0.8; }
}

.te-toolbar-actions {
  display: flex;
  gap: 10px;
}

.te-btn-history {
  width: 36px;
  padding: 8px;
  justify-content: center;
  color: var(--liquid-muted);
  border-color: var(--liquid-border);
  background: var(--vc-layer-subtle);
}
.te-btn-history:hover:not(:disabled) { color: var(--liquid-blue); border-color: var(--liquid-blue); }
.te-btn-history:disabled { opacity: .35; cursor: not-allowed; }

.te-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--vc-ink-inverse);
}

.te-btn i { font-size: 1rem; }

.te-btn-save { background: var(--liquid-success); }
.te-btn-save:hover { background: #2bb67c; box-shadow: 0 4px 12px rgba(53,197,138,0.3); }

.te-btn-reset { background: var(--vc-layer-alpha-050); border-color: var(--liquid-border); }
.te-btn-reset:hover { background: var(--vc-layer-alpha-100); }

.te-btn-export { background: var(--liquid-blue); }
.te-btn-export:hover { background: var(--liquid-blue-strong); }

.te-btn-import { background: var(--liquid-purple); }
.te-btn-import:hover { filter: brightness(1.1); }

.te-btn-inspect { background: transparent; border: 1px dashed var(--liquid-cyan); color: var(--liquid-cyan); }
.te-btn-inspect:hover, .te-btn-inspect.active { background: rgba(82,200,255,0.1); }

/* ── CORPO DO EDITOR ── */
.te-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.te-sidebar {
  width: 260px;
  background: var(--liquid-surface);
  border-right: 1px solid var(--liquid-border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  overflow-y: auto;
}

.te-cat-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--liquid-muted);
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.te-cat-btn:hover {
  background: var(--vc-layer-alpha-030);
  color: var(--liquid-text);
}

.te-cat-btn.active {
  background: var(--liquid-blue-soft);
  color: var(--liquid-blue);
  border-left-color: var(--liquid-blue);
  font-weight: 600;
}

.te-controls {
  flex: 1;
  padding: 32px 48px;
  overflow-y: auto;
  background: var(--bg-2);
}

.te-controls-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}

.te-controls-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.te-control-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  color: var(--liquid-muted);
  border: 1px solid var(--liquid-border);
  border-radius: 8px;
  background: var(--vc-layer-subtle);
}
.te-control-search input { width: 180px; color: var(--liquid-text); border: 0; outline: 0; background: transparent; }
.te-control-search input::placeholder { color: var(--liquid-muted); }

.te-live-preview { margin-bottom: 24px; }
.te-preview-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--liquid-muted); font-size: .78rem; }
.te-viewport-switch { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--liquid-border); border-radius: 8px; background: var(--liquid-surface); }
.te-viewport-switch button { display: grid; place-items: center; width: 32px; height: 28px; color: var(--liquid-muted); border: 0; border-radius: 6px; background: transparent; cursor: pointer; }
.te-viewport-switch button.active { color: var(--liquid-blue); background: var(--liquid-blue-soft); }
.te-preview-canvas { width: 100%; max-width: 100%; margin-inline: auto; padding: 14px; border: 1px dashed var(--liquid-border-strong); border-radius: 10px; background: var(--vc-surface-page); transition: width .2s ease; }
.te-live-preview[data-viewport="tablet"] .te-preview-canvas { width: min(720px, 100%); }
.te-live-preview[data-viewport="mobile"] .te-preview-canvas { width: min(390px, 100%); }
.te-preview-content { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--vc-grid-gap); }
.te-live-preview[data-viewport="mobile"] .te-preview-content { grid-template-columns: minmax(0, 1fr); }
.te-live-preview .vc-field { display: grid; gap: 6px; }
.te-live-preview .vc-action-row { flex-wrap: nowrap; }

.te-source-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin-top: 8px;
  color: var(--liquid-cyan);
  font-size: .75rem;
  font-weight: 650;
  text-decoration: none;
}
.te-source-link:hover { color: var(--liquid-blue); text-decoration: underline; }
.te-source-link[hidden] { display: none; }

.te-controls-header h3 {
  margin: 0 0 8px 0;
  font-size: 1.5rem;
  color: var(--liquid-text);
}

.te-controls-desc {
  color: var(--liquid-muted);
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.te-section-reset {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--liquid-border);
  border-radius: 8px;
  background: var(--vc-layer-subtle);
  color: var(--liquid-muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.te-section-reset:hover,
.te-section-reset:focus-visible {
  border-color: var(--liquid-blue);
  color: var(--liquid-blue);
  background: var(--liquid-blue-soft);
}

.te-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

/* ── CONTROLES ESPECÍFICOS ── */
.te-control {
  background: var(--liquid-surface);
  border: 1px solid var(--liquid-border);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.2s;
}
.te-control:hover { border-color: var(--liquid-border-strong); }

.te-label {
  display: block;
  font-size: 0.85rem;
  color: var(--liquid-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

/* Color Control */
.te-color-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.te-color-picker {
  -webkit-appearance: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  background: transparent;
}
.te-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.te-color-picker::-webkit-color-swatch { border: 1px solid var(--vc-layer-alpha-200); border-radius: 8px; }
.te-color-text {
  flex: 1;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--vc-layer-alpha-100);
  color: var(--vc-ink-inverse);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.9rem;
}

.te-color-text[aria-invalid="true"] {
  border-color: var(--liquid-danger);
  box-shadow: 0 0 0 2px rgba(255, 84, 112, 0.14);
}

.te-color-reset {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  border: 1px solid var(--liquid-border);
  border-radius: 8px;
  background: var(--vc-layer-subtle);
  color: var(--liquid-muted);
  cursor: pointer;
}

.te-color-reset:hover,
.te-color-reset:focus-visible {
  color: var(--liquid-blue);
  border-color: var(--liquid-blue);
}

/* Slider Control */
.te-slider-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.te-slider {
  flex: 1;
  accent-color: var(--liquid-blue);
}
.te-slider-value {
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--liquid-text);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Toggle Control */
.te-toggle-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.te-toggle-control .te-label { margin-bottom: 0; }
.te-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.te-toggle input { opacity: 0; width: 0; height: 0; }
.te-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--vc-layer-alpha-100);
  transition: .4s;
  border-radius: 24px;
}
.te-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
.te-toggle input:checked + .te-toggle-slider { background-color: var(--liquid-success); }
.te-toggle input:checked + .te-toggle-slider:before { transform: translateX(20px); }

/* Select Control */
.te-select {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--vc-layer-alpha-100);
  color: var(--vc-ink-inverse);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}
.te-select option { background: var(--bg-2); }

/* Shadow Control */
.te-shadow-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.te-shadow-option {
  padding: 6px 12px;
  background: var(--vc-layer-alpha-050);
  border: 1px solid var(--vc-layer-alpha-100);
  border-radius: 6px;
  color: var(--liquid-muted);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.te-shadow-option:hover { background: var(--vc-layer-alpha-100); }
.te-shadow-option.active { background: var(--liquid-blue-soft); border-color: var(--liquid-blue); color: var(--liquid-blue); }

/* ── PRESETS ── */
.te-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.te-preset-card {
  background: var(--liquid-surface);
  border: 1px solid var(--liquid-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.te-preset-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  border-color: var(--liquid-blue);
}
.te-preset-colors {
  display: flex;
  height: 60px;
}
.te-preset-swatch { flex: 1; }
.te-preset-info {
  padding: 16px;
}
.te-preset-info strong { display: block; color: var(--liquid-text); margin-bottom: 4px; }
.te-preset-info small { color: var(--liquid-muted); font-size: 0.8rem; }

/* ── INSPECT MODE ── */
.vip-inspect-mode :not(.te-inspect-panel, .te-inspect-panel *) { cursor: crosshair !important; }
.te-inspect-hover { outline: 2px dashed var(--liquid-blue) !important; outline-offset: 2px; }
.te-inspect-selected { outline: 3px solid var(--liquid-blue) !important; outline-offset: 2px; box-shadow: 0 0 16px rgba(47,125,244,0.4) !important; }

.te-inspect-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(390px, 100vw);
  background: var(--liquid-surface-strong);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--liquid-border);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px var(--vc-shade-overlay);
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.te-inspect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--liquid-border);
}
.te-inspect-header h3 { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.te-inspect-close { background: transparent; border: none; color: var(--liquid-muted); cursor: pointer; font-size: 1.2rem; }
.te-inspect-close:hover { color: var(--liquid-danger); }

.te-inspect-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.te-inspect-element {
  background: rgba(0,0,0,0.3);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-family: monospace;
  font-size: 0.9rem;
}
.te-inspect-tag { color: var(--liquid-pink); }
.te-inspect-classes { color: var(--liquid-cyan); }

.te-inspect-row {
  margin-bottom: 16px;
}
.te-inspect-row > label {
  display: block;
  font-size: 0.8rem;
  color: var(--liquid-muted);
  margin-bottom: 6px;
}

.te-inspect-note {
  margin: -8px 0 16px;
  color: var(--liquid-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.te-inspect-token-grid {
  display: grid;
  gap: 10px;
}

.te-inspect-token-grid .te-control {
  min-width: 0;
}

.te-inspect-owner {
  display: block;
  margin-bottom: 4px;
  color: var(--liquid-cyan);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
}

.te-inspect-actions {
  position: sticky;
  bottom: -20px;
  display: flex;
  gap: 8px;
  margin: 18px -20px -20px;
  padding: 14px 20px;
  border-top: 1px solid var(--liquid-border);
  background: var(--liquid-surface-strong);
}

.te-inspect-actions .te-btn-save { flex: 1; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .te-body { flex-direction: column; }
  .te-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--liquid-border); flex-direction: row; overflow-x: auto; padding: 0; }
  .te-cat-btn { border-left: none; border-bottom: 3px solid transparent; width: auto; white-space: nowrap; }
  .te-cat-btn.active { border-left-color: transparent; border-bottom-color: var(--liquid-blue); }
  .te-controls { padding: 20px; }
  .te-controls-header { align-items: stretch; flex-direction: column; }
  .te-controls-tools { justify-content: flex-start; }
  .te-control-search { flex: 1; }
  .te-control-search input { width: 100%; }
  .te-section-reset { align-self: flex-start; }
  .te-controls-grid { grid-template-columns: minmax(0, 1fr); }
  .te-toolbar-actions span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .te-unsaved-badge { animation: none; }
}
