@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Space+Grotesk:wght@400;500;600&display=swap');

:root {
  --bg-dark: #0b1b1f;
  --bg-mid: #14343b;
  --bg-light: #f1f4ef;
  --accent: #ffb347;
  --accent-2: #42c2d9;
  --ink: #0f1d22;
  --card: #f8f6f1;
  --shadow: 0 30px 60px rgba(7, 25, 29, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: var(--bg-light);
  background: radial-gradient(1200px circle at 10% -10%, #1b4b54, transparent 60%),
    radial-gradient(900px circle at 90% 0%, #243e43, transparent 55%),
    linear-gradient(120deg, var(--bg-dark), var(--bg-mid));
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-noise {
  position: fixed;
  inset: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="160" height="160" viewBox="0 0 160 160"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2" stitchTiles="stitch"/></filter><rect width="160" height="160" filter="url(%23n)" opacity="0.06"/></svg>');
  mix-blend-mode: soft-light;
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.hero {
  max-width: 720px;
  margin-bottom: 36px;
  animation: fadeInUp 0.8s ease both;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.75rem;
  color: var(--accent-2);
  margin-bottom: 12px;
}

.hero h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  margin: 0 0 12px;
  color: #fff7e8;
}

.lead {
  font-size: 1.05rem;
  color: #d7ebe7;
  margin: 0;
}

.panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.2fr);
  gap: 28px;
  align-items: start;
}

.upload-card,
.preview-card {
  background: var(--card);
  color: var(--ink);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.9s ease both;
}

.upload-card::after {
  content: '';
  position: absolute;
  inset: auto -60px -60px auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255, 179, 71, 0.4), transparent 70%);
  transform: rotate(18deg);
  pointer-events: none;
}

.upload-box {
  border: 2px dashed rgba(15, 29, 34, 0.2);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  background: #fffaf0;
  transition: border-color 0.2s ease, transform 0.2s ease;
  position: relative;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.template-card {
  border: 1px solid rgba(15, 29, 34, 0.15);
  border-radius: 16px;
  padding: 10px;
  background: white;
  display: grid;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.template-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.template-card span {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.template-card.selected {
  border-color: var(--accent-2);
  box-shadow: 0 12px 24px rgba(66, 194, 217, 0.2);
  transform: translateY(-2px);
}

.upload-box.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.upload-box.dragover {
  border-color: var(--accent-2);
  transform: translateY(-4px);
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-copy h2 {
  font-family: 'Fraunces', serif;
  margin: 0 0 8px;
}

.upload-meta {
  margin-top: 12px;
  font-size: 0.9rem;
  color: #4a5b61;
}

.actions {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.whatsapp-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-weight: 600;
  color: #0c4a2f;
  text-decoration: none;
}

.whatsapp-btn {
  align-self: flex-start;
  padding: 10px 16px;
  border-radius: 999px;
  background: #e6f7ee;
  border: 1px solid rgba(12, 74, 47, 0.15);
}

.preview-download {
  align-self: flex-start;
}

.whatsapp-link::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #25d366;
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.15);
}

.whatsapp-link:hover {
  text-decoration: underline;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--accent);
  color: #1d1d1d;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px rgba(255, 179, 71, 0.35);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(15, 29, 34, 0.2);
  color: var(--ink);
}

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

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.preview-header h3 {
  margin: 0;
  font-family: 'Fraunces', serif;
}

.chip {
  font-size: 0.75rem;
  background: rgba(66, 194, 217, 0.2);
  color: #0c3840;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
}

#outputCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  background: repeating-linear-gradient(45deg, #f0f3f3, #f0f3f3 10px, #f8fbfb 10px, #f8fbfb 20px);
  box-shadow: inset 0 0 0 1px rgba(15, 29, 34, 0.1);
}

.hint {
  margin: 0;
  font-size: 0.9rem;
  color: #4a5b61;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 600px) {
  .page {
    padding: 32px 18px 64px;
  }

  .upload-card,
  .preview-card {
    padding: 20px;
  }
}
