/* Styles for the widget editor workspace: layout, control panel, sliders, color pickers, and preview frame. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2937;
}

.editor {
  display: flex;
  flex-direction: row;
  height: 100vh;
}

.editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.tab-strip {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
  flex-shrink: 0;

  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.tab-strip:hover {
  scrollbar-color: #cbd5e1 transparent;
}

.tab-strip::-webkit-scrollbar {
  height: 6px;
}

.tab-strip::-webkit-scrollbar-track {
  background: transparent;
}

.tab-strip::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}

.tab-strip:hover::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

.tab-strip::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 12px;
  font-family: inherit;
  font-size: 0.8125rem;
  color: #4b5563;
  background: #e5e7eb;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: default;
  white-space: nowrap;
  max-width: 200px;
}

.tab.dragging {
  opacity: 0.5;
}

.tab:hover {
  background: #d1d5db;
}

.tab.active {
  background: #ffffff;
  color: #111827;
  box-shadow: 0 -2px 0 inset #3b82f6;
}

.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  color: #6b7280;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s;
}

.tab:hover .tab-close,
.tab.active .tab-close {
  opacity: 1;
}

.tab-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #111827;
}

.widget-tab {
  display: contents;
}

.editor-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 0.9375rem;
  font-style: italic;
  user-select: none;
}

.editor-area {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
}

.widget-editor {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-width: 0;
  min-height: 0;
}

.widget-picker {
  width: 64px;
  flex-shrink: 0;
  background: #f3f4f6;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  gap: 0.375rem;
}

.widget-picker-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.widget-picker-item:hover:not(.is-soon):not(.active) {
  background: #e5e7eb;
  color: #1f2937;
}

.widget-picker-item.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.widget-picker-item.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: #3b82f6;
  border-radius: 0 2px 2px 0;
}

.widget-picker-item.is-soon {
  opacity: 0.55;
  cursor: not-allowed;
  color: #9ca3af;
}

.widget-picker-soon {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 4px;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: #d1d5db;
  border-radius: 999px;
  line-height: 1.4;
  text-transform: uppercase;
}

.widget-picker-item svg {
  display: block;
}

.preview-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  background-color: #fafafa;
  background-image:
    linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
    linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, 10px 0;
  padding: 2rem;
  overflow: auto;
}

.preview-stage--custom-bg {
  background-color: var(--stage-bg);
  background-image: none;
}

.stage-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.stage-color-picker {
  display: inline-flex;
  cursor: pointer;
}

.stage-color-picker input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 24px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.stage-reset:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.widget {
  font-family: inherit;
  background: var(--t-bg-default);
  color: var(--t-color-default);
  border-color: var(--t-border-color-default);
  box-shadow: 0 var(--t-shadow-y-default) var(--t-shadow-blur-default) var(--t-shadow-color);
}

.widget-shell {
  position: relative;
  display: inline-flex;
}

.widget-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0;
  pointer-events: none;
  box-shadow:
    inset var(--t-padding-x, 0px) 0 0 0 var(--t-padding-highlight, transparent),
    inset calc(-1 * var(--t-padding-x, 0px)) 0 0 0 var(--t-padding-highlight, transparent),
    inset 0 var(--t-padding-y, 0px) 0 0 var(--t-padding-highlight, transparent),
    inset 0 calc(-1 * var(--t-padding-y, 0px)) 0 0 var(--t-padding-highlight, transparent);
}

.widget--button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transform: translateY(0) scale(1);
}

.widget--text-input {
  display: inline-block;
  outline: none;
}

.widget--text-input::placeholder {
  color: var(--t-placeholder-color);
}

.card-sample {
  width: 60px;
  height: 60px;
  background: var(--t-sample-bg);
  color: var(--t-sample-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.widget--transitions-enabled {
  transition: var(--t-transition);
}

.widget--hover-enabled:hover {
  background: var(--t-bg-hover);
  color: var(--t-color-hover);
  border-color: var(--t-border-color-hover);
  transform: translateY(var(--t-ty-hover, 0)) scale(var(--t-scale-hover, 1));
  box-shadow: 0 var(--t-shadow-y-hover) var(--t-shadow-blur-hover) var(--t-shadow-color);
  cursor: var(--t-cursor-hover);
}

.widget--press-enabled:active {
  background: var(--t-bg-active);
  color: var(--t-color-active);
  border-color: var(--t-border-color-active);
  transform: translateY(var(--t-ty-active, 0)) scale(var(--t-scale-active, 1));
  box-shadow: 0 var(--t-shadow-y-active) var(--t-shadow-blur-active) var(--t-shadow-color);
}

.widget--focus-enabled:focus {
  background: var(--t-bg-focus);
  color: var(--t-color-focus);
  border-color: var(--t-border-color-focus);
  border-style: var(--t-border-style-focus);
  outline: var(--t-ring-width) solid var(--t-ring-color);
  outline-offset: 0;
  box-shadow: 0 var(--t-shadow-y-focus) var(--t-shadow-blur-focus) var(--t-shadow-color);
}

.control-panel {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background-color: #ffffff;
  border-left: 1px solid #e5e7eb;
  min-height: 0;
}

.tab-pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;

  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.tab-pane:hover {
  scrollbar-color: #cbd5e1 transparent;
}

.tab-pane::-webkit-scrollbar {
  width: 8px;
}

.tab-pane::-webkit-scrollbar-track {
  background: transparent;
}

.tab-pane::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 4px;
}

.tab-pane:hover::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

.tab-pane::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.panel-title {
  margin: 0 0 0.5rem 0;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.75rem;
}

.panel-title-display {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.panel-title-text {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
}

.panel-title-input {
  width: 100%;
  margin: 0;
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  padding: 0.25rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background-color: #ffffff;
}

.panel-title-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.icon-button {
  background: transparent;
  border: none;
  padding: 0.25rem;
  border-radius: 4px;
  cursor: pointer;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s;
}

.icon-button:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.icon-button svg {
  display: block;
}

.panel-title-action {
  margin-left: auto;
}

.export-code-button {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1f2937;
  background: #e5e7eb;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.export-code-button:hover {
  background: #3b82f6;
  color: #ffffff;
}

.export-dialog {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  width: min(560px, 90vw);
  max-width: none;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  background: #ffffff;
  box-shadow: -4px 0 24px rgba(15, 23, 42, 0.15);

  transform: translateX(100%);
  opacity: 0;
  transition:
    transform 250ms ease,
    opacity 250ms ease,
    display 250ms allow-discrete,
    overlay 250ms allow-discrete;
}

.export-dialog[open] {
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  opacity: 1;
}

@starting-style {
  .export-dialog[open] {
    transform: translateX(100%);
    opacity: 0;
  }
}

.export-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  transition:
    opacity 250ms ease,
    display 250ms allow-discrete,
    overlay 250ms allow-discrete;
}

.export-dialog[open]::backdrop {
  opacity: 1;
}

@starting-style {
  .export-dialog[open]::backdrop {
    opacity: 0;
  }
}

.export-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
}

.export-dialog-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

.export-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 1.25rem;
}

.export-tab-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  gap: 0.75rem;
}

.export-code {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 0.875rem 1rem;
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
  border-radius: 6px;
  white-space: pre;
}

.copy-button {
  align-self: flex-end;
  padding: 0.5rem 0.875rem;
  min-width: 5.5rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #ffffff;
  background-color: #3b82f6;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.4s ease;
}

.copy-button:hover {
  background-color: #2563eb;
}

.copy-button--copied,
.copy-button--copied:hover {
  background-color: #16a34a;
}

.copy-button--failed,
.copy-button--failed:hover {
  background-color: #dc2626;
}

.copy-button:disabled,
.copy-button:disabled:hover {
  background-color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.7;
}

.export-error {
  margin: 0 1.25rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
}

.control-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.tab-button {
  flex: 1;
  padding: 0.625rem 0.75rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #6b7280;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-button:hover {
  color: #111827;
}

.tab-button.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

.enable-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.enable-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 18px;
  background: #d1d5db;
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  margin: 0;
  transition: background-color 0.15s;
  outline: none;
}

.enable-toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.enable-toggle input[type="checkbox"]:checked {
  background: #3b82f6;
}

.enable-toggle input[type="checkbox"]:checked::before {
  transform: translateX(14px);
}

.control-section {
  border-bottom: 1px solid #e5e7eb;
}

.control-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.625rem 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  user-select: none;
}

.control-section > summary::-webkit-details-marker {
  display: none;
}

.control-section > summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 0.5rem;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid #6b7280;
  transition: transform 0.15s ease;
}

.control-section[open] > summary::before {
  transform: rotate(90deg);
}

.control-section > summary:hover {
  background-color: #f9fafb;
}

.control-section-body {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  padding: 0.5rem 0.25rem 1rem 0.25rem;
}

.control-group {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 0.5rem;
  row-gap: 0.375rem;
  align-items: center;
}

.control-group > label {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
}

.control-group > .value-readout {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
}

.control-group > input[type="range"],
.control-group > input[type="text"],
.control-group > select,
.control-group > .color-input,
.control-group > .shadow-controls {
  grid-column: 1 / -1;
  grid-row: 2;
}

.control-group > .control-hint {
  grid-column: 1 / -1;
  grid-row: 3;
  font-size: 0.75rem;
  color: #b45309;
}

.control-required {
  color: #ef4444;
  font-weight: 600;
  margin-left: 0.125rem;
}

.control-help {
  color: #9ca3af;
  font-weight: 400;
  font-size: 0.6875rem;
  font-style: italic;
}

.control-group input[type="text"] {
  width: 100%;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background-color: #ffffff;
  color: #111827;
}

.control-group input[type="text"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.control-group--wide {
  grid-template-rows: auto auto;
}

.value-readout {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: #6b7280;
  background-color: #f3f4f6;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: #3b82f6;
}

.control-group select {
  width: 100%;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background-color: #ffffff;
  color: #111827;
}

.color-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-input > input[type="color"] {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background-color: #ffffff;
  cursor: pointer;
}

.shadow-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.625rem;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.shadow-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: 0.5rem;
}

.shadow-row > input[type="color"] {
  width: 40px;
  height: 24px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background-color: #ffffff;
  cursor: pointer;
}

.shadow-label {
  font-size: 0.75rem;
  color: #6b7280;
}
