/* ==========================================================
   CodeCaps QR Generator — Brand identity from codecaps.net
   ========================================================== */
:root {
  /* QR Studio — هوية زرقاء سماوية هادئة */
  --ink: #082f49;
  --ink-2: #0c4a6e;
  --brand: #0ea5e9;
  --brand-d: #0284c7;
  --brand-soft: rgba(14, 165, 233, .12);
  --slate: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --bg: #ffffff;
  --bg-soft: #f0f9ff;
  --card: #ffffff;
  --line: #e2edf5;
  --text: #0b2236;
  --text-2: #475569;
  --field: #f5fafd;
  --shadow: 0 1px 2px rgba(8, 47, 73, .04), 0 12px 32px -12px rgba(8, 47, 73, .14);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 32px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --font: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-en: 'Plus Jakarta Sans', 'Cairo', sans-serif;
}

[data-theme="dark"] {
  --bg: #04121e;
  --bg-soft: #071a2a;
  --card: #0a2134;
  --line: rgba(255, 255, 255, .08);
  --text: #eaf5fc;
  --text-2: #b6c7d6;
  --muted: #8aa0b4;
  --field: #0e2a40;
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .3s var(--ease), color .3s var(--ease);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1280px; margin-inline: auto; padding-inline: 2rem; }
.container.narrow { max-width: 820px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.25rem; border-radius: var(--radius-md);
  font-weight: 700; font-size: .95rem; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: .5rem .9rem; font-size: .85rem; border-radius: 10px; }
.btn-primary { background: var(--brand-d); color: #fff; box-shadow: 0 8px 20px -8px rgba(14, 165, 233, .55); }
.btn-primary:hover:not(:disabled) { background: #0369a1; }
.btn-navy { background: var(--ink); color: #fff; }
[data-theme="dark"] .btn-navy { background: #fff; color: var(--ink); }
.btn-navy:hover:not(:disabled) { background: var(--ink-2); }
[data-theme="dark"] .btn-navy:hover:not(:disabled) { background: #e6eef7; }
.btn-ghost { background: var(--field); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); }
.btn-outline-light { border: 1.5px solid rgba(255,255,255,.4); color: #fff; }
.btn-outline-light:hover { background: rgba(255,255,255,.08); }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); color: var(--text);
  transition: border-color .2s;
}
.icon-btn:hover { border-color: var(--brand); }
.icon-btn.sm { width: 32px; height: 32px; font-size: .85rem; }

/* ---------- Brand bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2.2rem; text-align: start; }
.brand { display: inline-flex; align-items: center; gap: .6rem; direction: ltr; }
.brand img { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 8px 18px -8px rgba(2, 132, 199, .6); }
.brand span { font-family: var(--font-en); font-weight: 700; font-size: 1.35rem; letter-spacing: -.02em; color: var(--text); }
.brand b { font-weight: 800; color: var(--brand-d); }
[data-theme="dark"] .brand b { color: var(--brand); }

/* ---------- Hero ---------- */
.hero { padding: 1.4rem 0 2rem; text-align: center; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -40% -10% auto; height: 520px; z-index: -1;
  background: radial-gradient(closest-side, var(--brand-soft), transparent 70%);
}
.hero-badge {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--brand-soft); color: var(--brand-d);
  font-weight: 700; font-size: .85rem; padding: .35rem .9rem; border-radius: 999px;
}
[data-theme="dark"] .hero-badge { color: var(--brand); }
.hero h1 { font-size: clamp(1.9rem, 4.6vw, 3.3rem); font-weight: 900; line-height: 1.3; margin: 1rem 0 .8rem; }
.grad {
  background: linear-gradient(135deg, var(--ink) 20%, var(--brand) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-family: var(--font-en);
}
[data-theme="dark"] .grad { background-image: linear-gradient(135deg, #fff 10%, var(--brand) 90%); }
.hero p { color: var(--text-2); max-width: 640px; margin: 0 auto; font-size: 1.05rem; }
.hero-points { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem 1.5rem; margin-top: 1.4rem; font-weight: 600; color: var(--text-2); font-size: .95rem; }
.hero-points i { color: var(--brand-d); margin-left: .3rem; }

/* ---------- Tool layout ---------- */
.tool { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 1.5rem; align-items: start; padding-bottom: 3rem; }
.editor { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
.preview-col { position: sticky; top: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.1rem; }
.card-head h2 { font-size: 1.15rem; font-weight: 800; }
.step {
  font-family: var(--font-en); font-weight: 800; font-size: .8rem;
  background: var(--ink); color: var(--brand);
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
}
[data-theme="dark"] .step { background: var(--brand); color: var(--ink); }

/* type chips */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: .55rem; margin-bottom: 1.25rem; }
.type-btn {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: .8rem .4rem; border-radius: var(--radius-md);
  background: var(--field); border: 1.5px solid transparent;
  font-weight: 700; font-size: .85rem; color: var(--text-2);
  transition: all .18s var(--ease);
}
.type-btn i { font-size: 1.25rem; color: var(--muted); transition: color .18s; }
.type-btn:hover { border-color: var(--line); color: var(--text); }
.type-btn[aria-selected="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--text); }
.type-btn[aria-selected="true"] i { color: var(--brand-d); }
[data-theme="dark"] .type-btn[aria-selected="true"] i { color: var(--brand); }

/* form */
.content-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.full, .field.grow { grid-column: 1 / -1; }
.field > label { font-weight: 700; font-size: .88rem; color: var(--text-2); }
.field > label .req { color: #f07178; }
.field small.help { color: var(--muted); font-size: .78rem; }
.field input[type=text], .field input[type=url], .field input[type=email], .field input[type=tel],
.field input[type=number], .field input[type=datetime-local], .field select, .field textarea {
  width: 100%; padding: .7rem .9rem; border-radius: var(--radius-md);
  border: 1.5px solid var(--line); background: var(--field);
  transition: border-color .2s, box-shadow .2s; outline: none; font-size: .95rem;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.field input.ltr, .field textarea.ltr { direction: ltr; text-align: left; }
.field input.invalid { border-color: #f07178; }
.input-group { display: flex; gap: .5rem; }
.input-group > :first-child { flex: 1; }
.form-error { margin-top: .8rem; color: #e5484d; font-weight: 600; font-size: .88rem; }

/* accordion */
.acc { border-top: 1px solid var(--line); }
.acc:first-of-type { border-top: 0; }
.acc summary {
  list-style: none; cursor: pointer; padding: .95rem .2rem; font-weight: 800;
  display: flex; align-items: center; gap: .6rem;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary i { color: var(--brand-d); width: 20px; text-align: center; }
[data-theme="dark"] .acc summary i { color: var(--brand); }
.acc summary::after { content: "\f107"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-inline-start: auto; color: var(--muted); transition: transform .2s; }
.acc[open] summary::after { transform: rotate(180deg); }
.acc-body { padding: .2rem .2rem 1.3rem; display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.row > .field { flex: 1 1 180px; }
.actions-inline { display: flex; gap: .5rem; flex-wrap: wrap; }

/* segmented */
.seg { align-self: flex-start; display: inline-flex; flex-wrap: wrap; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 4px; gap: 4px; }
.seg button { padding: .45rem .9rem; border-radius: 9px; font-weight: 700; font-size: .85rem; color: var(--text-2); }
.seg button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(8,47,73,.12); outline: 1.5px solid var(--brand); }

/* color input */
.color-field > div, .color-field { position: relative; }
.color-field { display: grid !important; grid-template-columns: 46px 1fr; grid-template-rows: auto auto; column-gap: .5rem; }
.color-field > label { grid-column: 1 / -1; }
.color-field input[type=color] {
  width: 46px; height: 44px; border-radius: var(--radius-md); border: 1.5px solid var(--line);
  padding: 3px; background: var(--field); cursor: pointer;
}
.color-field input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type=color]::-webkit-color-swatch { border: 0; border-radius: 8px; }
.color-field input[type=color]::-moz-color-swatch { border: 0; border-radius: 8px; }
.color-field .hex { direction: ltr; text-align: left; font-family: var(--font-en); text-transform: uppercase; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; font-size: .9rem; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch span { width: 42px; height: 24px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
[data-theme="dark"] .switch span { background: #173a54; }
.switch span::after { content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(-18px); }

/* range */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; background: var(--line); outline: none; }
[data-theme="dark"] input[type=range] { background: #173a54; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); border: 3px solid var(--card); box-shadow: 0 0 0 1.5px var(--brand); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--brand); border: 3px solid var(--card); box-shadow: 0 0 0 1.5px var(--brand); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); }

/* shape pickers */
.shape-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.shape-btn {
  width: 58px; height: 58px; border-radius: var(--radius-md); background: var(--field);
  border: 1.5px solid var(--line); display: grid; place-items: center; transition: all .15s;
}
.shape-btn { color: var(--text); }
.shape-btn svg { width: 36px; height: 36px; fill: var(--text); }
.shape-btn:hover { border-color: var(--faint); }
.shape-btn.active { border-color: var(--brand); background: var(--brand-soft); }

/* templates */
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .6rem; }
.tpl-btn { border-radius: var(--radius-md); border: 1.5px solid var(--line); padding: 6px; background: #fff; aspect-ratio: 1; transition: all .15s; position: relative; }
.tpl-btn canvas, .tpl-btn img { width: 100%; height: 100%; display: block; }
.tpl-btn:hover { border-color: var(--brand); transform: translateY(-2px); }
.tpl-btn span { position: absolute; bottom: -1.4rem; inset-inline: 0; font-size: .7rem; color: var(--muted); font-weight: 600; }

/* logo */
.logo-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.upload {
  flex: 0 0 170px; border: 2px dashed var(--line); border-radius: var(--radius-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  padding: 1rem; cursor: pointer; text-align: center; transition: border-color .2s, background .2s;
}
.upload:hover, .upload.drag { border-color: var(--brand); background: var(--brand-soft); }
.upload input { display: none; }
.upload i { font-size: 1.6rem; color: var(--brand-d); }
.upload span { font-weight: 700; font-size: .9rem; }
.upload small { color: var(--muted); font-size: .72rem; }
.logo-gallery { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: .45rem; align-content: start; }
.logo-opt { aspect-ratio: 1; border-radius: 10px; border: 1.5px solid var(--line); background: var(--field); padding: 5px; transition: all .15s; }
.logo-opt img { width: 100%; height: 100%; object-fit: contain; }
.logo-opt:hover { border-color: var(--faint); }
.logo-opt.active { border-color: var(--brand); background: var(--brand-soft); }
.logo-opt.none { display: grid; place-items: center; color: var(--muted); font-size: 1.1rem; }

/* frames */
.frame-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: .55rem; }
.frame-btn { aspect-ratio: .82; border-radius: var(--radius-md); border: 1.5px solid var(--line); background: var(--field); padding: 6px; display: grid; place-items: center; transition: all .15s; }
.frame-btn svg { width: 100%; height: 100%; }
.frame-btn.active { border-color: var(--brand); background: var(--brand-soft); }
.frame-btn:hover { border-color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { padding: .3rem .75rem; border-radius: 99px; background: var(--field); border: 1px solid var(--line); font-size: .8rem; font-weight: 600; color: var(--text-2); }
.chip:hover { border-color: var(--brand); color: var(--text); }

.raw-box { display: flex; gap: .5rem; align-items: flex-start; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-md); padding: .6rem .7rem; }
.raw-box code { flex: 1; direction: ltr; text-align: left; font-size: .8rem; white-space: pre-wrap; word-break: break-all; max-height: 140px; overflow: auto; color: var(--text-2); font-family: ui-monospace, Consolas, monospace; }
.tip { color: var(--muted); cursor: help; }

/* ---------- Preview ---------- */
.preview-stage {
  position: relative; border-radius: var(--radius-lg); padding: 1.25rem;
  background:
    repeating-conic-gradient(var(--bg-soft) 0 25%, var(--card) 0 50%) 50% / 18px 18px;
  border: 1px solid var(--line); display: grid; place-items: center; min-height: 300px;
}
#previewCanvas { width: 100%; height: auto; max-width: 340px; display: block; filter: drop-shadow(0 10px 24px rgba(8,47,73,.16)); transition: opacity .2s; }
#previewCanvas.dim { opacity: .25; }
.preview-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; color: var(--muted); font-weight: 700; }
.preview-empty i { font-size: 2.4rem; }
.preview-card { display: flex; flex-direction: column; gap: 1rem; }
.preview-card .card-head { margin-bottom: 0; }
.hint { font-size: .82rem; color: var(--muted); display: flex; gap: .45rem; align-items: center; }
.warn { font-size: .84rem; color: #b45309; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; padding: .55rem .75rem; display: flex; gap: .5rem; align-items: flex-start; }
[data-theme="dark"] .warn { background: rgba(251,146,60,.1); border-color: rgba(251,146,60,.3); color: #fdba74; }
.dl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.dl-grid .btn { padding-inline: .6rem; }
.tiny { font-size: .75rem; color: var(--muted); text-align: center; }

.mobile-jump { display: none; }

/* ---------- Sections ---------- */
.section { padding: 4.5rem 0; }
.section.alt { background: var(--bg-soft); }
.section.how { padding: 1rem 0 2.5rem; }
.how-points { margin-top: 0; }
.how-points li { position: relative; }
.section-head { text-align: center; margin-bottom: 2.5rem; }
.eyebrow { color: var(--brand-d); font-weight: 800; font-size: .9rem; }
[data-theme="dark"] .eyebrow { color: var(--brand); }
.section-head h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 900; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
.step-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.5rem; transition: transform .25s var(--ease), border-color .25s; }
.step-card:hover { transform: translateY(-4px); border-color: var(--brand); }
.step-card .num { font-family: var(--font-en); font-weight: 800; font-size: 2.2rem; line-height: 1; background: linear-gradient(135deg, var(--ink), var(--brand)); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="dark"] .step-card .num { background-image: linear-gradient(135deg, #fff, var(--brand)); }
.step-card h3 { margin: .7rem 0 .3rem; font-size: 1.1rem; font-weight: 800; }
.step-card p, .feature p { color: var(--text-2); font-size: .92rem; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
.feature { background: var(--card); border-radius: var(--radius-lg); padding: 1.5rem; border: 1px solid var(--line); }
.feature i { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--ink); color: var(--brand); font-size: 1.2rem; }
.feature h3 { margin: .9rem 0 .3rem; font-weight: 800; font-size: 1.05rem; }

.faq { display: flex; flex-direction: column; gap: .7rem; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 0 1.2rem; }
.faq summary { cursor: pointer; list-style: none; padding: 1rem 0; font-weight: 800; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--font-en); font-size: 1.3rem; color: var(--brand-d); line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq p { padding-bottom: 1rem; color: var(--text-2); }

.cta { background: linear-gradient(135deg, #082f49, #0c4a6e); color: #fff; padding: 3.5rem 0; position: relative; overflow: hidden; }
.cta::after { content: ""; position: absolute; width: 420px; height: 420px; left: -120px; top: -160px; background: radial-gradient(closest-side, rgba(14,165,233,.3), transparent); }
.cta-inner { display: flex; align-items: center; justify-content: space-between; gap: 2rem; flex-wrap: wrap; position: relative; z-index: 1; }
.cta h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 900; }
.cta p { color: #bae6fd; }
.cta-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

.powered { text-align: center; padding: 1.6rem 16px 2rem; font-size: .85rem; color: var(--muted); font-family: var(--font-en); direction: ltr; }
.powered a { font-weight: 700; color: var(--text-2); border-bottom: 1px dashed var(--faint); }
.powered a:hover { color: var(--brand-d); border-color: var(--brand-d); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 12px; font-weight: 700;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); transition: all .3s var(--ease); z-index: 400; display: flex; gap: .5rem; align-items: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast i { color: var(--brand); }
[data-theme="dark"] .toast { background: #fff; color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .tool { grid-template-columns: minmax(0, 1fr) 340px; }
  .steps, .features { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .container { padding-inline: 16px; }
  .tool { grid-template-columns: 1fr; }
  .preview-col { position: static; }
  #previewCanvas { max-width: 300px; }
  .mobile-jump {
    display: flex; align-items: center; gap: .5rem; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
    background: var(--ink); color: #fff; padding: .75rem 1.3rem; border-radius: 99px; font-weight: 800; z-index: 150;
    box-shadow: 0 10px 30px rgba(8,47,73,.35); transition: opacity .25s, transform .25s;
  }
  .mobile-jump i { color: var(--brand); }
  .mobile-jump.hide { opacity: 0; pointer-events: none; transform: translate(-50%, 20px); }
  [data-theme="dark"] .mobile-jump { background: var(--brand); color: var(--ink); }
  [data-theme="dark"] .mobile-jump i { color: var(--ink); }
}
@media (max-width: 560px) {
  .card { padding: 1.1rem; border-radius: 16px; }
  .content-form { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(3, 1fr); }
  .steps, .features { grid-template-columns: 1fr; }
  .upload { flex: 1 1 100%; }
  .hero { padding-top: 1rem; }
  .topbar { margin-bottom: 1.6rem; }
  .section { padding: 3rem 0; }
  .cta-inner { flex-direction: column; align-items: flex-start; }
}
