/* =========================================================
   native.css — Base nativa y responsiva de Digital Nomade
   Se enlaza DESPUÉS de global.css en todas las pantallas.
   ========================================================= */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Solo vale algo cuando la PWA de escritorio usa la barra de título integrada */
  --titlebar-h: env(titlebar-area-height, 0px);
}

*,
*::before,
*::after {
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  background: #05070a;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Sin zoom por doble toque, pero con scroll y pellizco disponibles */
  touch-action: manipulation;
  /* Comportamiento de app: el texto no se selecciona al tocar */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Campos de texto y contenido marcado como copiable sí se seleccionan */
input,
textarea,
[contenteditable="true"],
.selectable {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

img {
  -webkit-user-drag: none;
}

/* Alto real de pantalla en móviles (barra del navegador que aparece y desaparece) */
#app-body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* Áreas seguras: notch, barra inferior, esquinas redondeadas y barra de título del escritorio */
#app-body,
#pantallaPrevia {
  padding-top: calc(max(1rem, var(--safe-top)) + var(--titlebar-h));
  padding-right: max(1rem, var(--safe-right));
  padding-bottom: max(1rem, var(--safe-bottom));
  padding-left: max(1rem, var(--safe-left));
}

/* Zona arrastrable de la ventana (solo existe con barra de título integrada) */
#titlebar-drag {
  position: fixed;
  top: 0;
  left: env(titlebar-area-x, 0px);
  width: env(titlebar-area-width, 100%);
  height: env(titlebar-area-height, 0px);
  -webkit-app-region: drag;
  app-region: drag;
  z-index: 10001;
}

/* Pantallas táctiles: campos a 16px (iOS no hace zoom al enfocar) y áreas de toque de 44px */
@media (hover: none) and (pointer: coarse) {
  input,
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px;
  }

  button:not(.btn-toggle-pwd),
  [role="button"] {
    min-height: 44px;
  }
}

/* Barras de desplazamiento discretas en notebook y PC */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 118, 0.35) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 118, 0.3);
  border-radius: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* Teléfono en horizontal: compacta el espacio vertical */
@media (orientation: landscape) and (max-height: 500px) {
  #app-body,
  #pantallaPrevia {
    padding-top: calc(max(0.5rem, var(--safe-top)) + var(--titlebar-h));
    padding-bottom: max(0.5rem, var(--safe-bottom));
  }
}

/* =========================================================
   MODO POR DISPOSITIVO (lo marca js/native.js en <html>)
   data-dispositivo = smartphone | tablet | notebook
   data-modo        = app | navegador
   ========================================================= */

/* Alto real de pantalla calculado por native.js (respaldo para navegadores sin dvh) */
html { --alto-app: 100dvh; }

/* Celular y tablet: sin barras de desplazamiento visibles, como una app */
html[data-dispositivo="smartphone"] *,
html[data-dispositivo="tablet"] * {
  scrollbar-width: none;
}
html[data-dispositivo="smartphone"] ::-webkit-scrollbar,
html[data-dispositivo="tablet"] ::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Desplazamiento con inercia dentro de los paneles y modales */
html[data-dispositivo="smartphone"] .overflow-y-auto,
html[data-dispositivo="tablet"] .overflow-y-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Espacio para el teclado en pantalla mientras se escribe */
html.teclado-activo body { padding-bottom: 40vh; }

/* Respuesta táctil inmediata en botones (en táctil no existe hover) */
html[data-dispositivo="smartphone"] button:active,
html[data-dispositivo="tablet"] button:active,
html[data-dispositivo="smartphone"] [role="button"]:active,
html[data-dispositivo="tablet"] [role="button"]:active {
  transform: scale(0.97);
  transition: transform 80ms ease-out;
}

/* Tablet: tarjetas algo más amplias */
html[data-dispositivo="tablet"] #app-content { max-width: 34rem; }

/* App instalada: no hay barra del navegador, el contenido usa toda la pantalla */
html[data-modo="app"] body { min-height: var(--alto-app); }

/* =========================================================
   INSTALADOR (celular y tablet abiertos desde el navegador)
   ========================================================= */
#paw-instalador {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left));
  background: rgba(2, 4, 8, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-family: 'Plus Jakarta Sans', sans-serif;
  animation: paw-entrar 0.3s ease-out;
  transition: opacity 0.3s ease;
}
#paw-instalador.paw-oculto { opacity: 0; pointer-events: none; }
html[data-dispositivo="tablet"] #paw-instalador { align-items: center; }

#paw-instalador .paw-tarjeta {
  width: 100%;
  max-width: 420px;
  background: #0a101a;
  border: 1px solid rgba(0, 240, 118, 0.3);
  border-radius: 1.25rem;
  padding: 1.5rem;
  color: #e2e8f0;
  text-align: center;
  box-shadow: 0 0 40px rgba(0, 240, 118, 0.15);
}
#paw-instalador .paw-logo { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 0.75rem; display: block; }
#paw-instalador h2 { margin: 0 0 0.35rem; font: 700 1rem 'JetBrains Mono', monospace; letter-spacing: 0.05em; color: #fff; text-align: center; }
#paw-instalador p { margin: 0 0 1rem; font-size: 0.8rem; color: #94a3b8; text-align: center; line-height: 1.45; }
#paw-instalador .paw-pasos { text-align: left; margin: 0 0 1rem; padding-left: 1.2rem; font-size: 0.8rem; line-height: 1.7; color: #cbd5e1; }
#paw-instalador .paw-pasos b { color: #00f076; }
#paw-instalador .paw-ico { display: inline-flex; width: 1.1em; height: 1.1em; vertical-align: -0.15em; color: #00f0ff; }
#paw-instalador .paw-ico svg { width: 100%; height: 100%; }
#paw-instalador .paw-btn-principal {
  width: 100%; min-height: 48px; margin-bottom: 0.6rem; border: 0; border-radius: 0.75rem;
  background: #00f076; color: #000; font: 700 0.75rem 'JetBrains Mono', monospace; letter-spacing: 0.08em; text-transform: uppercase;
  box-shadow: 0 0 25px -5px rgba(0, 240, 118, 0.5); cursor: pointer;
}
#paw-instalador button { text-align: center !important; }
#paw-instalador .paw-btn-secundario {
  width: 100%; min-height: 44px; border: 1px solid #1e293b; border-radius: 0.75rem; background: transparent;
  color: #64748b; font: 500 0.7rem 'JetBrains Mono', monospace; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
}
#paw-instalador .hidden { display: none; }

@keyframes paw-entrar { from { opacity: 0; } to { opacity: 1; } }
#paw-instalador a.paw-btn-principal { display: flex; align-items: center; justify-content: center; text-decoration: none; }
#paw-instalador a.paw-btn-principal.hidden { display: none; }

/* =========================================================
   Ventanas del panel sin recuadro: el contenido queda directo
   sobre el fondo oscuro. La X de cerrar se mantiene.
   ========================================================= */
[id^="modal-"]:not(#modal-recuperar) > div:first-of-type {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  animation: none !important;
}

/* =========================================================
   X de cerrar de todas las ventanas: blanca, brillante y
   parpadeando suave para que se encuentre de inmediato.
   ========================================================= */
@keyframes paw-x-brillo {
  0%, 100% { opacity: 1;    filter: drop-shadow(0 0 3px rgba(0, 240, 255, 0.95)) drop-shadow(0 0 8px rgba(0, 240, 255, 0.7)); }
  50%      { opacity: 0.55; filter: drop-shadow(0 0 1px rgba(0, 240, 255, 0.4)); }
}
[id^="modal-"] button[onclick*="cerrar" i]:not([onclick*="cerrarMenus"]) {
  color: #ffffff !important;
  animation: paw-x-brillo 1.3s ease-in-out infinite;
}
[id^="modal-"] button[onclick*="cerrar" i]:not([onclick*="cerrarMenus"]) svg path {
  stroke-width: 2.5;
}
@media (prefers-reduced-motion: reduce) {
  [id^="modal-"] button[onclick*="cerrar" i] { animation: none; }
}

/* =========================================================
   Splash de inicio (LogoInicial.jpg, 3 segundos)
   ========================================================= */
html.paw-con-splash body { visibility: hidden; }
#paw-splash {
  visibility: visible;
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
  opacity: 1;
  transition: opacity 0.4s ease;
  animation: paw-splash-entrada 0.5s ease-out both;
}
#paw-splash img {
  width: auto;
  height: auto;
  max-width: min(82vw, 520px);
  max-height: 70vh;
  max-height: 70dvh;
  object-fit: contain;
}
html[data-dispositivo="tablet"] #paw-splash img { max-width: min(60vw, 560px); }
html[data-dispositivo="notebook"] #paw-splash img { max-width: min(40vw, 560px); }
@media (orientation: landscape) and (max-height: 500px) {
  #paw-splash img { max-width: 55vw; max-height: 80vh; }
}
#paw-splash.paw-splash-salida { opacity: 0; animation: none; }
@keyframes paw-splash-entrada { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
