/* ============================================================
   BioForge — Builder UI styles
   Palette: slate neutrals + blue primary + emerald accent
   ============================================================ */
:root {
  --bg: #0b1120;
  --panel: #111a2e;
  --panel-2: #16213b;
  --border: #24314f;
  --text: #e6edf7;
  --muted: #8ea0bf;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #10b981;
  --danger: #f43f5e;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

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

html { background: var(--bg); }

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(37, 99, 235, 0.12), transparent),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s;
  color: var(--text);
  background: transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { border-color: var(--border); background: var(--panel-2); }
.btn-ghost:hover { border-color: var(--primary); }
.btn-soft { background: var(--panel-2); border-color: var(--border); }
.btn-soft:hover { border-color: var(--primary); }
.btn-block { width: 100%; justify-content: center; }
.btn-link-danger { color: var(--danger); background: transparent; font-size: 13px; padding: 6px 8px; }
.btn-link-danger:hover { text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  color: #fff;
}
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-tag {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(16, 185, 129, .15); color: var(--accent);
  border: 1px solid rgba(16, 185, 129, .3);
}
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 460px) 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}

/* ---------- Editor ---------- */
.editor {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 78px;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.tab {
  padding: 14px 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
}
.tab i { font-size: 14px; }
.tab:hover { color: var(--text); }
.tab.active { color: #fff; border-bottom-color: var(--primary); background: var(--panel); }

.tab-body { padding: 20px; max-height: calc(100vh - 180px); overflow-y: auto; }
.tab-pane { display: none; animation: fade .2s ease; }
.tab-pane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.pane-intro { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input[type="text"],
.field input[type="url"],
.field textarea,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }
.field textarea { resize: vertical; }
.icon-field > span i { width: 16px; text-align: center; margin-right: 4px; color: var(--primary); }

.input-prefix { display: flex; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.input-prefix span { padding: 0 10px; color: var(--muted); }
.input-prefix input { border: none !important; border-radius: 0 !important; }

.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Avatar ---------- */
.avatar-uploader { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.avatar-preview {
  width: 74px; height: 74px; flex: none;
  border-radius: 50%;
  background: var(--panel-2);
  border: 2px dashed var(--border);
  display: grid; place-items: center;
  color: var(--muted);
  font-size: 24px;
  overflow: hidden;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* ---------- Links list ---------- */
.link-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.link-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}
.link-item .drag { cursor: grab; color: var(--muted); padding: 4px; }
.link-item .link-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.link-item input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; color: var(--text); font-family: inherit; font-size: 13px; outline: none;
}
.link-item input:focus { border-color: var(--primary); }
.link-item .del { color: var(--danger); background: transparent; border: none; cursor: pointer; font-size: 15px; padding: 6px; }
.sortable-ghost { opacity: .4; }
.sortable-chosen { border-color: var(--primary); }

/* ---------- Design tab ---------- */
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 10px; }
.group-title:first-child { margin-top: 0; }

.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.template-card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; align-items: center;
  font-family: inherit; color: var(--text); transition: border-color .15s;
}
.template-card:hover { border-color: var(--primary); }
.template-card.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.tpl-thumb { width: 100%; height: 56px; border-radius: 8px; }
.tpl-glass { background: linear-gradient(135deg, #6366f1, #22d3ee); position: relative; }
.tpl-minimal { background: #f1f5f9; border: 1px solid #cbd5e1; }
.tpl-creator { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.tpl-name { font-size: 12px; font-weight: 600; }
.premium-ico { color: #f59e0b; font-size: 11px; }

.color-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.color-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.color-field input[type="color"] {
  width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); cursor: pointer; padding: 4px;
}

.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented button {
  border: none; background: transparent; color: var(--muted); padding: 9px 16px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.segmented button.active { background: var(--primary); color: #fff; }

.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 14px; }
.switch-row span i { color: var(--primary); margin-right: 6px; }
.switch { appearance: none; width: 44px; height: 24px; background: var(--border); border-radius: 999px; position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- Preview ---------- */
.preview { position: sticky; top: 78px; }
.preview-toolbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-bottom: none; border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 16px;
}
.dot-row { display: flex; gap: 6px; }
.dot-row i { width: 11px; height: 11px; border-radius: 50%; background: var(--border); display: block; }
.dot-row i:first-child { background: #f87171; }
.dot-row i:nth-child(2) { background: #fbbf24; }
.dot-row i:nth-child(3) { background: #34d399; }
.preview-label { font-size: 12px; color: var(--muted); font-weight: 600; }

.preview-stage {
  background:
    linear-gradient(0deg, rgba(255,255,255,.02), rgba(255,255,255,.02)),
    repeating-linear-gradient(45deg, #0d1526 0 10px, #0b1120 10px 20px);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 24px;
  display: flex;
  justify-content: center;
  min-height: 640px;
}
.preview-frame {
  width: 100%;
  max-width: 480px;
  height: 720px;
  border: none;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  transition: max-width .25s ease;
}
.preview-stage.mobile .preview-frame { max-width: 375px; }

/* ---------- Pricing ---------- */
.pricing { max-width: 900px; margin: 40px auto; padding: 0 20px; text-align: center; }
.pricing h2 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.pricing-sub { color: var(--muted); margin: 8px 0 28px; }
.plans { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.plan {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px; text-align: left; position: relative;
}
.plan h3 { font-size: 18px; }
.plan .price { font-size: 36px; font-weight: 800; margin: 8px 0 18px; }
.plan .price span { font-size: 15px; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.plan ul li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.plan ul li i { color: var(--accent); }
.plan ul li.muted { color: var(--muted); }
.plan ul li.muted i { color: var(--muted); }
.plan-pro { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.plan-flag {
  position: absolute; top: -12px; right: 20px;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 700;
  padding: 4px 12px; border-radius: 999px;
}

/* ---------- Footer ---------- */
.app-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 20px 50px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3, 7, 18, .7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 380px; position: relative; box-shadow: var(--shadow);
}
.modal-wide { max-width: 720px; }
.modal-card h3 { font-size: 18px; margin-bottom: 6px; }
.modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal-sub code { background: var(--bg); padding: 2px 6px; border-radius: 6px; color: var(--accent); }
.modal-close { position: absolute; top: 14px; right: 14px; background: transparent; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-card input[type="text"] {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; color: var(--text); font-family: inherit; font-size: 14px; outline: none; margin-bottom: 16px;
}
.qr-holder { display: flex; justify-content: center; padding: 16px; background: #fff; border-radius: 12px; margin-bottom: 16px; min-height: 40px; }
.qr-holder canvas, .qr-holder img { display: block; }
#codeOut { width: 100%; height: 360px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; color: var(--accent); font-family: "Space Grotesk", monospace; font-size: 12px; resize: none; outline: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #04231a; font-weight: 700; font-size: 14px;
  padding: 12px 20px; border-radius: 999px; z-index: 60; box-shadow: var(--shadow);
  animation: toastin .25s ease;
}
.toast[hidden] { display: none; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .editor, .preview { position: static; }
  .plans { grid-template-columns: 1fr; }
  .header-actions .lbl { display: none; }
}
@media (max-width: 520px) {
  .app-header { padding: 10px 12px; }
  .header-actions { gap: 6px; }
  .btn { padding: 9px 11px; }
}

/* ---------- RTL / Arabic support ---------- */
[dir="rtl"] .switch-row span i { margin-right: 0; margin-left: 6px; }
[dir="rtl"] .icon-field > span i { margin-right: 0; margin-left: 4px; }
[dir="rtl"] .switch::after { left: auto; right: 3px; }
[dir="rtl"] .switch:checked::after { transform: translateX(-20px); }
[dir="rtl"] .plan { text-align: right; }
[dir="rtl"] .plan-flag { right: auto; left: 20px; }
[dir="rtl"] .modal-close { right: auto; left: 14px; }
[dir="rtl"] .input-prefix span { border-right: none; }
[dir="rtl"] body,
[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] select,
[dir="rtl"] button { font-family: "Cairo", "Inter", system-ui, sans-serif; }
[dir="rtl"] #codeOut { direction: ltr; text-align: left; }
