/* ===============================================================
   swissAI · Preview-Modal + Download-Modal · shared styles
   Two independent modals, both side-from-right.
   =============================================================== */

/* ───── Side-Modal Base ───── */
.side-modal {
  position: fixed; inset: 0;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.25s, visibility 0.25s;
  font-family: var(--sa-font-sans);
}
.side-modal.open { visibility: visible; opacity: 1; }

.side-modal .overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}

.side-modal .panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  background: var(--sa-bg, #f9f9fb);
  box-shadow: -20px 0 60px rgba(0,0,0,0.3);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.side-modal.open .panel { transform: translateX(0); }

/* Preview panel — wide, mostly iframe */
.side-modal.preview-modal .panel { width: min(95vw, 1280px); }

/* Download panel — narrow form */
.side-modal.download-modal .panel { width: min(95vw, 480px); }

/* ───── Panel head (shared, gradient glow) ───── */
.side-modal .panel-head {
  position: relative;
  padding: 24px 28px 20px;
  background: var(--sa-bg-dark, #121212);
  color: white;
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; gap: 16px;
}
.side-modal .panel-head::before {
  content: "";
  position: absolute;
  inset: -50% -10% auto auto;
  width: 320px; height: 320px;
  background: var(--sa-gradient, linear-gradient(90deg, #EB0000 0%, #B70FFF 100%));
  filter: blur(80px); opacity: 0.45;
  border-radius: 50%;
}
.side-modal .panel-head > * { position: relative; z-index: 1; }

.side-modal .head-text { flex: 1; min-width: 0; }
.side-modal .panel-head .tag {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(255,255,255,0.65);
  margin: 0 0 4px;
}
.side-modal .panel-head h3 {
  color: white;
  font-size: 22px; line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 600;
  margin: 0;
}
.side-modal .panel-head p.sub {
  color: rgba(255,255,255,0.75);
  font-size: 13px; line-height: 1.4;
  margin: 4px 0 0;
}

.side-modal .panel-close {
  width: 36px; height: 36px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: white;
  border-radius: 999px;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
}
.side-modal .panel-close:hover { background: rgba(255,255,255,0.2); }

/* ───── Preview iframe ───── */
.side-modal.preview-modal .preview-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: white;
  min-height: 0;
}

/* ───── Download body (form/success) ───── */
.side-modal.download-modal .panel-body {
  flex: 1;
  padding: 24px 32px 32px;
  overflow-y: auto;
  background: white;
}

.side-modal .field-group { margin-bottom: 18px; }
.side-modal .field-group label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--sa-text, #1a1a1a);
  margin-bottom: 6px;
}
.side-modal .field-group input[type="email"] {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--sa-border, #e0e0e0);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--sa-font-sans);
  color: var(--sa-text, #1a1a1a);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.side-modal .field-group input:focus {
  outline: none;
  border-color: var(--sa-lavender, #b70fff);
  box-shadow: 0 0 0 3px rgba(183, 15, 255, 0.15);
}

.side-modal .check-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0;
  cursor: pointer;
}
.side-modal .check-row input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--sa-lavender, #b70fff);
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.side-modal .check-row span {
  font-size: 14px;
  color: var(--sa-text, #1a1a1a);
  line-height: 1.5;
}
.side-modal .check-row span small {
  display: block;
  color: var(--sa-text-muted, #4a4a4a);
  font-size: 12px;
  margin-top: 2px;
}

.side-modal .panel-submit {
  width: 100%;
  height: 48px;
  background: var(--sa-gradient, linear-gradient(90deg, #EB0000 0%, #B70FFF 100%));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px; font-weight: 600;
  font-family: var(--sa-font-sans);
  cursor: pointer;
  margin-top: 20px;
  box-shadow: 0 12px 32px rgba(183, 15, 255, 0.20);
  transition: transform 0.15s;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
}
.side-modal .panel-submit:hover { transform: translateY(-1px); }
.side-modal .panel-submit svg { width: 16px; height: 16px; }

.side-modal .panel-fineprint {
  font-size: 11px;
  color: var(--sa-text-subtle, #8c8c8c);
  line-height: 1.5;
  margin-top: 12px;
  text-align: center;
}

/* ───── Success state ───── */
.side-modal .panel-success {
  display: none;
  text-align: center;
  padding: 32px 0 12px;
}
.side-modal .panel-success.active { display: block; }
.side-modal .panel-success ~ form { display: block; }
.side-modal .panel-success.active ~ form { display: none; }

.side-modal .panel-success .check {
  width: 56px; height: 56px;
  border-radius: 999px;
  background: var(--sa-gradient, linear-gradient(90deg, #EB0000 0%, #B70FFF 100%));
  color: white;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  font-size: 28px;
}
.side-modal .panel-success h4 {
  font-size: 22px; font-weight: 600;
  color: var(--sa-text, #1a1a1a);
  margin: 0 0 8px;
}
.side-modal .panel-success p {
  color: var(--sa-text-muted, #4a4a4a);
  font-size: 14px; line-height: 1.55;
  margin: 0 auto 24px;
  max-width: 360px;
}
.side-modal .download-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  background: var(--sa-gradient, linear-gradient(90deg, #EB0000 0%, #B70FFF 100%));
  color: white;
  text-decoration: none;
  font-size: 14px; font-weight: 600;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(183, 15, 255, 0.20);
}
.side-modal .download-btn svg { width: 16px; height: 16px; }

/* ───── Floating Download FAB (used on asset pages) ───── */
.dl-fab {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 800;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: var(--sa-gradient, linear-gradient(90deg, #EB0000 0%, #B70FFF 100%));
  color: white;
  text-decoration: none;
  font-size: 14px; font-weight: 600;
  font-family: var(--sa-font-sans);
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(183, 15, 255, 0.30);
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.dl-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(183, 15, 255, 0.40);
}
.dl-fab svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Embed mode (iframe inside preview-modal): hide floating UI */
body.embed-mode .dl-fab,
body.embed-mode .author-line { display: none !important; }

@media (max-width: 600px) {
  .dl-fab { top: auto; bottom: 20px; right: 20px; padding: 12px 16px; font-size: 13px; }
}

@media print {
  .dl-fab, .side-modal { display: none !important; }
}
