/* ==========================================================
   FreeGen - Generator app styles
   ========================================================== */

:root {
  --bg: #0d0d10;
  --surface: #15151a;
  --surface-2: #1e1e24;
  --text: #f2f2f4;
  --text-muted: rgba(242, 242, 244, 0.65);
  --accent: #c600a1;
  --accent-2: #ff2d95;
  --border: rgba(255, 255, 255, 0.1);
  --error: #ff6b6b;
  --radius: 14px;
  --dock-height: 190px;
}

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

body {
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
textarea { font-family: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  backdrop-filter: blur(16px);
  background: rgba(13, 13, 16, 0.75);
  border-bottom: 1px solid var(--border);
}
.topbar__logo { font-weight: 800; font-size: 19px; display: flex; align-items: center; gap: 9px; letter-spacing: -0.02em; }
.topbar__logo-img { display: block; border-radius: 8px; box-shadow: 0 2px 12px rgba(198, 0, 161, 0.4); }
.topbar__logo-ai {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 45, 149, 0.4);
  background: rgba(198, 0, 161, 0.12);
  color: var(--accent-2);
}
.topbar__links { display: flex; gap: 12px; }
.topbar__links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}
.topbar__links a:hover { color: var(--text); }
@media (max-width: 640px) {
  .topbar__badge { display: none; }
}

/* ---------- Stage ---------- */
.stage {
  max-width: 1060px;
  margin: 0 auto;
  padding: 40px 24px calc(var(--dock-height) + 60px);
}

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 56px 0 24px; }
.hero__title {
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 900;
  letter-spacing: -0.02em;
}
.hero__accent {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero__subtitle { color: var(--text-muted); margin-top: 14px; font-size: 17px; }
.hero__subtitle strong { color: var(--text); }

.hero__presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 36px;
}
.preset {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.preset:hover { border-color: rgba(255, 45, 149, 0.6); transform: translateY(-2px); }

/* ---------- Gallery ---------- */
.gallery { display: flex; flex-direction: column; gap: 32px; }

.gen-group { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.gen-group__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.gen-group__status {
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.gen-group__status--running { background: rgba(198, 0, 161, 0.18); color: var(--accent-2); }
.gen-group__status--completed { background: rgba(64, 200, 120, 0.15); color: #4fd18b; }
.gen-group__status--failed { background: rgba(255, 107, 107, 0.15); color: var(--error); }
.gen-group__prompt {
  color: var(--text);
  font-weight: 500;
  max-width: 640px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gen-group__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.gen-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  aspect-ratio: var(--card-ratio, 1 / 1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gen-card--done { cursor: pointer; }
.gen-card--done:hover { transform: translateY(-3px); box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5); }
.gen-card__img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* skeleton shimmer while generating */
.gen-card--loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.07) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.gen-card__spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-card__error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--error);
}

.gen-card__actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.gen-card--done:hover .gen-card__actions { opacity: 1; }
.gen-card__action {
  background: rgba(13, 13, 16, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.gen-card__action:hover { border-color: var(--accent-2); }

.gen-group__retry {
  margin-top: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
}
.gen-group__retry:hover { border-color: var(--accent-2); }

/* ---------- Dock ---------- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 16px 16px 20px;
  background: linear-gradient(180deg, rgba(13, 13, 16, 0) 0%, rgba(13, 13, 16, 0.9) 30%, var(--bg) 100%);
  pointer-events: none;
}
.dock__inner {
  pointer-events: auto;
  max-width: 860px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.dock__prompt {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  padding: 4px 4px 10px;
}
.dock__prompt::placeholder { color: var(--text-muted); }

.dock__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.dock__pills { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pill-wrap { position: relative; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s ease;
}
.pill:hover { border-color: rgba(255, 45, 149, 0.5); }
.pill--model { background: rgb(90, 37, 81); }
.pill__star { color: #ffd166; font-size: 12px; }
.pill__chev { font-size: 10px; opacity: 0.7; }
.pill__ratio-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  opacity: 0.8;
}

.dock__free-tag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent-2);
  padding: 4px 4px;
}

.dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  display: none;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  z-index: 70;
}
.dropdown.is-open { display: block; }
.dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.dropdown__item em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--text-muted); }
.dropdown__item:hover { background: rgba(255, 255, 255, 0.06); }
.dropdown__item.is-active { background: rgba(198, 0, 161, 0.18); }
.ratio-box {
  display: inline-block;
  width: calc(var(--rw) * 1px);
  height: calc(var(--rh) * 1px);
  border: 1.5px solid var(--text-muted);
  border-radius: 3px;
}

.dock__generate {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  border-radius: 999px;
  padding: 12px 32px;
  transition: filter 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 6px 24px rgba(198, 0, 161, 0.4);
}
.dock__generate:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.dock__generate:disabled { opacity: 0.55; cursor: not-allowed; }

.dock__error {
  margin-top: 10px;
  color: var(--error);
  font-size: 13.5px;
  font-weight: 500;
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(6px); }
.modal__content {
  position: relative;
  max-width: min(92vw, 1080px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.modal__img {
  max-width: 100%;
  max-height: calc(90vh - 80px);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}
.modal__close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 15px;
  z-index: 2;
}
.modal__actions { display: flex; gap: 12px; }
.modal__download {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  border-radius: 999px;
  padding: 12px 30px;
  text-decoration: none;
}
.modal__download:hover { filter: brightness(1.1); }

/* ---------- Ad modal ---------- */
.ad-modal__content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px 24px;
  width: min(92vw, 440px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}
.ad-modal__label {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ad-modal__slot {
  width: 100%;
  min-height: 280px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
}
.ad-modal__placeholder {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
}
.ad-modal__placeholder-icon { font-size: 28px; color: var(--accent-2); display: block; margin-bottom: 10px; }
.ad-modal__placeholder-hint { font-size: 12px; margin-top: 6px; opacity: 0.7; }
.ad-modal__placeholder code {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
}
.ad-modal__continue {
  width: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  border-radius: 999px;
  padding: 13px 24px;
  transition: filter 0.15s ease;
}
.ad-modal__continue:hover { filter: brightness(1.12); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .stage { padding-top: 24px; }
  .hero { padding-top: 28px; }
  .topbar__badge { font-size: 10px; padding: 5px 10px; }
  .gen-group__grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .dock__generate { width: 100%; }
}
