/**
 * Visual Editor Styles
 * All styles scoped under .ve class to prevent conflicts with website styles
 */

/* ============================================================================
   CSS Variables
   ============================================================================ */
.ve {
  /* Shadcn-inspired Design Tokens */
  --ve-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ve-font-mono: "SF Mono", Monaco, "Cascadia Code", monospace;

  /* Colors - Shadcn Neutral Scale */
  --ve-background: hsl(0 0% 100%);
  --ve-foreground: hsl(222.2 47.4% 11.2%);
  --ve-muted: hsl(210 40% 96.1%);
  --ve-muted-foreground: hsl(215.4 16.3% 46.9%);
  --ve-border-color: hsl(214.3 31.8% 91.4%);
  --ve-input-border: hsl(214.3 31.8% 91.4%);
  --ve-ring: hsl(222.2 47.4% 11.2%);

  /* Legacy gray scale (for compatibility) */
  --ve-gray-50: hsl(210 40% 98%);
  --ve-gray-100: hsl(210 40% 96.1%);
  --ve-gray-200: hsl(214.3 31.8% 91.4%);
  --ve-gray-300: hsl(212.7 26.8% 83.9%);
  --ve-gray-400: hsl(215 20.2% 65.1%);
  --ve-gray-500: hsl(215.4 16.3% 46.9%);
  --ve-gray-600: hsl(215.3 19.3% 34.5%);
  --ve-gray-700: hsl(215.3 25% 26.7%);
  --ve-gray-800: hsl(217.2 32.6% 17.5%);
  --ve-gray-900: hsl(222.2 47.4% 11.2%);

  /* Colors - Accent (Primary) */
  --ve-accent: hsl(222.2 47.4% 11.2%);
  --ve-accent-hover: hsl(222.2 47.4% 20%);
  --ve-accent-light: hsl(210 40% 96.1%);
  --ve-primary: hsl(222.2 47.4% 11.2%);
  --ve-primary-foreground: hsl(210 40% 98%);

  /* Colors - Status */
  --ve-success: hsl(142.1 76.2% 36.3%);
  --ve-success-light: hsl(142.1 76.2% 94%);
  --ve-danger: hsl(0 84.2% 60.2%);
  --ve-danger-light: hsl(0 84.2% 95%);
  --ve-warning: hsl(38 92% 50%);
  --ve-warning-light: hsl(38 92% 95%);

  /* Spacing */
  --ve-space-1: 4px;
  --ve-space-2: 8px;
  --ve-space-3: 12px;
  --ve-space-4: 16px;
  --ve-space-5: 20px;
  --ve-space-6: 24px;

  /* Borders - Shadcn style */
  --ve-radius-sm: 4px;
  --ve-radius: 6px;
  --ve-radius-lg: 8px;
  --ve-radius-xl: 12px;
  --ve-border: 1px solid var(--ve-border-color);

  /* Shadows - Subtle */
  --ve-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --ve-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --ve-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Focus Ring */
  --ve-ring-offset: 2px;
  --ve-ring-width: 2px;

  /* Panel */
  --ve-panel-width: 380px;
  --ve-z-index: 999999;
}

/* ============================================================================
   Reset & Base
   ============================================================================ */
.ve,
.ve *,
.ve *::before,
.ve *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.ve {
  font-family: var(--ve-font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ve-gray-700);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   Website Layout Adjustments
   ============================================================================ */
body.visual-editor-active .site {
  margin-right: var(--ve-panel-width, 380px) !important;
  transition: margin-right 0.3s ease;
}

body.visual-editor-active .site [style*="position: fixed"],
body.visual-editor-active .site [style*="position:fixed"],
body.visual-editor-active .site .fixed,
body.visual-editor-active .site header[class*="fixed"],
body.visual-editor-active .site nav[class*="fixed"],
body.visual-editor-active .site [class*="fixed-header"],
body.visual-editor-active .site [class*="sticky"] {
  right: var(--ve-panel-width, 380px) !important;
  width: calc(100% - var(--ve-panel-width, 380px)) !important;
  transition: right 0.3s ease, width 0.3s ease;
}

/* ============================================================================
   Panel
   ============================================================================ */
.ve.ve-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--ve-panel-width);
  height: 100vh;
  z-index: var(--ve-z-index);
  background: #fff;
  border-left: var(--ve-border);
  display: flex;
  flex-direction: column;
  animation: ve-slide-in 0.25s ease-out;
}

@keyframes ve-slide-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================================================
   Header
   ============================================================================ */
.ve .ve-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ve-space-4) var(--ve-space-5);
  border-bottom: var(--ve-border);
  flex-shrink: 0;
}

.ve .ve-header-title {
  display: flex;
  align-items: center;
  gap: var(--ve-space-2);
  font-size: 15px;
  font-weight: 600;
  color: var(--ve-gray-900);
}

.ve .ve-header-actions {
  display: flex;
  align-items: center;
  gap: var(--ve-space-2);
}

/* ============================================================================
   Tabs
   ============================================================================ */
.ve .ve-tabs {
  display: flex;
  border-bottom: var(--ve-border);
  flex-shrink: 0;
}

.ve .ve-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ve-space-1);
  padding: var(--ve-space-3) var(--ve-space-2);
  border: none;
  background: none;
  font-family: var(--ve-font);
  font-size: 12px;
  font-weight: 500;
  color: var(--ve-gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.ve .ve-tab:hover {
  color: var(--ve-gray-700);
}

.ve .ve-tab.active {
  color: var(--ve-accent);
  border-bottom-color: var(--ve-accent);
}

.ve .ve-tab .ve-icon {
  width: 14px;
  height: 14px;
}

/* ============================================================================
   Body / Content
   ============================================================================ */
.ve .ve-body {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--ve-space-4);
  min-height: 0;
  max-height: calc(100vh - 120px);
}

.ve .ve-tab-panel {
  display: none;
}

.ve .ve-tab-panel.active {
  display: block;
}

/* ============================================================================
   Hint / Info Text
   ============================================================================ */
.ve .ve-hint {
  font-size: 13px;
  color: var(--ve-gray-500);
  margin-bottom: var(--ve-space-3);
  line-height: 1.6;
}

.ve .ve-hint strong {
  color: var(--ve-gray-700);
  font-weight: 600;
}

.ve .ve-hint code {
  background: var(--ve-gray-100);
  padding: 2px 6px;
  border-radius: var(--ve-radius-sm);
  font-family: var(--ve-font-mono);
  font-size: 11px;
}

/* ============================================================================
   Info Box
   ============================================================================ */
.ve .ve-info-box {
  padding: var(--ve-space-3);
  background: var(--ve-success-light);
  border-radius: var(--ve-radius);
  margin-top: var(--ve-space-3);
}

.ve .ve-info-box-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ve-success);
  margin-bottom: var(--ve-space-1);
}

.ve .ve-info-box-text {
  font-size: 12px;
  color: var(--ve-gray-600);
  line-height: 1.5;
}

/* ============================================================================
   Empty State
   ============================================================================ */
.ve .ve-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--ve-space-6) var(--ve-space-4);
  flex: 1;
  min-height: 100%;
  text-align: center;
}

.ve .ve-empty-state .ve-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--ve-space-4);
  color: var(--ve-gray-300);
  background: var(--ve-gray-50);
  border-radius: 50%;
}

.ve .ve-empty-state .ve-empty-icon svg {
  width: 28px;
  height: 28px;
}

.ve .ve-empty-state .ve-empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ve-gray-700);
  margin: 0 0 var(--ve-space-1) 0;
}

.ve .ve-empty-state .ve-empty-hint {
  font-size: 13px;
  color: var(--ve-gray-400);
  margin: 0;
}

/* ============================================================================
   Inspector
   ============================================================================ */
.ve .ve-inspector {
  display: none;
}

.ve .ve-inspector.active {
  display: block;
}

.ve .ve-inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ve-space-2);
  padding: var(--ve-space-3);
  margin: calc(-1 * var(--ve-space-4));
  margin-bottom: var(--ve-space-4);
  background: var(--ve-muted);
  border-radius: var(--ve-radius-lg);
}

.ve .ve-inspector-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ve-foreground);
}

.ve .ve-element-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.ve .ve-element-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--ve-primary);
  color: var(--ve-primary-foreground);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-radius: var(--ve-radius-sm);
}

.ve .ve-element-id {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--ve-background);
  color: var(--ve-muted-foreground);
  font-size: 11px;
  font-family: var(--ve-font-mono);
  border-radius: var(--ve-radius-sm);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
   Form Controls - Sections
   ============================================================================ */
.ve .ve-section {
  margin-bottom: var(--ve-space-5);
  padding-bottom: var(--ve-space-4);
  border-bottom: var(--ve-border);
}

.ve .ve-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.ve .ve-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--ve-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--ve-space-3);
}

.ve .ve-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ve-gray-700);
  margin-bottom: var(--ve-space-2);
}

/* ============================================================================
   Form Controls - Inputs (Shadcn-inspired)
   ============================================================================ */
.ve .ve-input {
  display: flex;
  height: 36px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--ve-input-border);
  border-radius: var(--ve-radius);
  font-family: var(--ve-font);
  font-size: 14px;
  color: var(--ve-foreground);
  background: transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ve .ve-input:focus {
  outline: none;
  border-color: var(--ve-ring);
  box-shadow: 0 0 0 var(--ve-ring-width) hsl(222.2 47.4% 11.2% / 0.1);
}

.ve .ve-input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ve .ve-input::placeholder {
  color: var(--ve-muted-foreground);
}

.ve .ve-input-sm {
  height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

/* ============================================================================
   Form Controls - Label
   ============================================================================ */
.ve .ve-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ve-foreground);
  margin-bottom: 6px;
}

/* ============================================================================
   Form Controls - Color Picker (Shadcn-inspired)
   ============================================================================ */
.ve .ve-color-control {
  display: flex;
  gap: var(--ve-space-2);
  align-items: center;
}

.ve .ve-color-picker {
  width: 36px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--ve-input-border);
  border-radius: var(--ve-radius);
  cursor: pointer;
  background: transparent;
  transition: border-color 0.2s;
}

.ve .ve-color-picker:hover {
  border-color: var(--ve-gray-400);
}

.ve .ve-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.ve .ve-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

/* ============================================================================
   Form Controls - Slider (Shadcn-inspired)
   ============================================================================ */
.ve .ve-slider-control {
  display: flex;
  align-items: center;
  gap: var(--ve-space-3);
}

.ve .ve-slider {
  flex: 1;
  height: 6px;
  border-radius: 9999px;
  background: var(--ve-muted);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.ve .ve-slider:focus {
  outline: none;
}

.ve .ve-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  background: var(--ve-foreground);
  border: 2px solid var(--ve-background);
  box-shadow: var(--ve-shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.ve .ve-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: var(--ve-shadow);
}

.ve .ve-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--ve-background);
  border-radius: 9999px;
  background: var(--ve-foreground);
  box-shadow: var(--ve-shadow-sm);
  cursor: pointer;
}

.ve .ve-slider-value {
  width: 56px;
  height: 32px;
  text-align: center;
  font-size: 13px;
}

.ve .ve-slider-unit {
  font-size: 13px;
  color: var(--ve-muted-foreground);
  margin-left: -4px;
}

/* ============================================================================
   Form Controls - Alignment Buttons (Shadcn-inspired)
   ============================================================================ */
.ve .ve-align-buttons {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--ve-muted);
  border-radius: var(--ve-radius);
}

.ve .ve-align-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ve-muted-foreground);
  cursor: pointer;
  transition: all 0.15s;
}

.ve .ve-align-btn:hover {
  background: var(--ve-background);
  color: var(--ve-foreground);
}

.ve .ve-align-btn.active {
  background: var(--ve-background);
  color: var(--ve-foreground);
  box-shadow: var(--ve-shadow-sm);
}

.ve .ve-align-btn .ve-icon {
  width: 16px;
  height: 16px;
}

/* ============================================================================
   Form Controls - Spacing Grid (Shadcn-inspired)
   ============================================================================ */
.ve .ve-spacing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ve .ve-spacing-input {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ve .ve-spacing-input label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ve-muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ve .ve-spacing-input input {
  height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--ve-input-border);
  border-radius: var(--ve-radius);
  font-size: 13px;
  text-align: center;
  background: transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ve .ve-spacing-input input:focus {
  outline: none;
  border-color: var(--ve-ring);
  box-shadow: 0 0 0 var(--ve-ring-width) hsl(222.2 47.4% 11.2% / 0.1);
}

.ve .ve-spacing-input input:focus {
  outline: none;
  border-color: var(--ve-accent);
}

/* ============================================================================
   Buttons (Shadcn-inspired)
   ============================================================================ */
.ve .ve-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--ve-radius);
  font-family: var(--ve-font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.ve .ve-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 var(--ve-ring-width) hsl(222.2 47.4% 11.2% / 0.1);
}

.ve .ve-btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.ve .ve-btn .ve-icon {
  width: 16px;
  height: 16px;
}

/* Button Variants - Primary (default dark) */
.ve .ve-btn--primary {
  background: var(--ve-primary);
  color: var(--ve-primary-foreground);
}

.ve .ve-btn--primary:hover:not(:disabled) {
  background: var(--ve-accent-hover);
}

/* Button Variants - Secondary */
.ve .ve-btn--secondary {
  background: var(--ve-muted);
  color: var(--ve-foreground);
}

.ve .ve-btn--secondary:hover:not(:disabled) {
  background: hsl(210 40% 90%);
}

/* Button Variants - Outline */
.ve .ve-btn--outline {
  background: transparent;
  border: 1px solid var(--ve-input-border);
  color: var(--ve-foreground);
}

.ve .ve-btn--outline:hover:not(:disabled) {
  background: var(--ve-muted);
}

/* Button Variants - Ghost */
.ve .ve-btn--ghost {
  background: transparent;
  color: var(--ve-foreground);
}

.ve .ve-btn--ghost:hover:not(:disabled) {
  background: var(--ve-muted);
}

/* Button Variants - Danger */
.ve .ve-btn--danger {
  background: var(--ve-danger);
  color: white;
}

.ve .ve-btn--danger:hover:not(:disabled) {
  background: hsl(0 84.2% 50%);
}

/* Button Variants - Close */
.ve .ve-btn--close {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: var(--ve-muted-foreground);
  border-radius: var(--ve-radius);
}

.ve .ve-btn--close:hover {
  background: var(--ve-muted);
  color: var(--ve-foreground);
}

/* Button Sizes */
.ve .ve-btn--sm {
  height: 32px;
  padding: 6px 12px;
  font-size: 13px;
}

.ve .ve-btn--xs {
  height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

.ve .ve-btn--block {
  width: 100%;
}

/* ============================================================================
   Reset Property Button
   ============================================================================ */
.ve .ve-btn-reset {
  margin-top: 8px;
  padding: 4px 10px;
  height: 24px;
  background: transparent;
  color: var(--ve-danger);
  border: none;
  border-radius: var(--ve-radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.ve .ve-btn-reset:hover {
  background: var(--ve-danger-light);
}

/* ============================================================================
   Accordion Component (Shadcn-inspired)
   ============================================================================ */
.ve .ve-accordion {
  border-bottom: 1px solid var(--ve-border-color);
}

.ve .ve-accordion:first-child {
  border-top: 1px solid var(--ve-border-color);
}

.ve .ve-accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 0;
  background: transparent;
  border: none;
  font-family: var(--ve-font);
  font-size: 14px;
  font-weight: 500;
  color: var(--ve-foreground);
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}

.ve .ve-accordion-trigger:hover {
  color: var(--ve-foreground);
}

.ve .ve-accordion-trigger .ve-icon {
  width: 16px;
  height: 16px;
  color: var(--ve-muted-foreground);
}

/* Only rotate the chevron icon (last icon in trigger or in meta) */
.ve .ve-accordion-trigger > .ve-icon:last-child,
.ve .ve-accordion-meta .ve-icon {
  transition: transform 0.2s ease;
}

.ve .ve-accordion.open .ve-accordion-trigger > .ve-icon:last-child,
.ve .ve-accordion.open .ve-accordion-meta .ve-icon {
  transform: rotate(180deg);
}

.ve .ve-accordion-content {
  display: none;
  padding-bottom: 16px;
}

.ve .ve-accordion.open .ve-accordion-content {
  display: block;
}

.ve .ve-accordion-content .ve-field {
  margin-bottom: 16px;
}

.ve .ve-accordion-content .ve-field:last-child {
  margin-bottom: 0;
}

/* Accordion Label with Icon */
.ve .ve-accordion-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ve .ve-accordion-label .ve-icon {
  width: 16px;
  height: 16px;
  color: var(--ve-muted-foreground);
}

/* Accordion Meta (count badge + chevron) */
.ve .ve-accordion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ve .ve-accordion-meta .ve-icon {
  width: 12px;
  height: 12px;
}

/* Badge */
.ve .ve-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  background: var(--ve-muted);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ve-muted-foreground);
}

/* ============================================================================
   Design Tab Styles
   ============================================================================ */
.ve .ve-design-header {
  margin-bottom: 16px;
}

.ve .ve-design-info {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: var(--ve-muted-foreground);
}

.ve .ve-design-body {
  display: flex;
  flex-direction: column;
}

/* Variable Field */
.ve .var-field {
  margin-bottom: 12px;
}

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

.ve .var-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ve-muted-foreground);
  word-break: break-all;
}

.ve .var-field input[type="text"],
.ve .var-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  font-size: 13px;
  font-family: var(--ve-font);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ve .var-field input[type="text"]:focus,
.ve .var-field textarea:focus {
  outline: none;
  border-color: var(--ve-ring);
  box-shadow: 0 0 0 2px hsl(222.2 47.4% 11.2% / 0.1);
}

.ve .var-field textarea {
  resize: vertical;
  min-height: 60px;
}

/* Color Field Input Wrapper */
.ve .var-input-wrapper {
  display: flex;
  gap: 8px;
}

.ve .var-input-wrapper input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  cursor: pointer;
  background: #fff;
}

.ve .var-input-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.ve .var-input-wrapper input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.ve .var-input-wrapper input[type="text"] {
  flex: 1;
}

/* ============================================================================
   Select Dropdown
   ============================================================================ */
.ve .ve-select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  background: #fff;
  font-size: 13px;
  font-family: var(--ve-font);
  color: var(--ve-foreground);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' 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: 36px;
}

.ve .ve-select:focus {
  outline: none;
  border-color: var(--ve-ring);
  box-shadow: 0 0 0 2px hsl(222.2 47.4% 11.2% / 0.1);
}

.ve .ve-select:hover {
  border-color: var(--ve-gray-300);
}

/* ============================================================================
   Animation Status
   ============================================================================ */
.ve .ve-animation-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: hsl(142 71% 45% / 0.1);
  border: 1px solid hsl(142 71% 45% / 0.3);
  border-radius: var(--ve-radius);
  color: hsl(142 71% 35%);
  font-size: 13px;
  font-weight: 500;
}

.ve .ve-animation-status .ve-icon {
  width: 16px;
  height: 16px;
  color: hsl(142 71% 45%);
}

/* ============================================================================
   Advanced Animation Editor
   ============================================================================ */

/* Animation Mode Tabs */
.ve .ve-anim-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--ve-gray-100);
  border-radius: var(--ve-radius);
}

.ve .ve-anim-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ve-gray-500);
  background: transparent;
  border: none;
  border-radius: calc(var(--ve-radius) - 2px);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ve .ve-anim-tab:hover {
  color: var(--ve-gray-700);
  background: var(--ve-gray-50);
}

.ve .ve-anim-tab.active {
  color: var(--ve-primary);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Animation Panels - visibility managed by inline styles */
.ve .ve-anim-panel {
  /* display: none; - controlled by inline style */
}

/* Preset field styling */
.ve .ve-anim-preset-field {
  margin-bottom: 12px;
}

/* Animation Grid (for from/to state fields) */
.ve .ve-anim-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ve .ve-anim-field {
  display: grid;
  grid-template-columns: 70px 1fr 60px;
  align-items: center;
  gap: 8px;
}

.ve .ve-anim-field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ve-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Range Slider */
.ve .ve-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--ve-gray-200);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.ve .ve-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--ve-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.ve .ve-range::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.ve .ve-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--ve-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* Small Input */
.ve .ve-input--sm {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  text-align: center;
}

/* Field Group */
.ve .ve-field-group {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--ve-gray-50);
  border-radius: var(--ve-radius);
}

.ve .ve-label--section {
  display: block;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ve-gray-600);
}

/* Row Layout */
.ve .ve-row {
  display: flex;
  gap: 12px;
}

.ve .ve-field--half {
  flex: 1;
  min-width: 0;
}

/* Input with suffix */
.ve .ve-input-with-suffix {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ve .ve-input-with-suffix .ve-range {
  flex: 1;
}

.ve .ve-input-with-suffix .ve-input--sm {
  width: 60px;
  flex-shrink: 0;
}

/* Color Input */
.ve .ve-color-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ve .ve-color-input input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  cursor: pointer;
  overflow: hidden;
}

.ve .ve-color-input input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.ve .ve-color-input input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.ve .ve-color-input .ve-input {
  flex: 1;
  font-family: monospace;
  font-size: 12px;
}

/* Scrubber Row (play button + scrubber) */
.ve .ve-scrubber-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ve .ve-scrubber-row .ve-btn--icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ve-primary);
  color: white;
  border: none;
  border-radius: var(--ve-radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ve .ve-scrubber-row .ve-btn--icon:hover {
  background: hsl(222.2 47.4% 20%);
  transform: scale(1.05);
}

.ve .ve-scrubber-row .ve-btn--icon .ve-icon {
  width: 16px;
  height: 16px;
}

/* Scrubber Container */
.ve .ve-scrubber-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, var(--ve-gray-50), var(--ve-gray-100));
  border-radius: var(--ve-radius);
  border: 1px solid var(--ve-gray-200);
  flex: 1;
}

.ve .ve-scrubber {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 8px;
  background: linear-gradient(90deg, var(--ve-primary), hsl(270 76% 60%));
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.ve .ve-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 2px solid var(--ve-primary);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}

.ve .ve-scrubber::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ve .ve-scrubber::-webkit-slider-thumb:active {
  cursor: grabbing;
}

.ve .ve-scrubber::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #fff;
  border: 2px solid var(--ve-primary);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.ve .ve-scrubber-value {
  min-width: 45px;
  padding: 4px 8px;
  background: var(--ve-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border-radius: var(--ve-radius);
}

/* Animation Actions */
.ve .ve-anim-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--ve-gray-200);
}

.ve .ve-anim-actions .ve-btn {
  flex: 1;
}

.ve .ve-anim-actions .ve-btn--danger {
  flex: 0 0 auto;
}

/* Primary Button */
.ve .ve-btn--primary {
  background: var(--ve-primary);
  color: #fff;
  border: 1px solid var(--ve-primary);
}

.ve .ve-btn--primary:hover {
  background: hsl(239 84% 67% / 0.9);
  border-color: hsl(239 84% 67% / 0.9);
}

/* Button with icon */
.ve .ve-btn .ve-icon {
  width: 14px;
  height: 14px;
}

/* ============================================================================
   Font Dropdown
   ============================================================================ */
.ve .ve-font-dropdown {
  position: relative;
  width: 100%;
}

.ve .ve-font-dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ve-space-2) var(--ve-space-3);
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.ve .ve-font-dropdown-trigger:hover {
  border-color: var(--ve-gray-300);
}

.ve .ve-font-dropdown-trigger .ve-icon {
  width: 12px;
  height: 12px;
  color: var(--ve-gray-400);
  transition: transform 0.15s;
}

.ve .ve-font-dropdown.open .ve-font-dropdown-trigger .ve-icon {
  transform: rotate(180deg);
}

.ve .ve-font-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: var(--ve-space-1);
  padding: var(--ve-space-1);
  background: #fff;
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  box-shadow: var(--ve-shadow);
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.ve .ve-font-dropdown.open .ve-font-dropdown-menu {
  display: block;
}

.ve .ve-font-dropdown-option {
  padding: var(--ve-space-2) var(--ve-space-3);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--ve-radius-sm);
  transition: background 0.1s;
}

.ve .ve-font-dropdown-option:hover {
  background: var(--ve-gray-50);
}

.ve .ve-font-dropdown-option.selected {
  background: var(--ve-accent-light);
  color: var(--ve-accent);
  font-weight: 500;
}

/* ============================================================================
   Text Toolbar (Floating)
   ============================================================================ */
.ve-text-toolbar {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid hsl(220 13% 90%);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000000;
  animation: ve-toolbar-appear 0.15s ease-out;
}

@keyframes ve-toolbar-appear {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ve-text-toolbar .ve-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: hsl(220 13% 35%);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.ve-text-toolbar .ve-toolbar-btn:hover {
  background: hsl(220 13% 95%);
  color: hsl(220 13% 20%);
}

.ve-text-toolbar .ve-toolbar-btn.active {
  background: hsl(220 13% 90%);
  color: hsl(220 13% 20%);
}

.ve-text-toolbar .ve-toolbar-btn--save {
  background: hsl(142 71% 45%);
  color: #fff;
  padding: 0 12px;
  width: auto;
  font-size: 12px;
  font-weight: 500;
  margin-left: 4px;
  border-radius: 4px;
}

.ve-text-toolbar .ve-toolbar-btn--save:hover {
  background: hsl(142 71% 38%);
}

/* ============================================================================
   Image Dialog
   ============================================================================ */
.ve-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000001;
}

.ve-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--ve-radius-lg);
  box-shadow: var(--ve-shadow-lg);
  z-index: 1000002;
}

.ve-dialog-header {
  padding: var(--ve-space-4) var(--ve-space-5);
  border-bottom: var(--ve-border);
}

.ve-dialog-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ve-gray-900);
}

.ve-dialog-body {
  padding: var(--ve-space-5);
}

.ve-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--ve-space-2);
  padding: var(--ve-space-4) var(--ve-space-5);
  border-top: var(--ve-border);
}

.ve-image-preview {
  margin-bottom: var(--ve-space-4);
  padding: var(--ve-space-4);
  background: var(--ve-gray-50);
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  text-align: center;
}

.ve-image-preview img {
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
  border-radius: var(--ve-radius-sm);
}

.ve-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ve-space-2);
  padding: var(--ve-space-3) var(--ve-space-4);
  background: var(--ve-accent);
  color: #fff;
  border-radius: var(--ve-radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.ve-upload-btn:hover {
  background: var(--ve-accent-hover);
}

.ve-upload-divider {
  margin: var(--ve-space-3) 0;
  text-align: center;
  color: var(--ve-gray-400);
  font-size: 12px;
}

/* ============================================================================
   Layout Panel - Section Items
   ============================================================================ */
.ve .ve-section-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ve-space-3);
  background: var(--ve-gray-50);
  border-radius: var(--ve-radius);
  margin-bottom: var(--ve-space-2);
}

.ve .ve-section-item:last-child {
  margin-bottom: 0;
}

.ve .ve-section-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ve-gray-700);
}

/* ============================================================================
   Overlays (Hover & Selection)
   ============================================================================ */
.ve-hover-overlay {
  position: absolute;
  border: 2px dashed var(--ve-accent, #6366f1);
  background: rgba(99, 102, 241, 0.06);
  pointer-events: none;
  z-index: 999998;
  transition: all 0.12s ease-out;
  border-radius: var(--ve-radius-sm, 4px);
  opacity: 0;
}

.ve-active-overlay {
  position: absolute;
  border: 2px solid var(--ve-accent, #6366f1);
  background: rgba(99, 102, 241, 0.1);
  pointer-events: none;
  z-index: 999997;
  transition: all 0.12s ease-out;
  border-radius: var(--ve-radius-sm, 4px);
  opacity: 0;
}

/* ============================================================================
   Section Select Mode (Alt+Click)
   ============================================================================ */
body.section-select-mode section,
body.section-select-mode div[class*="section"],
body.section-select-mode div[id*="section"] {
  outline: 2px dashed var(--ve-warning, #f59e0b) !important;
  outline-offset: 4px !important;
  cursor: pointer !important;
}

body.section-select-mode section:hover,
body.section-select-mode div[class*="section"]:hover,
body.section-select-mode div[id*="section"]:hover {
  outline-style: solid !important;
  background-color: rgba(245, 158, 11, 0.04) !important;
}

/* ============================================================================
   Active Editing States
   ============================================================================ */
.ve-element-hover {
  outline: 2px dashed var(--ve-accent, #6366f1) !important;
  outline-offset: 2px !important;
  cursor: pointer !important;
}

.ve-element-active {
  outline: 2px solid var(--ve-accent, #6366f1) !important;
  outline-offset: 2px !important;
}

/* ============================================================================
   Design System Panel
   ============================================================================ */
.ve .ve-ds-header {
  margin-bottom: var(--ve-space-4);
}

.ve .ve-ds-search {
  width: 100%;
  padding: var(--ve-space-2) var(--ve-space-3);
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  font-size: 13px;
}

.ve .ve-ds-search:focus {
  outline: none;
  border-color: var(--ve-accent);
}

.ve .ve-ds-category {
  margin-bottom: var(--ve-space-2);
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  overflow: hidden;
}

.ve .ve-ds-category-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--ve-space-2);
  padding: var(--ve-space-3) var(--ve-space-4);
  background: var(--ve-gray-50);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.ve .ve-ds-category-header:hover {
  background: var(--ve-gray-100);
}

.ve .ve-ds-category-icon {
  font-size: 14px;
}

.ve .ve-ds-category-title {
  flex: 1;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ve-gray-700);
}

.ve .ve-ds-category-count {
  padding: 2px 8px;
  background: var(--ve-gray-200);
  color: var(--ve-gray-600);
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
}

.ve .ve-ds-category-arrow {
  font-size: 10px;
  color: var(--ve-gray-400);
  transition: transform 0.2s;
}

.ve .ve-ds-category-header.expanded .ve-ds-category-arrow {
  transform: rotate(180deg);
}

.ve .ve-ds-category-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  background: #fff;
}

.ve .ve-ds-category-content.expanded {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--ve-space-3) var(--ve-space-4);
}

.ve .ve-ds-field {
  margin-bottom: var(--ve-space-3);
}

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

.ve .ve-ds-field-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--ve-gray-600);
  margin-bottom: var(--ve-space-1);
}

.ve .ve-ds-field-input {
  display: flex;
  gap: var(--ve-space-2);
}

/* ============================================================================
   Icons
   ============================================================================ */
.ve .ve-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.ve .ve-icon svg {
  width: 100%;
  height: 100%;
}

/* ============================================================================
   Design System Panel (uses generated classes)
   ============================================================================ */
.ve .design-system-header {
  margin-bottom: var(--ve-space-4);
}

.ve .design-system-info {
  font-size: 12px;
  color: var(--ve-gray-500);
  margin: 0 0 var(--ve-space-3) 0;
}

.ve .variable-search {
  width: 100%;
  padding: var(--ve-space-2) var(--ve-space-3);
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  font-size: 13px;
  transition: border-color 0.15s;
}

.ve .variable-search:focus {
  outline: none;
  border-color: var(--ve-accent);
}

.ve .design-system-body {
  max-height: calc(100vh - 400px);
  overflow-y: auto;
}

.ve .category-section {
  margin-bottom: var(--ve-space-2);
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  overflow: hidden;
}

.ve .category-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--ve-space-2);
  padding: var(--ve-space-3) var(--ve-space-4);
  background: var(--ve-gray-50);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.ve .category-header:hover {
  background: var(--ve-gray-100);
}

.ve .category-icon {
  font-size: 14px;
}

.ve .category-title {
  flex: 1;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--ve-gray-700);
}

.ve .category-count {
  padding: 2px 8px;
  background: var(--ve-gray-200);
  color: var(--ve-gray-600);
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
}

.ve .category-arrow {
  font-size: 10px;
  color: var(--ve-gray-400);
  transition: transform 0.2s;
}

.ve .category-header.expanded .category-arrow {
  transform: rotate(180deg);
}

.ve .category-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  background: #fff;
}

.ve .category-content.expanded {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--ve-space-3) var(--ve-space-4);
}

.ve .var-field {
  margin-bottom: var(--ve-space-3);
}

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

.ve .var-field label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--ve-gray-600);
  margin-bottom: var(--ve-space-1);
}

.ve .var-input-wrapper {
  display: flex;
  gap: var(--ve-space-2);
}

.ve .var-input-wrapper input[type="color"] {
  width: 40px;
  height: 32px;
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  cursor: pointer;
  padding: 2px;
}

.ve .var-input-wrapper input[type="text"] {
  flex: 1;
}

.ve .var-field input[type="text"],
.ve .var-field textarea {
  width: 100%;
  padding: 6px 10px;
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  font-size: 12px;
  font-family: var(--ve-font-mono);
  transition: border-color 0.15s;
}

.ve .var-field input[type="text"]:focus,
.ve .var-field textarea:focus {
  outline: none;
  border-color: var(--ve-accent);
}

.ve .var-field textarea {
  resize: vertical;
  min-height: 50px;
}

/* Inspector Toggle Button */
.ve .inspector-toggle-btn {
  width: 100%;
  padding: var(--ve-space-2) var(--ve-space-3);
  margin-bottom: var(--ve-space-3);
  border: var(--ve-border);
  border-radius: var(--ve-radius);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--ve-space-2);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}

.ve .inspector-toggle-btn:hover {
  border-color: var(--ve-accent);
  background: var(--ve-gray-50);
}

.ve .inspector-toggle-btn.active {
  background: var(--ve-accent);
  color: #fff;
  border-color: var(--ve-accent);
}

.ve .toggle-icon {
  font-size: 14px;
}

/* ============================================================================
   Scrollbar
   ============================================================================ */
.ve ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.ve ::-webkit-scrollbar-track {
  background: transparent;
}

.ve ::-webkit-scrollbar-thumb {
  background: var(--ve-gray-300);
  border-radius: 3px;
}

.ve ::-webkit-scrollbar-thumb:hover {
  background: var(--ve-gray-400);
}
