/* public/styles.css */
:root {
  --palm-bg: #879a7b;        /* Verde oliva LCD clásico */
  --palm-dark: #1e2b18;      /* Texto oscuro/verdoso de matriz pasiva */
  --pda-plastic: #2a2e35;    /* Gris carbón para la carcasa plástica */
  --pda-border: #15181c;
}

body {
  background-color: #111;
  font-family: 'Courier New', Courier, monospace; /* Tipografía tipo terminal pixelada */
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  overflow: hidden;
}

/* Carcasa de la PDA APVG1 */
.pda-body {
  background-color: var(--pda-plastic);
  width: 350px;
  height: 600px;
  border-radius: 24px;
  padding: 20px;
  box-shadow: inset -4px -4px 8px rgba(0,0,0,0.6), 15px 15px 35px rgba(0,0,0,0.9);
  border: 4px solid var(--pda-border);
  display: flex;
  flex-direction: column;
}

/* Pantalla LCD de Cristal Líquido */
.pda-screen {
  background-color: var(--palm-bg);
  color: var(--palm-dark);
  flex: 1;
  border: 5px solid #000;
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: inset 3px 3px 6px rgba(0,0,0,0.4);
  position: relative;
}

/* Efecto de líneas de escaneo LCD retro */
.pda-screen::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.06) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  z-index: 10;
  background-size: 100% 3px, 3px 100%;
  pointer-events: none;
}

/* Preferencias visuales activadas desde Herramientas en la PWA. */
body.pwa-high-contrast .pda-screen {
  --palm-bg: #9eb391;
  --palm-dark: #000;
  background-color: var(--palm-bg);
  color: #000;
}

body.pwa-high-contrast .pda-screen::before {
  display: none;
}

.pwa-tools-dialog {
  box-sizing: border-box;
  width: min(290px, calc(100vw - 32px));
  max-height: min(80vh, 420px);
  padding: 12px;
  border: 2px solid var(--palm-dark);
  border-radius: 6px;
  background: var(--palm-bg);
  color: var(--palm-dark);
  font: 12px 'Courier New', Courier, monospace;
}

.pwa-tools-dialog::backdrop {
  background: rgb(0 0 0 / 55%);
}

body.pwa-high-contrast .pwa-tools-dialog {
  background: #9eb391;
  border-color: #000;
  color: #000;
}

.pwa-tools-dialog h2 {
  margin: 0 0 10px;
  font-size: 14px;
}

.pwa-tools-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid currentColor;
}

.pwa-tools-option input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--palm-dark);
}

.pwa-tools-option span {
  display: block;
}

.pwa-tools-option small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
}

.pwa-tools-close {
  width: 100%;
  margin-top: 8px;
  padding: 7px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font: inherit;
}

/* Barra Superior de Estado */
.screen-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px dashed var(--palm-dark);
  font-size: 11px;
  font-weight: bold;
  padding-bottom: 4px;
  letter-spacing: 1px;
}

/* Área de contenido dinámico */
.screen-content {
  flex: 1;
  padding-top: 15px;
  font-size: 14px;
  line-height: 1.3;
}

/* Zona inferior de dibujo táctil / Graffiti */
.graffiti-area {
  height: 80px;
  border-top: 3px double var(--palm-dark);
  display: flex;
  margin-top: auto;
}

.graffiti-pad {
  flex: 1;
  border-right: 1px dashed var(--palm-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  font-size: 12px;
  font-weight: bold;
}

.graffiti-pad:last-child {
  border-right: none;
}

/* Panel de Botones de Hardware Físicos */
.hardware-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding: 0 4px;
}

.hw-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #4a515a;
  border: 2px solid var(--pda-border);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.5), inset 1px 1px 2px rgba(255,255,255,0.2);
}

.hw-btn:active {
  box-shadow: inset 2px 2px 4px rgba(0,0,0,0.8);
  background-color: #383d44;
}

/* Botones alargados de Scroll (arriba y abajo) */
.scroll-btn {
  border-radius: 6px;
  height: 32px;
  width: 36px;
  font-size: 12px;
}

/* --- ESTILOS UNIFORMES PARA FORMULARIOS PALM OS --- */

.pda-form {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Distancia uniforme entre cada campo */
  margin-top: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Etiquetas de texto pequeñas encima de los inputs */
.pda-label {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  color: var(--palm-dark);
  letter-spacing: 0.5px;
}

/* Forzar tamaño y diseño idéntico para Inputs y Selects */
.pda-input, .pda-select {
  background: transparent;
  border: 2px solid var(--palm-dark);
  border-radius: 4px;
  color: var(--palm-dark);
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  font-weight: bold;
  padding: 8px; /* Relleno interno idéntico */
  height: 36px;  /* Altura fija estricta para todos */
  width: 100%;   /* Ocupan todo el ancho disponible uniformemente */
  box-sizing: border-box; /* Evita que el padding deforme el tamaño */
}

/* Enfoque retro cuando el usuario hace clic para escribir */
.pda-input:focus, .pda-select:focus {
  outline: none;
  background-color: rgba(0, 0, 0, 0.05);
  box-shadow: 0 0 0 1px var(--palm-dark);
}

/* Botones de acción del formulario */
.pda-submit-btn {
  background-color: transparent;
  border: 2px solid var(--palm-dark);
  border-radius: 4px;
  color: var(--palm-dark);
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  font-weight: bold;
  height: 38px;
  cursor: pointer;
  margin-top: 5px;
  text-transform: uppercase;
  transition: background 0.1s;
}

.pda-submit-btn:active {
  background-color: var(--palm-dark);
  color: var(--palm-bg);
}

/* Pantalla de bloqueo total */
.screen-blocked {
  text-align: center;
  margin-top: 50px;
  border: 3px double var(--palm-dark);
  padding: 15px;
  background-color: rgba(0,0,0,0.02);
}


/* --- CONSOLA DE DIAGNÓSTICO RETRO --- */
.pda-console {
  font-size: 10px;
  font-family: 'Courier New', Courier, monospace;
  font-weight: bold;
  color: var(--palm-dark);
  border-top: 1px dashed rgba(30, 43, 24, 0.3);
  padding: 4px 2px 0 2px;
  margin-top: auto; /* Se empuja automáticamente al fondo de la pantalla útil */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

/* Efecto de parpadeo sutil cuando entra un nuevo log técnico */
.pda-log-flash {
  animation: logFlashAnim 0.3s ease-out;
}

.pda-log-dismiss {
  animation: logDismissAnim 0.3s ease-in forwards;
}

@keyframes logFlashAnim {
  0% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}

@keyframes logDismissAnim {
  to { opacity: 0; }
}

/* Ajustes de la PWA sobre la carcasa Palm compartida. */
.pwa-shell .pda-screen {
  min-height: 0;
}

.pwa-shell .screen-content {
  --apcc-font-body: 14px;
  --apcc-font-heading: 17px;
  --apcc-font-small: 12px;
  --apcc-font-control: 14px;
  min-height: 0;
  overflow-y: auto;
  font-size: var(--apcc-font-body);
}

/* Tipografía común: incluye apps insertadas dinámicamente por Render. */
body.pwa-shell .pda-screen .screen-content * {
  font-size: var(--apcc-font-body) !important;
}

body.pwa-shell .pda-screen .screen-content :is(h1, h2, h3, h4, h5, h6) {
  font-size: var(--apcc-font-heading) !important;
}

body.pwa-shell .pda-screen .screen-content small {
  font-size: var(--apcc-font-small) !important;
}

body.pwa-shell .pda-screen .screen-content :is(input, textarea, select, button) {
  font-size: var(--apcc-font-control) !important;
}

.pwa-title {
  margin: 20px 0 8px;
  font-size: 17px;
  text-align: center;
}

.pwa-copy {
  margin: 0;
  text-align: center;
}

.pwa-note {
  margin: 12px 0 0;
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
}

.pwa-install-button {
  width: 100%;
  margin: 12px 0 0;
}

.pwa-install-help {
  margin: 8px 0 0;
  padding: 8px;
  border: 1px dashed var(--palm-dark);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

.pwa-secondary-button {
  margin-top: 0;
}

.pwa-shell .pda-console {
  min-height: 30px;
  line-height: 1.2;
  white-space: pre-line;
  overflow: visible;
  text-overflow: clip;
}

.pwa-shell .hw-btn {
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 80ms ease;
}

.pwa-shell .hw-btn:active,
.pwa-shell .hw-btn.is-pressed {
  transform: translateY(2px);
  background-color: #383d44;
  box-shadow: inset 2px 2px 4px rgb(0 0 0 / 80%);
}

@media (max-width: 430px) {
  .pwa-shell .pda-body {
    box-sizing: border-box;
    width: min(398px, 100vw);
    height: min(648px, 100dvh);
    padding: 16px;
  }
}

@media (max-height: 680px) {
  .pwa-shell {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    padding: 12px 0;
  }

  .pwa-shell .pda-body {
    height: 620px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-shell .hw-btn {
    transition-duration: .01ms;
  }
}
