/* Panel de TekyTap. Valores del kit de marca de Tekysoft
   (agency_tekysoft/docs/brand/tekysoft-brand-kit.md): Manrope, navy, azul como
   único acento en modo claro, verde solo para "correcto", escala Slate, radios
   8/12/16 y sin gradientes. Sin compilación: este fichero se sirve tal cual.

   Pensado primero para el teléfono, donde se usa como una app: barra de pestañas
   abajo, botones de 48 px y zonas seguras de la pantalla. Desde 840 px la misma
   barra sube a la cabecera. */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('../fonts/manrope-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('../fonts/manrope-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --navy: #0A2540;
  --blue: #2563EB;
  --blue-hover: #1D4ED8;
  --green: #10B981;
  --error: #EF4444;
  --danger: #DC2626; /* El rojo de error con texto blanco no llega a 4,5:1; este sí. */
  --warning: #F59E0B;
  --slate-50: #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --slate-700: #334155;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --easing: cubic-bezier(0.4, 0, 0.2, 1);
  --tabbar-height: 64px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--slate-50);
  color: var(--slate-700);
  font: 400 16px/1.5 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

::selection { background: rgba(37, 99, 235, 0.22); color: var(--navy); }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

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

h1, h2 { color: var(--navy); margin: 0; }
h1 { font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 18px; line-height: 26px; font-weight: 600; }

p { margin: 0; }

[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.btn.desktop-only { display: none; }

/* Barra superior */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  padding-top: env(safe-area-inset-top);
}

.appbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 8px; min-height: 40px; text-decoration: none; }
.brand-full { display: none; height: 40px; width: auto; }
.brand-mark { display: block; height: 32px; width: 32px; }
.brand-product { color: var(--navy); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

/* Pestañas: al pie en el teléfono */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #fff;
  border-top: 1px solid var(--slate-200);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-height);
  color: var(--slate-500);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  text-decoration: none;
  touch-action: manipulation;
}

.tab .icon { width: 24px; height: 24px; }
.tab:active { background: var(--slate-50); }
.tab[aria-current=page] { color: var(--blue); }

/* Página */

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 24px) max(16px, env(safe-area-inset-left));
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head-row { flex-wrap: nowrap; align-items: flex-start; }

.page-sub { color: var(--slate-500); font-size: 14px; line-height: 20px; margin-top: 2px; overflow-wrap: anywhere; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  margin: -4px 0 4px;
  color: var(--slate-600);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.back .icon { width: 18px; height: 18px; }

.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.card-narrow { max-width: 560px; }
.card-narrow > .card + .card, [data-controls] > .card + .card { margin-top: 16px; }

.card-danger { border-color: var(--slate-200); }

.split { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }

.stack { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }

.history-card { margin-top: 16px; }
.history { list-style: none; margin: 8px 0 0; padding: 0; }
.history li { font-size: 14px; line-height: 20px; color: var(--navy); padding: 12px 0; border-top: 1px solid var(--slate-100); overflow-wrap: anywhere; }
.history li:last-child { padding-bottom: 0; }
.history-meta { color: var(--slate-500); font-size: 12px; line-height: 16px; font-weight: 500; margin-bottom: 4px; }

/* Botones: 48 px de alto, para el dedo */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 150ms var(--easing), border-color 150ms var(--easing);
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }

.btn-secondary { background: #fff; border-color: var(--slate-300); color: var(--navy); }
.btn-secondary:hover { border-color: var(--slate-400); background: var(--slate-50); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; }

.btn:disabled { background: var(--slate-200); border-color: var(--slate-200); color: var(--slate-500); cursor: not-allowed; }

.btn-small { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.btn-block, .btn-block-mobile { width: 100%; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.actions .btn:not(.btn-small) { flex: 1 1 140px; }

.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--blue);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* Formularios. 16 px en los campos: con menos, el iPhone acerca la página al tocarlos. */

.card-form { margin-top: 16px; }

.field { margin-bottom: 16px; }

label { display: block; color: var(--navy); font-size: 14px; font-weight: 600; margin-bottom: 8px; }

input[type=text], input[type=url], input[type=email], input[type=password] {
  width: 100%;
  min-height: 48px;
  background: #fff;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  color: var(--navy);
  font: inherit;
  font-size: 16px;
  padding: 12px;
}

input::placeholder { color: var(--slate-400); }
input:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
input.has-error { border-color: var(--error); }

.input-code { font-size: 24px !important; font-weight: 700; letter-spacing: 0.3em; text-align: center; }

.hint { color: var(--slate-500); font-size: 14px; line-height: 20px; margin-top: 8px; }

.field-error { color: var(--navy); font-size: 14px; line-height: 20px; margin-top: 8px; font-weight: 500; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--slate-600); margin: 0; }
.check input { width: 20px; height: 20px; }

/* Avisos: el color va en el borde, el texto siempre con contraste. */

.alert {
  display: flex;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--slate-400);
  border-radius: 8px;
  color: var(--navy);
  font-size: 14px;
  line-height: 20px;
  padding: 12px 16px;
  margin-bottom: 16px;
  overflow-wrap: anywhere;
}

.alert-error { border-left-color: var(--error); }
.alert-success { border-left-color: var(--green); }
.alert-warning { border-left-color: var(--warning); }

.alert-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; font-weight: 600; }

/* Códigos y estados */

.code { color: var(--navy); font-weight: 700; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
h1.code { font-size: 32px; line-height: 40px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--slate-200);
  border-radius: 9999px;
  color: var(--slate-600);
  background: #fff;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  padding: 4px 10px;
  white-space: nowrap;
}

.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--slate-400); }
.pill-ok::before { background: var(--green); }

/* Lista de piezas */

.pieces { list-style: none; margin: 0; padding: 0; }

.piece-row {
  display: grid;
  grid-template-columns: 1fr auto 20px;
  align-items: center;
  gap: 4px 12px;
  min-height: 72px;
  padding: 12px 12px 12px 16px;
  border-top: 1px solid var(--slate-100);
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
  transition: background-color 150ms var(--easing);
}

.pieces li:first-child .piece-row { border-top: 0; }
.piece-row:hover, .piece-row:active { background: var(--slate-50); }

.piece-url { grid-column: 1 / 3; color: var(--slate-500); font-size: 14px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.piece-chevron { grid-column: 3; grid-row: 1 / 3; color: var(--slate-400); display: flex; }

.card-flush { padding: 0; overflow: hidden; }

.empty { padding: 32px 24px; }
.empty p + p { margin-top: 8px; color: var(--slate-500); font-size: 14px; }

/* Lo que falta para activar una pieza */

.checklist { list-style: none; margin: 8px 0 0; padding: 0; }

.checklist li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--slate-100); }
.checklist li:first-child { border-top: 0; }
.checklist .icon { margin-top: 2px; color: var(--slate-400); }
.checklist li.done .icon { color: var(--green); }
.checklist strong { display: block; color: var(--navy); font-size: 14px; line-height: 20px; font-weight: 600; }
.checklist span { display: block; color: var(--slate-500); font-size: 14px; line-height: 20px; }

/* Cámara */

.camera {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: 480px;
  background: var(--navy);
  border-radius: 16px;
  overflow: hidden;
}

.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.camera-frame { position: absolute; inset: 16%; pointer-events: none; }

.camera-frame i { position: absolute; width: 32px; height: 32px; border: 0 solid #fff; }
.camera-frame i:nth-child(1) { top: 0; left: 0; border-width: 3px 0 0 3px; border-top-left-radius: 8px; }
.camera-frame i:nth-child(2) { top: 0; right: 0; border-width: 3px 3px 0 0; border-top-right-radius: 8px; }
.camera-frame i:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-bottom-left-radius: 8px; }
.camera-frame i:nth-child(4) { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-bottom-right-radius: 8px; }

.camera-start { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

.camera-status { color: var(--slate-600); font-size: 14px; line-height: 20px; margin-top: 12px; max-width: 480px; min-height: 20px; }

/* Datos de la pieza */

.facts { display: grid; gap: 12px; margin: 12px 0 0; }
.facts-top { margin-top: 0; }
.facts dt { color: var(--slate-500); font-size: 12px; line-height: 16px; font-weight: 500; margin-bottom: 4px; }
.facts dd { color: var(--navy); font-size: 14px; line-height: 20px; font-weight: 600; margin: 0; overflow-wrap: anywhere; }

/* En móvil el botón baja de línea: la URL del NFC no debe partirse a mitad. */
.fact-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.fact-row .btn { flex: none; white-space: nowrap; }

/* Grabador NFC */

.nfc-status {
  margin-top: 16px;
  padding: 16px;
  min-height: 88px;
  display: flex;
  align-items: center;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--slate-400);
  border-radius: 8px;
  color: var(--navy);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.nfc-status[data-kind=wait], .nfc-status[data-kind=busy] { border-left-color: var(--blue); }
.nfc-status[data-kind=ok] { border-left-color: var(--green); }
.nfc-status[data-kind=error] { border-left-color: var(--error); }

.overwrite { margin-top: 16px; font-size: 14px; line-height: 20px; color: var(--navy); overflow-wrap: anywhere; }

/* Modal: sube desde abajo en el teléfono, como una hoja */

.sheet {
  width: 100%;
  max-width: 480px;
  margin: auto auto 0;
  padding: 24px 16px calc(16px + env(safe-area-inset-bottom));
  background: #fff;
  border: 0;
  border-radius: 16px 16px 0 0;
  color: var(--slate-700);
  box-shadow: var(--shadow-md);
}

.sheet::backdrop { background: rgba(10, 37, 64, 0.55); }
.sheet p { margin-top: 12px; font-size: 14px; line-height: 20px; }
.sheet-url { color: var(--navy); font-weight: 600; overflow-wrap: anywhere; }
.sheet-actions { display: grid; gap: 8px; margin-top: 16px; }

/* Entrada */

.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.auth-side {
  background: var(--navy);
  color: var(--slate-300);
  padding: calc(16px + env(safe-area-inset-top)) 16px 16px;
}

.auth-side img { display: block; height: 40px; width: auto; }
.auth-tagline { display: none; }
.auth-product { font-size: 14px; margin-top: 4px; }

.auth-main { flex: 1; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.auth-form { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-form h1 { margin-bottom: 4px; }
.auth-form .page-sub { margin: 0 0 16px; }
.auth-secondary { margin-top: 16px; text-align: center; font-size: 14px; font-weight: 600; }

/* A partir de aquí, pantalla grande */

@media (min-width: 840px) {
  h1 { font-size: 32px; line-height: 40px; }
  h2 { font-size: 20px; line-height: 28px; }
  h1.code { font-size: 36px; line-height: 44px; }

  .btn.desktop-only { display: inline-flex; }

  .appbar-inner { padding: 16px; }
  .brand { gap: 12px; }
  .brand-full { display: block; }
  .brand-mark { display: none; }
  .brand-product { color: var(--slate-500); font-size: 14px; font-weight: 600; padding-left: 12px; border-left: 1px solid var(--slate-200); }

  .tabs {
    position: static;
    display: flex;
    gap: 4px;
    margin-left: auto;
    padding: 0;
    border: 0;
    background: none;
  }

  .tab { flex-direction: row; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: 8px; font-size: 14px; line-height: 20px; }
  .tab .icon { width: 20px; height: 20px; }
  .tab:hover { background: var(--slate-50); color: var(--navy); }
  .tab[aria-current=page] { background: var(--slate-100); }

  .page { padding: 32px 16px 64px; }
  .page-head { margin-bottom: 24px; }
  .back { margin-bottom: 12px; }

  .card { padding: 24px; box-shadow: var(--shadow-md); }
  .split { gap: 24px; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
  .stack { gap: 24px; }
  .history-card { margin-top: 24px; }
  .card-narrow > .card + .card, [data-controls] > .card + .card { margin-top: 24px; }
  .alert { margin-bottom: 24px; }

  .btn-block-mobile { width: auto; }

  .piece-row { grid-template-columns: 96px 148px minmax(0, 1fr) 20px; gap: 16px; min-height: 56px; padding: 12px 16px 12px 24px; }
  .piece-url { grid-column: 3; }
  .piece-chevron { grid-column: 4; grid-row: auto; }

  .sheet { margin: auto; padding: 24px; border-radius: 16px; }
  .sheet-actions { grid-template-columns: 1fr 1fr; }

  .auth { flex-direction: row; }
  .auth-side { flex: 5; padding: 64px 48px; }
  .auth-tagline { display: block; color: #fff; font-size: 36px; line-height: 44px; font-weight: 700; letter-spacing: -0.01em; margin-top: 48px; max-width: 16em; }
  .auth-product { margin-top: 8px; }
  .auth-main { flex: 7; padding: 96px 64px; }
  .auth-form { margin: 0; }
  .auth-secondary { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
