*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-surface-hover: #f0f1f3;
  --color-border: #e2e4e9;
  --color-border-focus: #a3b8d8;
  --color-text: #1a1d27;
  --color-text-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #eff4ff;
  --color-success: #059669;
  --color-success-light: #ecfdf5;
  --color-danger: #dc2626;
  --color-danger-light: #fef2f2;
  --color-warning: #d97706;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout */

.configurator {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
}

.configurator__header {
  margin-bottom: 32px;
}

.configurator__title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-text);
}

.configurator__subtitle {
  color: var(--color-text-muted);
  font-size: 14px;
}

.configurator__body {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  .configurator__body {
    grid-template-columns: 1fr;
  }
}

/* Sidebar */

.configurator__sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Widget picker */

.widget-picker {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.widget-picker__header {
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.widget-picker__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.widget-picker__search {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.widget-picker__search:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.widget-picker__search::placeholder {
  color: var(--color-text-muted);
  opacity: 0.6;
}

.widget-picker__grid {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 360px;
  overflow-y: auto;
}

/* Widget card */

.widget-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
  width: 100%;
}

.widget-card:hover {
  background: var(--color-bg);
}

.widget-card--active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.widget-card--active:hover {
  background: var(--color-primary-light);
}

.widget-card__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border-radius: var(--radius);
  position: relative;
}

.widget-card--active .widget-card__icon {
  background: #fff;
}

/* CSS icon: carousel — three bars */
.widget-card__icon--glide-news-carousel::after,
.widget-card__icon--offers-carousel::after,
.widget-card__icon--offers-carousel-v2::after,
.widget-card__icon--newsletter-carousel::after {
  content: "";
  width: 18px;
  height: 12px;
  display: flex;
  background:
    repeating-linear-gradient(
      to right,
      var(--color-primary) 0px, var(--color-primary) 4px,
      transparent 4px, transparent 6px
    );
  border-radius: 1px;
}

/* v2 gets a dot below */
.widget-card__icon--offers-carousel-v2::before {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 10px;
  height: 2px;
  background:
    repeating-linear-gradient(
      to right,
      var(--color-primary) 0px, var(--color-primary) 2px,
      transparent 2px, transparent 4px
    );
}

/* CSS icon: single offer — card shape */
.widget-card__icon--single-offer::after {
  content: "";
  width: 14px;
  height: 16px;
  border: 2px solid var(--color-primary);
  border-radius: 3px;
}

/* CSS icon: banner — wide rect */
.widget-card__icon--widget-banner::after {
  content: "";
  width: 20px;
  height: 10px;
  border: 2px solid var(--color-primary);
  border-radius: 2px;
  background: linear-gradient(135deg, transparent 40%, var(--color-primary-light) 40%);
}

/* CSS icon: bet builder — selection row with chevron */
.widget-card__icon--bet-builder::after {
  content: "";
  width: 18px;
  height: 14px;
  border-top: 2px solid var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  background:
    linear-gradient(var(--color-primary), var(--color-primary)) 0 6px / 12px 2px no-repeat,
    linear-gradient(45deg, transparent 45%, var(--color-primary) 45% 58%, transparent 58%) 13px 4px / 6px 6px no-repeat;
}

/* Glide news gets a small newspaper line */
.widget-card__icon--glide-news-carousel::before {
  content: "";
  position: absolute;
  top: 7px;
  width: 10px;
  height: 1.5px;
  background: var(--color-primary);
  opacity: 0.4;
}

/* Newsletter gets an envelope hint */
.widget-card__icon--newsletter-carousel::before {
  content: "";
  position: absolute;
  top: 8px;
  width: 8px;
  height: 5px;
  border: 1.5px solid var(--color-primary);
  border-radius: 1px;
  background: transparent;
  opacity: 0.4;
}

.widget-card__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.widget-card__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.widget-card__desc {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.widget-card__tag {
  font-family: "SF Mono", "Fira Code", Menlo, monospace;
  font-size: 10px;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 1px 5px;
  border-radius: 3px;
  align-self: flex-start;
  margin-top: 2px;
}

/* Widget selected bar */

.widget-selected {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

.widget-selected:not([hidden]) {
  display: flex;
}

.widget-selected__info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.widget-selected__icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light);
  border-radius: var(--radius);
  flex-shrink: 0;
  position: relative;
}

.widget-selected__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.widget-selected__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.widget-selected__tag {
  font-family: "SF Mono", "Fira Code", Menlo, monospace;
  font-size: 11px;
  color: var(--color-primary);
}

.widget-selected__remove {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 18px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.widget-selected__remove:hover {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: var(--color-danger-light);
}

/* Properties form */

.properties-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Form tabs */

.form-tabs {
  display: flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 4px;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}

.form-tabs__btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.form-tabs__btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.form-tabs__btn--active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.form-tabs__btn--active:hover {
  background: var(--color-primary-hover);
  color: #fff;
}

.form-tabs__panel {
  flex-direction: column;
  gap: 4px;
}

.form-tabs__panel:not([hidden]) {
  display: flex;
}

/* Form sections */

.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.form-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.form-section--collapsible .form-section__header {
  cursor: pointer;
  user-select: none;
}

.form-section--collapsible .form-section__header:hover {
  background: var(--color-surface-hover);
}

.form-section__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.form-section__chevron {
  font-size: 12px;
  color: var(--color-text-muted);
  transition: transform 0.2s;
}

.form-section--open .form-section__chevron {
  transform: rotate(90deg);
}

.form-section__desc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px 0;
}

.form-section__description {
  font-size: 12px;
  color: var(--color-text-muted);
}

.form-section__reset-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.form-section__reset-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.form-section__reset-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.form-section__reset-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.form-section__body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Field */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field__label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.field__required {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 1px 6px;
  border-radius: 4px;
}

.field__description {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.field__input,
.field__select {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.field__input:focus,
.field__select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.field__input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.5;
}

.field__select {
  cursor: pointer;
}

/* Toggle switch */

.field__toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
}

.field__checkbox {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.field__slider {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--color-border);
  border-radius: 22px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.field__slider::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.field__checkbox:checked + .field__slider {
  background: var(--color-primary);
}

.field__checkbox:checked + .field__slider::after {
  transform: translateX(18px);
}

.field__toggle-label {
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Overwrites */

.overwrites {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overwrites__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overwrites__row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px;
}

.overwrites__row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 2px;
}

.overwrites__row-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.overwrites__input {
  font-size: 12px;
  padding: 6px 8px;
  width: 100%;
}

.overwrites__field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.overwrites__field-label {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.overwrites__remove-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 16px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.overwrites__remove-btn:hover {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: var(--color-danger-light);
}

.overwrites__add-btn {
  background: none;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  color: var(--color-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 8px;
  transition: background 0.15s, border-color 0.15s;
}

.overwrites__add-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

/* Output */

.configurator__output {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 24px;
  align-self: start;
}

.code-output {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.code-output__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.code-output__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.code-output__copy-btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.code-output__copy-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.code-output__copy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.code-output__copy-btn--success {
  background: var(--color-success);
}

.code-output__pre {
  margin: 0;
  padding: 20px;
  overflow-x: auto;
  background: #1e1e2e;
  cursor: text;
  user-select: all;
  -webkit-user-select: all;
}

.code-output__code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
  color: #a6e3a1;
  word-break: break-all;
  white-space: pre-wrap;
  text-shadow: 0 0 2px rgba(166, 227, 161, 0.15);
}

.code-output__pre::selection,
.code-output__code::selection {
  background: rgba(137, 180, 250, 0.3);
  color: #cdd6f4;
}

/* Preview panel */

.preview-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.preview-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.preview-panel__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Viewport switcher */

.preview-viewport {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2px;
}

.preview-viewport__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border: none;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s;
}

.preview-viewport__btn:hover {
  background: var(--color-bg);
}

.preview-viewport__btn--active {
  background: var(--color-primary-light);
}

.preview-viewport__btn--active:hover {
  background: var(--color-primary-light);
}

.preview-viewport__label {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
  min-width: 48px;
}

/* Viewport CSS icons */

.vp-icon {
  display: block;
  border: 1.5px solid var(--color-text-muted);
  border-radius: 2px;
  transition: border-color 0.12s;
}

.preview-viewport__btn--active .vp-icon {
  border-color: var(--color-primary);
}

.vp-icon--desktop {
  width: 18px;
  height: 12px;
  border-bottom-width: 2.5px;
}

.vp-icon--tablet {
  width: 13px;
  height: 16px;
  border-radius: 2.5px;
}

.vp-icon--mobile {
  width: 9px;
  height: 15px;
  border-radius: 2.5px;
}

.preview-panel__btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.preview-panel__btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.preview-panel__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Preview loading */
.preview-panel__btn--loading,
.preview-panel__btn--loading:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  cursor: wait;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 1;
}

.btn-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(37, 99, 235, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Preview is up to date */
.preview-panel__btn--current {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

/* Preview is stale */
.preview-panel__btn--stale {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  animation: gentle-glow 3s ease-in-out infinite;
}

.preview-panel__btn--stale:hover {
  background: var(--color-primary);
  color: #fff;
  animation: none;
}

@keyframes gentle-glow {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
}

.preview-panel__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.preview-panel__content {
  padding: 16px;
  background: #fff;
  min-height: 350px;
  max-height: 700px;
  overflow: auto;
}

.preview-panel__iframe {
  width: 100%;
  min-height: 200px;
  border: none;
  display: block;
  transition: width 0.3s ease;
}

@media (max-width: 900px) {
  .preview-panel__iframe {
    width: 100% !important;
    margin: 0 !important;
  }
}

.preview-panel__error {
  background: var(--color-danger-light);
  border: 1px solid #fca5a5;
  color: var(--color-danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin: 12px 16px 0;
}

.preview-panel__placeholder {
  color: var(--color-text-muted);
  font-size: 14px;
  text-align: center;
  padding: 60px 20px;
}
