/* ═══════════════════════════════════════════════════════════════════════════
   STYLE EDITOR — Full-page Modal
   Dev tool for editing design tokens
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
   OVERLAY CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */

.style-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease, visibility 300ms ease;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
}

.style-editor-overlay[data-open="true"] {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

body.se-open {
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BACKDROP
   ═══════════════════════════════════════════════════════════════════════════ */

.se-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════════════ */

.se-modal {
  position: relative;
  width: 100%;
  max-width: 900px;
  max-height: calc(100vh - 48px);
  background: rgba(18, 18, 22, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
  transform: scale(0.95) translateY(10px);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.style-editor-overlay[data-open="true"] .se-modal {
  transform: scale(1) translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════════ */

.se-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.3);
}

.se-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.se-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.se-status {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
}

.se-status--modified {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.se-status--success {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.se-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.se-refresh-group {
  display: flex;
  gap: 8px;
}

.se-refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  cursor: pointer;
  transition: all 150ms ease;
}

.se-refresh-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.95);
}

.se-refresh-btn--app {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.1);
}

.se-refresh-btn--app:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
}

.se-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 150ms ease;
}

.se-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.95);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BODY LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

.se-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */

.se-sidebar {
  width: 200px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.se-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 24px;
}

.se-tab {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 150ms ease;
}

.se-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
}

.se-tab.is-active {
  background: rgba(139, 92, 246, 0.2);
  color: rgba(255, 255, 255, 0.95);
}

.se-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.se-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 150ms ease;
}

.se-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
}

.se-action-btn--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════════════════ */

.se-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.se-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTROLS
   ═══════════════════════════════════════════════════════════════════════════ */

.se-control {
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.se-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 12px;
}

.se-value {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 4px;
}

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

.se-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8B5CF6, #6366F1);
  border: 2px solid rgba(255, 255, 255, 0.9);
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.se-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.se-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.se-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8B5CF6, #6366F1);
  border: 2px solid rgba(255, 255, 255, 0.9);
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Generic button styling (kept for potential future use) */
.se-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  cursor: pointer;
  transition: all 150ms ease;
}

.se-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.95);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════════════════ */

.se-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.3);
}

.se-footer-info {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.se-footer-info kbd {
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, monospace;
  font-size: 10px;
}

.se-save-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.2);
  color: rgba(255, 255, 255, 0.95);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
}

.se-save-btn:hover {
  background: rgba(139, 92, 246, 0.35);
  border-color: rgba(139, 92, 246, 0.6);
}

.se-save-btn:active {
  transform: scale(0.97);
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 700px) {
  .se-modal {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .se-body {
    flex-direction: column;
  }

  .se-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px;
  }

  .se-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
  }

  .se-sidebar-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
  }

  .se-refresh-group {
    flex-wrap: wrap;
  }

  .se-content {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .style-editor-overlay,
  .se-modal,
  .se-slider::-webkit-slider-thumb {
    transition: none !important;
  }
}

.se-empty {
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LINKED BADGE SYSTEM
   ═══════════════════════════════════════════════════════════════════════════ */

.se-label-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.se-linked-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: rgba(167, 139, 250, 0.9);
  font-size: 10px;
  cursor: pointer;
  transition: all 150ms ease;
}

.se-linked-badge svg {
  opacity: 0.8;
}

.se-linked-badge:hover {
  background: rgba(139, 92, 246, 0.25);
  border-color: rgba(139, 92, 246, 0.5);
}

.se-linked-count {
  font-weight: 600;
}

/* Linked tooltip dropdown */
.se-linked-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  max-width: 280px;
  padding: 10px;
  background: rgba(24, 24, 28, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 150ms ease;
}

.se-linked-badge:hover .se-linked-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.se-linked-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(255, 255, 255, 0.12);
}

.se-linked-tooltip::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid rgba(24, 24, 28, 0.98);
}

.se-tooltip-header {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.se-tooltip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  margin: 2px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 100ms ease;
}

.se-tooltip-item:hover {
  background: rgba(139, 92, 246, 0.15);
}

.se-tooltip-item code {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.se-tooltip-type {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.35);
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LINKED ELEMENT HIGHLIGHT
   ═══════════════════════════════════════════════════════════════════════════ */

.se-linked-highlight {
  outline: 2px solid rgba(139, 92, 246, 0.8) !important;
  outline-offset: 3px;
  animation: se-pulse-highlight 1s ease-in-out infinite;
}

@keyframes se-pulse-highlight {
  0%, 100% {
    outline-color: rgba(139, 92, 246, 0.8);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0);
  }
  50% {
    outline-color: rgba(139, 92, 246, 1);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
  }
}
