/* ╔══════════════════════════════════════════╗
   ║  QR Poster Studio  –  Design System     ║
   ╚══════════════════════════════════════════╝ */

/* ── Design Tokens ── */
:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;

  /* Dark canvas */
  --bg-body: #0c0f14;
  --bg-surface: rgba(22, 27, 37, 0.85);
  --bg-surface-hover: rgba(30, 37, 50, 0.95);
  --bg-elevated: rgba(35, 42, 58, 0.7);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(255, 255, 255, 0.18);

  /* Text */
  --text-primary: #f1f3f5;
  --text-secondary: #8b95a5;
  --text-muted: #5a6578;

  /* Accent */
  --accent: #7c6aef;
  --accent-glow: rgba(124, 106, 239, 0.25);

  /* Poster dynamic colors */
  --dynamic-accent: #e96a2d;
  --dynamic-bg: #fffaf0;
  --dynamic-qr: #1a1a2e;

  /* Layout */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Animated gradient blobs behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 10% 20%, rgba(124, 106, 239, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 85% 70%, rgba(233, 106, 45, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(0, 119, 182, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

/* ╔═══════════════════╗
   ║  HEADER           ║
   ╚═══════════════════╝ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px) saturate(130%);
  background: rgba(12, 15, 20, 0.75);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #5b4adb);
  display: grid;
  place-items: center;
  color: white;
  flex-shrink: 0;
}
.brand-icon svg { width: 22px; height: 22px; }

.brand h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.tagline {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ╔═══════════════════╗
   ║  BUTTONS          ║
   ╚═══════════════════╝ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5b4adb);
  color: #fff;
  padding: 13px 24px;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 12px 20px;
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 14px;
  font-size: 0.82rem;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-elevated); }

.btn-lg { padding: 14px 28px; font-size: 0.95rem; }

/* ╔═══════════════════╗
   ║  WORKSPACE GRID   ║
   ╚═══════════════════╝ */
.workspace {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 28px;
  align-items: start;
}

/* ── Glass Panel (controls) ── */
.glass-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(20px) saturate(120%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
}

/* ╔═══════════════════╗
   ║  FORM SECTIONS    ║
   ╚═══════════════════╝ */
.form-section {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.step-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5b4adb);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.optional-tag {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

/* ── Fields ── */
.field {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.field:last-child { margin-bottom: 0; }

.field span { font-size: 0.78rem; }

.field input[type="url"],
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-weight: 500;
  font-size: 0.88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b95a5'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ── Color fields ── */
.color-field .color-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  transition: border-color var(--transition);
}
.color-field .color-input-wrap:focus-within {
  border-color: var(--accent);
}

.color-field input[type="color"] {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  background: none;
  flex-shrink: 0;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border-radius: 5px; border: 1px solid rgba(255,255,255,0.1); }

.color-hex {
  font-size: 0.72rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ── Preset Swatches ── */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.preset-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 4px 8px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.preset-swatch:hover { background: var(--bg-elevated); }
.preset-swatch.active {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.swatch-color {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  border: 2px solid rgba(255,255,255,0.08);
  transition: transform var(--transition);
}
.preset-swatch:hover .swatch-color { transform: scale(1.1); }

.swatch-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.custom-colors { margin-top: 14px; }

/* ── Drop Zone ── */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border-focus);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  overflow: hidden;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(124, 106, 239, 0.05);
}

.drop-zone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  pointer-events: none;
}
.drop-zone-content svg { color: var(--text-secondary); }
.drop-zone-content p { font-size: 0.82rem; font-weight: 500; }
.drop-zone-content small { font-size: 0.72rem; }
.link-text { color: var(--accent); text-decoration: underline; }

.drop-zone-preview {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}
.drop-zone-preview img {
  max-height: 60px;
  max-width: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.remove-logo {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  border: none;
  font-size: 0.72rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform var(--transition);
  line-height: 1;
}
.remove-logo:hover { transform: scale(1.15); }

/* ── Download ── */
.download-actions {
  display: flex;
  gap: 10px;
}
.download-actions .btn { flex: 1; justify-content: center; }

/* ╔═══════════════════╗
   ║  PREVIEW PANEL    ║
   ╚═══════════════════╝ */
.preview-panel {
  position: sticky;
  top: 80px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
}

.preview-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 50px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}
.status-badge.ready {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.2);
  background: rgba(52, 211, 153, 0.08);
}

.preview-stage {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  min-height: 680px;
  overflow: hidden;

  /* Subtle checkerboard pattern */
  background-image:
    radial-gradient(circle at 50% 50%, rgba(124, 106, 239, 0.03) 0%, transparent 70%);
}

/* ╔═══════════════════╗
   ║  POSTER PREVIEW   ║
   ╚═══════════════════╝ */
.poster-preview {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 20px 60px rgba(0, 0, 0, 0.4));
}

.poster-card {
  position: relative;
  background-color: var(--dynamic-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Poster sizes (scaled for screen) */
.size-a4 .poster-card { width: 380px; height: 538px; border-radius: 4px; }
.size-a3 .poster-card { width: 380px; height: 538px; border-radius: 4px; }
.size-letter .poster-card { width: 380px; height: 492px; border-radius: 4px; }
.size-tabloid .poster-card { width: 380px; height: 587px; border-radius: 4px; }
.size-square .poster-card { width: 400px; height: 400px; border-radius: 4px; }

.poster-background {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% 10%, var(--dynamic-accent), transparent 60%);
  opacity: 0.15;
  transition: opacity 0.4s;
}

.poster-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 28px 24px;
  text-align: center;
}

/* ── Poster zones ── */
.logo-preview {
  height: 60px;
  width: 100%;
  object-fit: contain;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.headline-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 16px;
  flex: 0 0 auto;
  min-height: 80px;
  max-height: 160px;
  overflow: hidden;
}

.kicker {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
  color: var(--dynamic-accent);
}

.headline-block h3 {
  margin: 0;
  font-family: var(--font);
  font-weight: 900;
  line-height: 1.15;
  color: var(--dynamic-accent);
  word-wrap: break-word;
  overflow: hidden;
}

.qr-frame {
  background: white;
  padding: 14px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
  flex-shrink: 0;
  transition: transform 0.3s;
}

.qr-target { width: 160px; height: 160px; }
.qr-target canvas,
.qr-target img { width: 100% !important; height: 100% !important; display: block; }

.scan-hint {
  font-size: 0.72rem;
  color: #536271;
  margin: 12px 0 4px;
  font-weight: 500;
}

.link-preview {
  font-size: 0.65rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #8a9bb0;
  word-break: break-all;
  margin: 0;
}

/* ── Visual states ── */
.is-empty { opacity: 0.25; filter: blur(1px); }
.hidden { display: none !important; }

/* ╔═══════════════════╗
   ║  FOOTER           ║
   ╚═══════════════════╝ */
.app-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px 28px 32px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ╔═══════════════════╗
   ║  RESPONSIVE       ║
   ╚═══════════════════╝ */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 20px;
  }
  .preview-panel { position: static; }
  .preview-stage { min-height: auto; padding: 24px; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 520px) {
  .header-inner { padding: 12px 16px; }
  .brand h1 { font-size: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .download-actions { flex-direction: column; }

  .size-a4 .poster-card,
  .size-a3 .poster-card,
  .size-letter .poster-card,
  .size-tabloid .poster-card { width: 280px; height: auto; min-height: 396px; }
  .size-square .poster-card { width: 280px; height: 280px; }
}

/* ╔═══════════════════╗
   ║  ANIMATIONS       ║
   ╚═══════════════════╝ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.form-section {
  animation: fadeInUp 0.5s ease both;
}
.form-section:nth-child(1) { animation-delay: 0.05s; }
.form-section:nth-child(2) { animation-delay: 0.10s; }
.form-section:nth-child(3) { animation-delay: 0.15s; }
.form-section:nth-child(4) { animation-delay: 0.20s; }
.form-section:nth-child(5) { animation-delay: 0.25s; }
.form-section:nth-child(6) { animation-delay: 0.30s; }

.preview-stage {
  animation: fadeInUp 0.6s ease 0.15s both;
}
