/* ============================================================
   Smart QR Code Generator — styles.css
   Streamlined single-viewport layout, modern dark + light themes
   ============================================================ */

/* ---------- Theme tokens (dark default) ---------- */
:root,
[data-theme="dark"] {
  --bg: #0a0d12;
  --bg-2: #0f141b;
  --surface: rgba(20, 26, 34, 0.72);
  --surface-solid: #141a22;
  --surface-2: #1b222c;
  --surface-border: rgba(255, 255, 255, 0.08);
  --text: #e7edf3;
  --text-soft: #9aa6b2;
  --text-faint: #8593a3;
  --accent: #2dd4bf;
  --accent-2: #22d3ee;
  --accent-3: #38bdf8;
  --grad: linear-gradient(135deg, #2dd4bf 0%, #22d3ee 100%);
  --grad-soft: linear-gradient(135deg, rgba(45,212,191,.14), rgba(34,211,238,.10));
  --danger: #f87171;
  --success: #34d399;
  --ring: rgba(45, 212, 191, 0.32);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.65);
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --header-h: 62px;
  --footer-h: 46px;
}

[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-2: #eef1f5;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-2: #f3f5f8;
  --surface-border: rgba(15, 23, 32, 0.10);
  --text: #0f1720;
  --text-soft: #475569;
  --text-faint: #64748b;
  --accent: #0d9488;
  --accent-2: #0891b2;
  --accent-3: #0284c7;
  --grad: linear-gradient(135deg, #0d9488 0%, #0891b2 100%);
  --grad-soft: linear-gradient(135deg, rgba(13,148,136,.10), rgba(8,145,178,.08));
  --danger: #dc2626;
  --success: #16a34a;
  --ring: rgba(13, 148, 136, 0.22);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, 0.14);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(45,212,191,.10), transparent 60%),
    radial-gradient(900px 500px at 105% 0%, rgba(56,189,248,.08), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s ease, color .35s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Faint dot-grid texture for depth */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(var(--surface-border) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: .5;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
}
.site-header, .app, .site-footer { position: relative; z-index: 1; }

h1, h2, h3 { line-height: 1.18; margin: 0; letter-spacing: -0.02em; font-family: "Sora", sans-serif; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
em { font-style: normal; color: var(--text-faint); font-size: .85em; }

.grad-text,
.brand-accent {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-sm { padding: 8px 14px; font-size: .88rem; }

/* Keyboard focus visibility */
.btn:focus-visible,
.swatch:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#resetBtn:hover { background: transparent; color: var(--danger); }

.btn-primary {
  background: var(--accent);
  color: #04201c;
  box-shadow: 0 8px 22px var(--ring);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 30px var(--ring); filter: brightness(1.05); }

.btn-secondary {
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--grad-soft); color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  flex: none;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(16px, 4vw, 32px);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--surface-border);
}

.brand { display: flex; align-items: center; gap: 10px; font-family: "Sora", sans-serif; font-weight: 800; font-size: 1.18rem; letter-spacing: -0.01em; }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--grad); color: #fff;
  box-shadow: 0 6px 16px var(--ring);
}

.theme-toggle {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: var(--surface-solid);
  color: var(--text); cursor: pointer;
  display: grid; place-items: center;
  transition: transform .2s, border-color .2s, color .2s;
}
.theme-toggle:hover { transform: rotate(-12deg); color: var(--accent); border-color: var(--accent); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ---------- App (fills viewport between header & footer) ---------- */
.app {
  flex: 1 1 auto;
  min-height: 0;
  padding: clamp(14px, 2.4vw, 26px);
}
.app-grid {
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 0.92fr;
  gap: clamp(16px, 2vw, 26px);
  align-items: stretch;
}

.panel {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  animation: panelIn .6s cubic-bezier(.22,1,.36,1) forwards;
}
.left-panel { animation-delay: .05s; }
.right-panel { animation-delay: .16s; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* Left panel scrolls internally if needed */
.left-panel { display: flex; }
.panel-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: clamp(18px, 2.4vw, 28px);
}
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 99px; }

.field-block { margin-bottom: 20px; }
.field-block:last-child { margin-bottom: 0; }
.block-label {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-weight: 600; font-size: .72rem; margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--text-faint);
}
.block-label em { text-transform: none; letter-spacing: 0; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 7px; font-size: .9rem; font-weight: 600; color: var(--text-soft); flex: 1; }
.field-row { display: flex; gap: 14px; }
.field-row .field { min-width: 0; }

input[type="text"], input[type="url"], input[type="email"], input[type="tel"],
textarea, select {
  font: inherit; font-weight: 500; font-size: .95rem;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  background: var(--surface-solid);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
#url-link {
  font-family: "JetBrains Mono", monospace;
  font-size: .95rem; padding: 15px 16px;
  letter-spacing: -0.01em;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring);
}
/* Kill the browser autofill / password-manager white background so inputs
   keep the dark theme. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-solid) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-out 0s;
}
textarea { resize: vertical; min-height: 56px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.checkbox-field { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text-soft); font-size: .92rem; cursor: pointer; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* Color swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.swatch {
  width: 40px; height: 40px; flex: none; border-radius: 11px; cursor: pointer;
  background: var(--c);
  border: 2px solid var(--surface-border);
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.color-field input[type="color"] {
  width: 100%; height: 44px; padding: 4px; cursor: pointer;
  border-radius: var(--radius-sm);
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 999px; padding: 0;
  background: var(--grad); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: var(--shadow-sm); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: pointer;
}

.field-error { color: var(--danger); font-size: .85rem; font-weight: 600; margin-top: 8px; min-height: 1em; }
.field-hint { margin-top: 8px; font-size: .82rem; color: var(--text-faint); font-weight: 500; }
.field-hint strong { color: var(--text-soft); font-weight: 700; }

/* Type tabs */
.type-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.type-tab {
  font: inherit; font-weight: 600; font-size: .8rem;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  background: var(--surface-solid);
  color: var(--text-soft);
  transition: border-color .2s, color .2s, background .2s, transform .15s;
}
.type-tab svg { color: var(--text-faint); transition: color .2s; }
.type-tab:hover { transform: translateY(-2px); border-color: var(--accent); }
.type-tab.active {
  border-color: var(--accent);
  background: var(--grad-soft);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
.type-tab.active svg { color: var(--accent); }
.type-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Password reveal — masked via CSS (plain text input = no password-manager
   white background, identical look to the SSID box). */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap input { width: 100%; padding-right: 46px; }
.pw-input { -webkit-text-security: disc; text-security: disc; }
.pw-input.revealed { -webkit-text-security: none; text-security: none; }
.pw-wrap .pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  border: none; background: transparent; color: var(--text-faint);
  cursor: pointer; border-radius: 8px; transition: color .2s, background .2s;
}
.pw-toggle:hover { color: var(--accent); background: var(--grad-soft); }
.pw-toggle.revealed { color: var(--accent); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Accordion */
.accordion { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.accordion-item {
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  overflow: hidden;
}
.accordion-head {
  width: 100%; font: inherit; font-weight: 700; font-size: .98rem;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: transparent; border: none; color: var(--text);
  cursor: pointer; transition: background .2s;
}
.accordion-head:hover { background: var(--grad-soft); }
.chev { transition: transform .28s ease; color: var(--text-faint); }
.accordion-item.open .chev { transform: rotate(180deg); }
.accordion-body {
  max-height: 0; overflow: hidden;
  transition: max-height .35s ease, padding .35s ease;
  padding: 0 18px;
}
.accordion-item.open .accordion-body { max-height: 720px; padding: 4px 18px 20px; }
.accordion-body .field { margin-top: 14px; }
.accordion-body .field-row { margin-top: 14px; }
.accordion-body .field-row .field { margin-top: 0; }
.accordion-body .checkbox-field { margin-top: 14px; }

/* Logo upload */
.upload-drop {
  display: flex; align-items: center; gap: 16px;
  padding: 16px; border-radius: var(--radius);
  border: 2px dashed var(--surface-border);
  cursor: pointer; transition: border-color .2s, background .2s; color: var(--text-soft);
}
.upload-drop:hover { border-color: var(--accent); background: var(--grad-soft); }
.upload-thumb {
  width: 56px; height: 56px; flex: none; border-radius: 12px;
  display: grid; place-items: center; overflow: hidden;
  background: var(--grad-soft); color: var(--accent);
}
.upload-thumb img { width: 100%; height: 100%; object-fit: contain; }
.upload-text { font-size: .9rem; font-weight: 600; }

/* Download */
.download-block { margin-bottom: 0; }
.download-row { display: flex; flex-wrap: wrap; gap: 10px; }
.download-row .btn { flex: 1 1 auto; min-width: 72px; }
.toast {
  margin-top: 12px; font-size: .9rem; font-weight: 600; min-height: 1em;
  opacity: 0; transform: translateY(-4px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { color: var(--success); }
.toast.error { color: var(--danger); }

/* ---------- Right panel / preview ---------- */
.right-panel {
  display: flex; flex-direction: column; gap: 16px;
  padding: clamp(18px, 2.4vw, 28px);
  overflow-y: auto;
}
.qr-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex; align-items: stretch; justify-content: center;
  padding: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-border);
  background:
    repeating-conic-gradient(var(--bg-2) 0% 25%, transparent 0% 50%) 50% / 20px 20px,
    var(--surface-2);
  overflow: hidden;
}
/* corner brackets — instrument framing */
.qr-stage::before, .qr-stage::after {
  content: ""; position: absolute; width: 20px; height: 20px; pointer-events: none;
  border: 2px solid var(--accent); opacity: .55;
}
.qr-stage::before { top: 14px; left: 14px; border-right: none; border-bottom: none; border-top-left-radius: 6px; }
.qr-stage::after { bottom: 14px; right: 14px; border-left: none; border-top: none; border-bottom-right-radius: 6px; }
.qr-canvas {
  display: flex; align-items: center; justify-content: center;
  min-height: 0; min-width: 0; max-width: 100%;
}
.qr-canvas canvas, .qr-canvas svg {
  display: block;
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain;
  border-radius: 10px; box-shadow: 0 12px 36px rgba(0,0,0,.45);
}
.qr-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-faint); text-align: center; pointer-events: none;
}
.qr-placeholder p { font-weight: 600; font-size: .92rem; }
.qr-stage.has-qr .qr-placeholder { display: none; }

.qr-info {
  flex: none;
  background: var(--surface-solid); border: 1px solid var(--surface-border);
  border-radius: var(--radius); padding: 14px 18px; display: flex; flex-direction: column; gap: 10px;
}
.qr-info-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; font-size: .85rem; }
.qr-info-row span {
  font-family: "JetBrains Mono", monospace; font-size: .68rem;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-faint); font-weight: 600; flex: none;
}
.qr-info-row strong { font-family: "JetBrains Mono", monospace; font-weight: 500; font-size: .82rem; text-align: right; color: var(--text-soft); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }

.scan-reminder {
  flex: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: .9rem; color: var(--text-soft);
  padding: 12px; border-radius: var(--radius); background: var(--grad-soft);
  border: 1px solid var(--surface-border);
}
.scan-reminder svg { color: var(--accent); flex: none; }

/* ---------- Footer ---------- */
.site-footer {
  flex: none;
  height: var(--footer-h);
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: .88rem; color: var(--text-faint);
  border-top: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}
.site-footer a {
  font-weight: 700;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  transition: opacity .2s;
}
.site-footer a:hover { opacity: .8; text-decoration: underline; }

/* ---------- Tooltips ---------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--text); color: var(--bg);
  padding: 6px 10px; border-radius: 8px; font-size: .76rem; font-weight: 600;
  white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity .2s, transform .2s; z-index: 200;
  box-shadow: var(--shadow);
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.field em[data-tip] { cursor: help; color: var(--accent); font-weight: 700; }

/* Right-edge tooltip (theme toggle) anchors to its right so it never clips */
.theme-toggle[data-tip]::after { left: auto; right: 0; transform: translateY(4px); }
.theme-toggle[data-tip]:hover::after { transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  body { overflow: auto; }
  .app { padding: 16px; }
  .app-grid { display: flex; flex-direction: column; height: auto; }
  .right-panel { order: -1; }   /* show the live preview first on mobile */
  .panel { overflow: visible; }
  .left-panel, .right-panel { overflow: visible; }
  .panel-scroll { overflow: visible; }
  .qr-stage { min-height: 300px; }
}
@media (max-width: 480px) {
  .field-row { flex-direction: column; gap: 14px; }
  .download-row .btn { flex: 1 1 calc(50% - 10px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
