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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a28;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --accent-primary: #8b5cf6;
  --accent-secondary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #8b5cf6, #06b6d4);
  --accent-gradient-warm: linear-gradient(135deg, #f97316, #ec4899);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(139, 92, 246, 0.3);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================
   HEADER
   ============================ */
.app-header {
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

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

.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 22px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================
   BUTTONS
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(139, 92, 246, 0.45);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-ghost {
  background: none;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 13px;
}

.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  font-size: 18px;
}

/* ============================
   MAIN LAYOUT
   ============================ */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ============================
   INPUT SECTION
   ============================ */
.input-section {
  margin-bottom: 32px;
  animation: fadeUp 0.5s ease forwards;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.input-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.input-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.input-tab {
  flex: 1;
  padding: 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  font-family: 'Inter', sans-serif;
}

.input-tab:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}

.input-tab.active {
  color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.06);
  border-bottom: 2px solid var(--accent-primary);
}

.input-body {
  padding: 24px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.upload-area {
  border: 2px dashed rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(139, 92, 246, 0.03);
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.08);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.upload-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

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

.upload-subtitle span {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

#fileInput {
  display: none;
}

.json-textarea {
  width: 100%;
  min-height: 200px;
  max-height: 400px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 16px;
  resize: vertical;
  transition: var(--transition);
  line-height: 1.5;
}

.json-textarea::placeholder {
  color: var(--text-muted);
}

.json-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

/* ============================
   STATS BAR
   ============================ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
  animation: fadeUp 0.5s ease 0.1s forwards;
  opacity: 0;
}

.stats-bar.visible {
  opacity: 1;
  animation: fadeUp 0.5s ease forwards;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.purple {
  background: rgba(139, 92, 246, 0.15);
}

.stat-icon.cyan {
  background: rgba(6, 182, 212, 0.15);
}

.stat-icon.orange {
  background: rgba(249, 115, 22, 0.15);
}

.stat-icon.pink {
  background: rgba(236, 72, 153, 0.15);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 700;
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 500;
}

/* ============================
   WEEK SELECTOR
   ============================ */
.week-selector {
  display: none;
  margin-bottom: 28px;
  animation: fadeUp 0.4s ease forwards;
}

.week-selector.visible {
  display: block;
}

.week-selector-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.week-selector-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.week-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.week-pill {
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
}

.week-pill:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: rgba(139, 92, 246, 0.1);
}

.week-pill.active {
  background: var(--accent-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.week-pill-info {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.85;
  display: block;
  margin-top: 2px;
}

/* ============================
   SECTION HEADERS
   ============================ */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 36px 0 18px;
}

.section-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-gradient);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: white;
}

.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
}

/* ============================
   SLIDES PREVIEW GRID
   ============================ */
.slides-output {
  margin-top: 8px;
}

.slides-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 16px;
}

.slide-wrapper {
  position: relative;
  animation: slideIn 0.45s ease forwards;
  opacity: 0;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.slide-label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-card);
  border-radius: 6px;
}

/* ============================
   SLIDE CANVAS (1080x1080)
   ============================ */
.slide-canvas {
  width: 1080px;
  height: 1080px;
  position: relative;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
}

.slide-preview {
  width: 340px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  cursor: pointer;
}

.slide-preview:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
}

.slide-preview-container {
  width: 340px;
  height: 340px;
  overflow: hidden;
}

.slide-preview .slide-canvas {
  transform: scale(calc(340 / 1080));
  transform-origin: top left;
}

/* ============================
   SLIDE BACKGROUNDS
   ============================ */
.slide-bg-dark {
  background: linear-gradient(160deg, #0f0f1a 0%, #1a1028 40%, #0d1520 100%);
}

.slide-bg-cover {
  background: linear-gradient(160deg, #0f0f1a 0%, #1e1040 50%, #0a1628 100%);
}

.slide-bg-final {
  background: linear-gradient(160deg, #1a0a2e 0%, #0f1b3d 50%, #0a1628 100%);
}

/* Background Image Layer */
.slide-bg-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.slide-bg-image img {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  object-fit: cover;
  display: block;
  transform-origin: center center;
}

.slide-bg-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.5);
}

/* ============================
   SLIDE: COVER — all content z-index:3+
   ============================ */
.slide-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px;
}

.cover-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.cover-circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.08;
}

.cover-circle-1 {
  width: 600px;
  height: 600px;
  background: var(--accent-primary);
  top: -200px;
  right: -150px;
}

.cover-circle-2 {
  width: 400px;
  height: 400px;
  background: var(--accent-secondary);
  bottom: -100px;
  left: -100px;
}

.cover-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 600;
  color: #c4b5fd;
  margin-bottom: 40px;
  z-index: 3;
  position: relative;
}

.cover-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 72px;
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff 30%, #c4b5fd 60%, #67e8f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 24px;
  z-index: 3;
  position: relative;
}

.cover-subtitle {
  font-size: 24px;
  color: var(--text-secondary);
  font-weight: 400;
  z-index: 3;
  position: relative;
}

.cover-date-range {
  margin-top: 40px;
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  font-size: 20px;
  font-weight: 500;
  color: var(--text-secondary);
  z-index: 3;
  position: relative;
}

.cover-line {
  width: 120px;
  height: 4px;
  background: var(--accent-gradient);
  border-radius: 2px;
  margin: 30px 0;
  z-index: 3;
  position: relative;
}

/* ============================
   SLIDE: EVENTS LIST
   ============================ */
.slide-events {
  display: flex;
  flex-direction: column;
  padding: 44px;
}

.slide-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.slide-top-left,
.slide-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slide-brand-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.slide-brand-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.slide-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
}

.badge-semana {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
}

.badge-fds {
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: #fdba74;
}

.slide-page-number {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.event-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 14px 16px;
}

.event-image-wrap {
  width: 200px;
  height: 140px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}

.event-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.event-image-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.event-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.event-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 23px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-venue {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 500;
  color: #c4b5fd;
}

.event-address {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-datetime {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent-secondary);
  margin-top: 2px;
}

.event-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ============================
   SLIDE: FINAL — all content z-index:3+
   ============================ */
.slide-final {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px;
}

.final-emoji {
  font-size: 100px;
  margin-bottom: 30px;
  z-index: 3;
  position: relative;
}

.final-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 68px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 20%, #f97316 50%, #ec4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
  margin-bottom: 24px;
  z-index: 3;
  position: relative;
}

.final-subtitle {
  font-size: 22px;
  color: var(--text-secondary);
  z-index: 3;
  position: relative;
}

.final-cta {
  margin-top: 40px;
  padding: 16px 40px;
  background: var(--accent-gradient-warm);
  border-radius: 30px;
  font-size: 20px;
  font-weight: 700;
  color: white;
  z-index: 3;
  position: relative;
}

/* ============================
   WATERMARK
   ============================ */
.slide-watermark {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 1px;
  z-index: 5;
}

/* ============================
   MODAL
   ============================ */
.slide-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  align-items: center;
  justify-content: center;
}

.slide-modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-dialog {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 95vw;
  max-height: 95vh;
  overflow: hidden;
  animation: modalIn 0.3s ease;
  display: flex;
  flex-direction: column;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #f87171;
}

.modal-body {
  display: flex;
  gap: 0;
  overflow: hidden;
  max-height: calc(95vh - 60px);
}

.modal-slide-area {
  flex: 1;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  min-width: 0;
}

.modal-slide-container {
  width: 540px;
  height: 540px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.modal-slide-container .slide-canvas {
  transform: scale(0.5);
  transform-origin: top left;
}

/* Modal sidebar */
.modal-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* Text edit fields */
.text-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.text-edit-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.text-edit-field input,
.text-edit-field textarea {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  outline: none;
  transition: var(--transition);
}

.text-edit-field input:focus,
.text-edit-field textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

.text-edit-field textarea {
  resize: vertical;
  min-height: 40px;
  max-height: 80px;
}

/* Emoji grid */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.emoji-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  background: var(--bg-card);
}

.emoji-item:hover {
  transform: scale(1.15);
  background: var(--bg-card-hover);
}

.emoji-item.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.1);
}

/* BG upload area */
.bg-upload-area {
  border: 2px dashed rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(139, 92, 246, 0.03);
}

.bg-upload-area:hover {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.08);
}

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

.control-label-sm {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.range-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

.range-value {
  font-size: 12px;
  color: var(--accent-primary);
  font-weight: 600;
  text-align: right;
}

.hint-text {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* Color swatches */
.color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: white;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.hex-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 4px 4px 12px;
}

.hex-prefix {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}

.hex-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  min-width: 0;
  text-transform: uppercase;
}

.color-apply-btns {
  display: flex;
  gap: 8px;
}

.color-apply-btns .btn {
  flex: 1;
  justify-content: center;
}

/* ============================
   DOWNLOAD MODAL
   ============================ */
.download-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  align-items: center;
  justify-content: center;
}

.download-modal.open {
  display: flex;
}

.download-dialog {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 420px;
  max-width: 92vw;
  overflow: hidden;
  animation: modalIn 0.3s ease;
}

.download-options {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.download-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  text-align: left;
  width: 100%;
  color: var(--text-primary);
}

.download-option:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.15);
}

.download-option:active {
  transform: translateY(0);
}

.download-option-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.download-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.download-option-title {
  font-size: 15px;
  font-weight: 700;
}

.download-option-desc {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ============================
   LOADING OVERLAY
   ============================ */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(10px);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(139, 92, 246, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 17px;
  font-weight: 500;
}

.loading-progress {
  width: 300px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.loading-progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ============================
   MISC
   ============================ */
.render-area {
  position: fixed;
  left: -9999px;
  top: 0;
}

.hidden {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state-text {
  font-size: 18px;
  font-weight: 500;
}

/* ============================
   TOAST
   ============================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease;
  max-width: 380px;
}

.toast.success {
  border-left: 3px solid #22c55e;
}

.toast.error {
  border-left: 3px solid #ef4444;
}

.toast.info {
  border-left: 3px solid #3b82f6;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================
   VARIATION MODAL
   ============================ */
.variation-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  align-items: center;
  justify-content: center;
}

.variation-modal.open {
  display: flex;
}

.variation-dialog {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 440px;
  max-width: 92vw;
  overflow: hidden;
  animation: modalIn 0.3s ease;
}

.variation-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.variation-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.variation-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.variation-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.variation-input {
  width: 80px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  padding: 10px 14px;
  text-align: center;
  outline: none;
  transition: var(--transition);
}

.variation-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.variation-toggle-group {
  display: flex;
  gap: 8px;
}

.variation-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.variation-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.variation-toggle.active {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-primary);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

.toggle-icon {
  font-size: 18px;
}

.layout-warning {
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: #fdba74;
  animation: fadeIn 0.3s ease;
}

/* ============================
   IMAGE CROP CONTROLS
   ============================ */
.crop-info-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  text-align: center;
}

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

.crop-event-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-primary);
  padding: 6px 10px;
  background: rgba(139, 92, 246, 0.08);
  border-radius: var(--radius-sm);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crop-apply-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.crop-apply-btns .btn {
  flex: 1;
  justify-content: center;
}

/* Crop divider */
.crop-divider {
  border-top: 1px solid var(--border-color);
  margin: 10px 0;
}

/* Text style row: label | slider | value | align buttons */
.text-style-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.text-style-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 58px;
  flex-shrink: 0;
}

.range-slider.range-sm {
  flex: 1;
  min-width: 60px;
  height: 4px;
}

.range-value-sm {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

/* Alignment buttons */
.align-btns {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.align-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.align-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.align-btn.active {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-primary);
}

/* Card layout toggle buttons */
.card-layout-toggle {
  display: flex;
  gap: 6px;
}

.layout-btn {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.layout-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.layout-btn.active {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-primary);
}

/* Event image with crop highlight */
.modal-slide-container .event-image-wrap {
  cursor: pointer;
  transition: outline 0.2s ease, box-shadow 0.2s ease;
  outline: 3px solid transparent;
  position: relative;
}

.modal-slide-container .event-image-wrap::after {
  content: '⤡';
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-slide-container .event-image-wrap:hover::after {
  opacity: 1;
}

.modal-slide-container .event-image-wrap:hover {
  outline-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
  cursor: nwse-resize;
}

.modal-slide-container .event-image-wrap.crop-active {
  outline-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

/* ============================
   VERTICAL CARD LAYOUT
   ============================ */
.event-card.layout-vertical {
  flex-direction: column;
  align-items: stretch;
}

.event-card.layout-vertical .event-image-wrap {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* Vertical card alignment is controlled via inline styles (JS) */

/* ============================
   VENUE AVATAR
   ============================ */
.venue-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(139, 92, 246, 0.4);
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

/* ============================
   ADAPTIVE EVENT CARDS
   ============================ */

/* ---- TWO-COLUMN GRID ---- */
.events-list.events-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
}

/* ---- COMPACT (6-10 events, two col) ---- */
/* Available per card: ~492px wide × ~170px tall (5 rows) */
.events-list.events-compact .event-card {
  padding: 12px 14px;
  gap: 14px;
  border-radius: 14px;
}

.events-list.events-compact .event-image-wrap {
  width: 140px;
  height: 100px;
  border-radius: 10px;
}

.events-list.events-compact .event-name {
  font-size: 19px;
  line-height: 1.15;
}

.events-list.events-compact .event-venue {
  font-size: 15px;
  gap: 6px;
}

.events-list.events-compact .event-address {
  font-size: 13px;
  gap: 5px;
}

.events-list.events-compact .event-datetime {
  font-size: 14px;
  margin-top: 1px;
  gap: 5px;
}

.events-list.events-compact .event-info {
  gap: 4px;
}

.events-list.events-compact .event-icon {
  font-size: 15px;
}

.events-list.events-compact .venue-avatar {
  width: 26px;
  height: 26px;
  border-width: 2px;
}

.events-list.events-compact .event-image-placeholder {
  font-size: 28px;
}

/* ---- ULTRA COMPACT (11-12 events, two col) ---- */
/* Available per card: ~492px wide × ~140px tall (6 rows) */
.events-list.events-ultra-compact .event-card {
  padding: 10px 12px;
  gap: 12px;
  border-radius: 12px;
}

.events-list.events-ultra-compact .event-image-wrap {
  width: 115px;
  height: 82px;
  border-radius: 8px;
}

.events-list.events-ultra-compact .event-name {
  font-size: 16px;
  line-height: 1.15;
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

.events-list.events-ultra-compact .event-venue {
  font-size: 13px;
  gap: 5px;
}

.events-list.events-ultra-compact .event-address {
  font-size: 12px;
  gap: 4px;
}

.events-list.events-ultra-compact .event-datetime {
  font-size: 13px;
  margin-top: 0;
  gap: 4px;
}

.events-list.events-ultra-compact .event-info {
  gap: 3px;
}

.events-list.events-ultra-compact .event-icon {
  font-size: 13px;
}

.events-list.events-ultra-compact .venue-avatar {
  width: 22px;
  height: 22px;
  border-width: 2px;
}

.events-list.events-ultra-compact .event-image-placeholder {
  font-size: 24px;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 900px) {
  .header-inner {
    flex-direction: column;
    gap: 12px;
  }

  .modal-body {
    flex-direction: column;
  }

  .modal-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: 300px;
  }

  .modal-slide-container {
    width: 340px;
    height: 340px;
  }

  .modal-slide-container .slide-canvas {
    transform: scale(calc(340 / 1080));
  }

  .slides-row {
    justify-content: center;
  }

  .slide-preview,
  .slide-preview-container {
    width: 300px;
    height: 300px;
  }

  .slide-preview .slide-canvas {
    transform: scale(calc(300 / 1080));
  }
}