/* ============================================================================
   Carnival configurator — restyle to match the ConfettiSwap jester logo.

   Palette extracted from the logo:
     - Crimson red   #E83A4C   (jester silhouette, primary CTAs)
     - Magenta glow  #FF4E8A   (rim highlights, focus states)
     - Deep purple   #5B2BA5   (secondary shading, accent #2)
     - Bright purple #7B3AE8   (active states, links)
     - Background    #08040E   (deep almost-black with purple undertone)
   Visual language: dark carnival — sharp angular forms with selective curves,
   nebula-style radial gradients, soft confetti texture, glow on focus.
============================================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

:root {
  /* Surface */
  --bg:           #08040E;
  --panel:        #130A1F;
  --panel-2:      #1C1030;
  --panel-3:      #251638;
  --border:       rgba(232, 58, 76, 0.10);
  --border-hover: rgba(232, 58, 76, 0.28);
  --border-focus: rgba(232, 58, 76, 0.55);

  /* Text */
  --text:    #F4EEFA;
  --muted:   rgba(244, 238, 250, 0.55);
  --whisper: rgba(244, 238, 250, 0.32);

  /* Accents — straight from the logo */
  --accent:    #E83A4C;
  --accent-2:  #FF4E8A;
  --purple:    #5B2BA5;
  --purple-2:  #7B3AE8;

  /* Glow */
  --glow-red:    rgba(232, 58, 76, 0.35);
  --glow-mag:    rgba(255, 78, 138, 0.40);
  --glow-purple: rgba(123, 58, 232, 0.30);

  /* Status */
  --ok:     #2BD17E;
  --danger: #FF7B8C;

  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "ss01", "cv11";
}

* { box-sizing: border-box; }

/* ----------------------------------------------------------------------------
   Body: deep dark with nebula gradients echoing the logo's atmosphere.
   ---------------------------------------------------------------------------- */

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  height: 100%;
}

body {
  background:
    /* Confetti diamond pattern — extremely subtle */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'><g fill='%23E83A4C' fill-opacity='0.04'><path d='M20 30 l4 4 -4 4 -4 -4z'/><path d='M90 20 l3 3 -3 3 -3 -3z'/><path d='M70 80 l5 5 -5 5 -5 -5z'/><path d='M30 95 l3 3 -3 3 -3 -3z'/></g><g fill='%237B3AE8' fill-opacity='0.04'><path d='M105 70 l4 4 -4 4 -4 -4z'/><path d='M45 55 l3 3 -3 3 -3 -3z'/></g></svg>"),
    /* Two big radial nebula gradients matching the logo background */
    radial-gradient(circle at 12% 18%, rgba(232, 58, 76, 0.18), transparent 45%),
    radial-gradient(circle at 88% 82%, rgba(123, 58, 232, 0.16), transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(91, 43, 165, 0.05), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* ----------------------------------------------------------------------------
   Topbar
   ---------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background:
    linear-gradient(180deg, rgba(232, 58, 76, 0.06), transparent),
    rgba(8, 4, 14, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

/* Logo image — keep the jester crisp, drop the old gradient dot. */
.brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: #1A0816;
  box-shadow:
    0 0 32px var(--glow-red),
    0 0 0 1px rgba(232, 58, 76, 0.22) inset;
}

.brand .title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #FFE3EA 0%, var(--accent-2) 60%, var(--purple-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.brand .subtitle {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--whisper);
  margin-top: 2px;
}

/* Old `.dot` element retained but hidden by default — logo image takes its place */
.brand .dot { display: none; }

/* ----------------------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.01em;
  padding: 11px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition:
    transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 220ms ease,
    background 220ms ease,
    border-color 220ms ease;
  position: relative;
  overflow: hidden;
}
.btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-hover);
}
.btn:active { transform: translateY(0); }
.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn.ghost {
  background: transparent;
  border-color: var(--border);
}
.btn.ghost:hover {
  background: rgba(232, 58, 76, 0.06);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1A0612;
  border-color: transparent;
  box-shadow:
    0 14px 36px var(--glow-mag),
    0 0 0 1px rgba(255, 255, 255, 0.10) inset;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn.primary:hover {
  box-shadow:
    0 18px 44px var(--glow-mag),
    0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}
.btn.primary:disabled {
  background: var(--panel-3);
  color: var(--whisper);
  box-shadow: none;
}

/* ----------------------------------------------------------------------------
   Layout
   ---------------------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(380px, 480px) 1fr;
  gap: 24px;
  padding: 24px;
  height: calc(100vh - 73px);
}
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; height: auto; }
}

.panel {
  background:
    linear-gradient(180deg, rgba(232, 58, 76, 0.04), transparent 30%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  position: relative;
}
.panel::before {
  /* Subtle top-edge red glow on each panel — matches the logo's lit-from-above feel */
  content: "";
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  opacity: 0.35;
}

.form {
  padding: 22px;
  gap: 18px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 58, 76, 0.4) transparent;
}
.form::-webkit-scrollbar { width: 8px; }
.form::-webkit-scrollbar-track { background: transparent; }
.form::-webkit-scrollbar-thumb {
  background: rgba(232, 58, 76, 0.25);
  border-radius: 999px;
}
.form::-webkit-scrollbar-thumb:hover { background: rgba(232, 58, 76, 0.45); }

/* ----------------------------------------------------------------------------
   Form sections + fields
   ---------------------------------------------------------------------------- */

.section-title {
  font-size: 10px;
  font-weight: 900;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-top: 14px;
  margin-bottom: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  /* Tiny diamond marker — echoes the confetti in the logo */
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent);
  transform: rotate(45deg);
  box-shadow: 0 0 8px var(--glow-red);
}

.field {
  display: grid;
  gap: 6px;
}
.field label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="url"],
.field select,
.field textarea {
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  transition: border-color 180ms ease, box-shadow 220ms ease, background 220ms ease;
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--whisper);
}
.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--border-hover);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--panel-3);
  box-shadow:
    0 0 0 4px rgba(232, 58, 76, 0.10),
    0 0 24px var(--glow-red);
}

/* select dropdown arrow — custom so it matches the theme */
.field select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent-2) 50%),
    linear-gradient(135deg, var(--accent-2) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) center,
    calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

/* ----------------------------------------------------------------------------
   Checkbox / toggle rows
   ---------------------------------------------------------------------------- */

.field .checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.field .checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 120ms ease;
}
.field .checkboxes label:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.field .checkboxes input { accent-color: var(--accent); }

/* Toggle rows — pill-style row. Wrapper IS the <label>, text is inside a span.
   The whole row is clickable; the input + span flow horizontally. */
.field.toggle {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 120ms ease;
}
.field.toggle:hover {
  border-color: var(--border-hover);
  background: var(--panel-3);
  transform: translateY(-1px);
}
.field.toggle input {
  accent-color: var(--accent);
  margin: 2px 0 0;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.field.toggle span {
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  flex: 1;
  line-height: 1.4;
}

/* ----------------------------------------------------------------------------
   Preview panel
   ---------------------------------------------------------------------------- */

.preview {
  background:
    radial-gradient(circle at 30% 0%, rgba(232, 58, 76, 0.10), transparent 50%),
    radial-gradient(circle at 70% 100%, rgba(123, 58, 232, 0.10), transparent 55%),
    #0A0612;
  position: relative;
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.preview-frame {
  flex: 1;
  display: grid;
  place-items: center;
  position: relative;
}
.preview-frame::before {
  /* Subtle ambient glow behind the modal */
  content: "";
  position: absolute;
  inset: 20% 25%;
  background: radial-gradient(circle, rgba(232, 58, 76, 0.10), transparent 70%);
  pointer-events: none;
  filter: blur(40px);
}
.preview-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  display: block;
  position: relative;
  z-index: 1;
}

/* ----------------------------------------------------------------------------
   Toast
   ---------------------------------------------------------------------------- */

.muted { color: var(--muted); }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background:
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border-hover);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.55),
    0 0 24px var(--glow-red);
  z-index: 50;
  letter-spacing: 0.02em;
}
.toast.is-ok    { color: var(--ok);    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55), 0 0 24px rgba(43, 209, 126, 0.35); }
.toast.is-error { color: var(--danger); box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55), 0 0 24px rgba(255, 123, 140, 0.35); }

/* ----------------------------------------------------------------------------
   Reduced motion
   ---------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
