/* ==========================================================================
   Generador / Decodificador QR — Estilos mobile-first
   ========================================================================== */

:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-muted: #9aa0a9;
  --accent: #4f8cff;
  --accent-2: #6aa6ff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --success: #34d186;
  --danger: #ff5d5d;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --maxw: 720px;
  --header-h: 56px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* evita scroll horizontal por el drawer */
  overflow-x: hidden;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.menu-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.menu-btn:hover { background: var(--bg-elev-2); }
.menu-btn svg { width: 20px; height: 20px; }

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand span { color: var(--accent); }

/* ---------- Drawer (menú lateral) ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 90;
}
.scrim.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(82vw, 300px);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 6px;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.drawer__title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.drawer__close {
  width: 34px; height: 34px;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; border-radius: 8px; font-size: 1.3rem; line-height: 1;
}
.drawer__close:hover { background: var(--bg-elev-2); color: var(--text); }

.drawer__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
}
.drawer__link:hover { background: var(--bg-elev-2); text-decoration: none; }
.drawer__link.active { background: var(--accent-soft); color: var(--accent-2); }
.drawer__link svg { width: 20px; height: 20px; flex: 0 0 auto; }

.drawer__sep { height: 1px; background: var(--border); margin: 8px 0; }
.drawer__foot { color: var(--text-muted); font-size: 0.8rem; padding: 8px 12px; }

/* ---------- Main ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.page-subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

/* ---------- Cards / formularios ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  position: relative;
}
.label-row .label { margin-bottom: 0; }

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
}
.info-btn:hover { color: var(--accent-2); }
.info-btn svg { width: 16px; height: 16px; }

.info-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  max-width: 280px;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
}
.info-pop[hidden] { display: none; }
.info-pop strong { color: var(--accent-2); }

.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input.invalid, .textarea.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 93, 93, 0.14);
}
.textarea { resize: vertical; min-height: 76px; }

.field-error {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--danger);
}
.field-error[hidden] { display: none; }

/* tipo selector (tabs) */
.tabs {
  position: relative;
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 14px;
  overflow: visible;
}
.tab {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--accent); color: #fff; }

/* Botón "Más" y menú desplegable de tabs */
.tab-more { display: inline-flex; align-items: center; gap: 2px; }
.tab-more[hidden] { display: none; }
.tab-more svg { width: 12px; height: 12px; }
.tab-more.active { background: var(--accent); color: #fff; }

.tab-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 150px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tab-menu[hidden] { display: none; }
.tab-menu__item {
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.tab-menu__item:hover { background: var(--bg); }
.tab-menu__item.active { background: var(--accent-soft); color: var(--accent-2); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}
.btn:hover { background: #272c37; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn--ghost { background: transparent; }
.btn svg { width: 18px; height: 18px; }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Resultado QR ---------- */
.qr-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 4px 0 10px;
  text-align: center;
}
#qr-out {
  display: block;
  text-align: center;
  margin-top: 8px;

}
.qr-canvas-wrap {
  background: #fff;
  padding: 14px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin: 0 auto;
}
.qr-canvas-wrap img,
.qr-canvas-wrap canvas { display: block; width: 180px !important; height: 180px !important; max-width: 100%; margin: 0 auto; }
.qr-placeholder { opacity: 0.4; }
.qr-placeholder svg { display: block; width: 180px; height: 180px; max-width: 100%; margin: 0 auto; }

.qr-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 28px 8px;
  font-size: 0.92rem;
}

/* ---------- Decodificador ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { color: var(--text); display: block; margin-bottom: 4px; }
.dropzone svg { width: 34px; height: 34px; margin-bottom: 8px; }

.result-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  word-break: break-all;
}
.result-box.is-link a { font-weight: 600; }
.result-box .result-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.result-box .result-value { font-size: 1.05rem; }

.preview-img {
  margin-top: 14px;
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 200;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--success); }
.toast.err { border-color: var(--danger); }

/* ---------- Contenido SEO ---------- */
.seo-content {
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}
.seo-content h2 {
  color: var(--text);
  font-size: 1.15rem;
  margin: 22px 0 8px;
}
.seo-content p { margin: 0 0 12px; }
.seo-content ul { margin: 0 0 12px; padding-left: 20px; }
.seo-content li { margin-bottom: 4px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 18px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.site-footer a { color: var(--text-muted); }

/* ---------- Desktop >= 720px ---------- */
@media (min-width: 720px) {
  .page-title { font-size: 1.8rem; }
  main { padding: 36px 24px 64px; }
  .qr-canvas-wrap img, .qr-canvas-wrap canvas { width: 220px !important; height: 220px !important; }
  .qr-placeholder svg { width: 220px; height: 220px; }
}

/* ---------- Accesibilidad ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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