/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* Generador de códigos QR — estilos, con tema claro y oscuro */

:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #eaf0f7;
  --border: #d2dbe6;
  --text: #16212e;
  --text-soft: #56657a;
  --accent: #1d5fbf;
  --accent-text: #ffffff;
  --accent-soft: #e2ecfa;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --shadow: 0 1px 3px rgba(12, 30, 60, .12);
  --radius: 8px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0f151d;
  --surface: #17202b;
  --surface-2: #1f2a37;
  --border: #2d3a4a;
  --text: #e5ecf4;
  --text-soft: #9fb0c3;
  --accent: #7fb0ff;
  --accent-text: #0f151d;
  --accent-soft: #1e2f47;
  --warn: #ffd27a;
  --warn-soft: #3a2f16;
  --danger: #ff8a80;
  --danger-soft: #3a1f1d;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.iconos { display: none; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

a { color: var(--accent); }

.visualmente-oculto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Cabecera --- */

.cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.marca {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.lema {
  margin: 2px 0 0;
  font-size: .9rem;
  color: var(--text-soft);
}

.herramientas {
  display: flex;
  gap: 4px;
}

.tb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.tb:hover { background: var(--surface-2); }
.tb:focus-visible, .btn:focus-visible, .tipos button:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 170px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}

.menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu button:hover { background: var(--accent-soft); }
.menu button[aria-checked="true"] { font-weight: 600; color: var(--accent); }

/* --- Cuerpo --- */

.principal {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.tipos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}

.tipos button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}

.tipos button:hover { background: var(--surface-2); }

.tipos button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.grupo {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.grupo[hidden] { display: none; }

.fila {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: .95rem;
  min-width: 0;
}

.campo small {
  font-weight: 400;
  color: var(--text-soft);
}

input[type="text"], input[type="url"], input[type="email"], input[type="tel"],
input[type="password"], input[type="datetime-local"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

textarea { resize: vertical; min-height: 80px; }

.con-boton { position: relative; display: block; }
.con-boton input { padding-right: 44px; }
.tb-dentro {
  position: absolute;
  top: 50%;
  right: 3px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  color: var(--text-soft);
}

.campo-desactivado { opacity: .5; }

.casilla {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.casilla input { width: 18px; height: 18px; accent-color: var(--accent); }

.ayuda {
  margin: 0 0 10px;
  font-size: .9rem;
  color: var(--text-soft);
}

.aviso-campo {
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--warn-soft);
  color: var(--warn);
}

.aviso-campo[hidden] { display: none; }

.enlace-icono {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .95rem;
}

.enlace-icono[hidden] { display: none; }

.error {
  margin: 4px 0 0;
  padding: 8px 12px;
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: .95rem;
}

.acciones-form {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn-secundario {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
  font-weight: 400;
}

.btn-secundario:hover { background: var(--surface-2); filter: none; }

/* --- Resultado --- */

.panel-resultado {
  position: sticky;
  top: 20px;
}

.lienzo {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  max-width: 340px;
  margin: 0 auto;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.lienzo.con-qr {
  border-style: solid;
  background: #ffffff;
}

.vacio {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: var(--text-soft);
}

/* El código se ve siempre oscuro sobre blanco: así lo leen todas las cámaras. */
.qr {
  width: 100%;
  height: 100%;
  padding: 10px;
}

.qr svg { width: 100%; height: 100%; display: block; }

/* El dibujo del código no hereda el trazo de los iconos. */
svg.codigo { stroke: none; }

.estado {
  min-height: 1.45em;
  margin: 10px 0;
  font-size: .9rem;
  text-align: center;
  color: var(--text-soft);
}

.estado.aviso {
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--warn-soft);
  color: var(--warn);
}

.estado.peligro {
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
}

.acciones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* --- Pie --- */

.pie {
  padding: 10px 20px;
  text-align: center;
  font-size: .85rem;
  color: var(--text-soft);
}

.pie p { margin: 0; }

/* --- Vista grande --- */

.grande {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: #ffffff;
  color: #111111;
}

.grande[hidden] { display: none; }

.grande-qr {
  width: min(88vw, calc(100vh - 140px));
  width: min(88vw, calc(100dvh - 140px));
  aspect-ratio: 1;
}

.grande-qr svg { width: 100%; height: 100%; display: block; }

.grande-texto {
  max-width: 90vw;
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.8rem);
  text-align: center;
  overflow-wrap: anywhere;
}

.grande-texto:empty { display: none; }

.tb-cerrar {
  position: absolute;
  top: 12px;
  right: 12px;
  color: #111111;
}

.tb-cerrar:hover { background: #eeeeee; }

/* --- Ventanas y avisos --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .45);
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  padding: 20px 22px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}

.modal h2 { margin-top: 0; font-size: 1.15rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}

.toast[hidden] { display: none; }

/* --- Pantallas estrechas --- */

@media (max-width: 820px) {
  .principal {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px;
    gap: 14px;
  }

  .panel-resultado { position: static; }
}

@media (max-width: 520px) {
  .cabecera { padding: 10px 14px; }
  .lema { display: none; }
  .tipos { grid-template-columns: repeat(3, 1fr); }
  .fila { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .panel { padding: 14px; }
}
