/* ============================================================
   STACKD — builder.css
   Styles specific to the page builder UI
   ============================================================ */

/* ── BUILDER LAYOUT ── */
.builder-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 1rem;
}

/* ── TAB BAR ── */
.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 56px;
  z-index: 10;
}

.tab-btn {
  padding: 0.82rem 0.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.66rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
}

.tab-btn .tab-icon { font-size: 1.05rem; }
.tab-btn.active    { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ── TAB PANELS ── */
.tab-panel { display: none; padding: 1.25rem; }
.tab-panel.active { display: block; animation: fadeUp 0.2s ease; }

/* ── LINK CARDS ── */
.link-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
  margin-bottom: 0.75rem;
  position: relative;
  animation: fadeUp 0.2s ease;
}

.link-card:last-of-type { margin-bottom: 0; }

.link-card-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.link-card-row:last-child { margin-bottom: 0; }

.emoji-inp {
  width: 52px !important;
  flex: none !important;
  text-align: center;
  font-size: 1.1rem;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.link-del-btn {
  position: absolute;
  top: 0.72rem;
  right: 0.72rem;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: rgba(239,68,68,0.1);
  border: none;
  color: var(--danger);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  line-height: 1;
}

.link-del-btn:hover { background: rgba(239,68,68,0.22); }

.add-link-btn {
  width: 100%;
  padding: 0.78rem;
  background: rgba(168,85,247,0.05);
  border: 1.5px dashed rgba(168,85,247,0.25);
  border-radius: var(--radius-lg);
  color: var(--accent);
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 0.75rem;
}

.add-link-btn:hover {
  background: rgba(168,85,247,0.1);
  border-color: var(--accent);
}

/* ── THEME GRID ── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.theme-swatch {
  height: 42px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.theme-swatch:hover { transform: scale(1.05); }

.theme-swatch.active {
  border-color: #fff;
  transform: scale(1.08);
}

.theme-swatch.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* ── LIVE PREVIEW ── */
.preview-outer {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg);
  padding: 1.25rem;
  margin-top: 1rem;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.preview-phone-wrap {
  display: flex;
  justify-content: center;
}

.preview-phone {
  width: 200px;
  min-height: 320px;
  border-radius: 28px;
  padding: 14px 12px 20px;
  border: 1px solid var(--border);
  transition: background 0.3s;
  position: relative;
}

/* Phone screen elements */
.pp-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--grad);
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: background 0.3s;
  overflow: hidden;
}

.pp-name {
  text-align: center;
  font-weight: 800;
  font-size: 0.88rem;
  margin-bottom: 2px;
  transition: color 0.2s;
}

.pp-bio {
  text-align: center;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  margin: 0 6px 12px;
  line-height: 1.4;
}

.pp-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 6px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.pp-link:hover { transform: scale(1.02); }
.pp-link:last-child { margin-bottom: 0; }

/* ── PUBLISH TAB ── */
.publish-card {
  background: var(--grad-subtle);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.publish-card h3 { margin-bottom: 0.35rem; }
.publish-card p  { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.5; }

.url-row { display: flex; gap: 0.5rem; }

.url-row input {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.62rem 0.8rem;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.76rem;
  outline: none;
}

.copy-btn {
  padding: 0.62rem 1rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.76rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.copy-btn:hover  { background: #9333EA; }
.copy-btn.copied { background: var(--success); }

.share-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

.share-chip {
  padding: 0.46rem 0.88rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.76rem;
  cursor: pointer;
  transition: var(--transition);
}

.share-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ── UPSELL BOX ── */
.upsell-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
}

.upsell-box h3 { margin-bottom: 0.35rem; }
.upsell-box p  { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.5; }

/* ── LINK COUNT BADGE ── */
.link-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 0.4rem;
}

.link-count.at-limit { color: var(--warning); border-color: rgba(245,158,11,0.3); }
