@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/plus-jakarta-sans/plus-jakarta-sans-variable.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --accent-1: #ad62fe;
  --accent-2: #6bdffe;
  --accent-gradient: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-2) 100%);
  --bg: #f4f5f9;
  --card: #ffffff;
  --border: #e3e5ec;
  --text: #1c1e29;
  --text-muted: #80828f;
  --radius: 14px;
  --radius-sm: 10px;

  /* Shared width logic: all inner content/generator boxes use the same
     max-width, the outer site frame (site.css) is ~60px wider so its
     edge reads as a margin around the aligned inner boxes. */
  --inner-box-width: 820px;
  --outer-box-width: 880px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.page {
  width: 100%;
  max-width: var(--inner-box-width);
  margin: 0 auto;
  padding: 32px 24px 48px;
  box-sizing: border-box;
}

/* ---------- Header / footer ---------- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}

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

.lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.lang-btn:hover {
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.page-footer {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

.reset-link,
.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 4px;
  transition: color 0.15s ease;
}

.reset-link:hover,
.text-btn:hover {
  color: var(--text);
}

/* ---------- Cards / steps ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  animation: card-in 0.45s ease both;
}

.page section.card:nth-of-type(1) { animation-delay: 0s; }
.page section.card:nth-of-type(2) { animation-delay: 0.06s; }
.page section.card:nth-of-type(3) { animation-delay: 0.12s; }
.page section.card:nth-of-type(4) { animation-delay: 0.18s; }
.page section.card:nth-of-type(5) { animation-delay: 0.24s; }

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
  text-align: center;
}

/* ---------- Type grid ---------- */

.type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.type-btn .icon {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.type-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent-1);
}

.type-btn:hover .icon {
  color: var(--accent-1);
}

.type-btn.active {
  border-color: transparent;
  background-image: linear-gradient(var(--card), var(--card)), var(--accent-gradient);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 4px 14px rgba(173, 98, 254, 0.18);
}

.type-btn.active .icon {
  color: var(--accent-1);
}

/* ---------- Form fields ---------- */

.field {
  margin-bottom: 16px;
}

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

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="datetime-local"],
.field textarea,
.field select {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(173, 98, 254, 0.14);
}

.field-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.field-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-1);
}

/* ---------- Error correction buttons ---------- */

.ec-buttons {
  display: flex;
  gap: 8px;
}

.ec-btn {
  flex: 1;
  padding: 10px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
}

.ec-btn:hover {
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.ec-btn.active {
  border-color: transparent;
  background-image: linear-gradient(var(--card), var(--card)), var(--accent-gradient);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: var(--accent-1);
}

/* ---------- Color fields ---------- */

.color-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.color-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.swatch:hover {
  transform: scale(1.12);
}

.swatch.active {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent-1);
}

.color-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-input-row input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

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

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

.color-input-row input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 7px;
}

.color-hex {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  text-transform: lowercase;
}

/* ---------- Logo step ---------- */

.logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-preview {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.logo-controls input[type="file"] {
  font-family: inherit;
  font-size: 0.85rem;
  max-width: 100%;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 10px 0 0;
}

.hint-warning {
  color: #92620a;
  background: #fef3da;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ---------- Output step ---------- */

.qr-preview-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

#qr-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  transition: opacity 0.2s ease;
}

#qr-preview canvas,
#qr-preview svg {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.size-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.size-btn {
  flex: 1 1 64px;
  padding: 10px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
}

.size-btn:hover {
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.size-btn.active {
  border-color: transparent;
  background-image: linear-gradient(var(--card), var(--card)), var(--accent-gradient);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: var(--accent-1);
}

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

.btn-primary {
  display: block;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 6px 16px rgba(173, 98, 254, 0.28);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(173, 98, 254, 0.34);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 16px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay.open {
  opacity: 1;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 360px;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  text-align: center;
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 16px;
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.format-btn {
  padding: 10px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.format-btn:hover {
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.lang-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.lang-option .flag {
  font-size: 1.3rem;
  line-height: 1;
}

.lang-option:hover {
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.lang-option.active {
  border-color: transparent;
  background-image: linear-gradient(var(--card), var(--card)), var(--accent-gradient);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 4px 14px rgba(173, 98, 254, 0.18);
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .type-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .color-fields {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .page {
    padding: 22px 24px 40px;
  }
}

/* ---------- RTL support (Arabic etc.) ---------- */

[dir="rtl"] .field-checkbox label {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

[dir="rtl"] .logo-controls {
  align-items: flex-end;
}

[dir="rtl"] input[type="url"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="tel"] {
  direction: ltr;
  text-align: right;
}
