/* ══════════════════════════════════════════════════════════════
   KIOSK VERTICAL — pantalla 10" girada (≈800×1280)
   Objetivo: todo visible en una pantalla, sin scroll de página,
   contenido centrado vertical y horizontalmente.
   ══════════════════════════════════════════════════════════════ */

@media (orientation: portrait) and (max-width: 920px) {

  /* Las pantallas que caben quedan centradas y sin scroll; los
     listados largos (albaranes, etc.) scrollean con normalidad
     con la barra fija arriba. */
  .footer { display: none; }

  /* ── Navbar compacta y siempre visible ── */
  .navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    padding: 0 0.75rem;
    gap: 0.4rem;
    flex-shrink: 0;
  }
  .nav-brand img { height: 36px !important; }
  .nav-clock { display: none; }
  .nav-primary-btn { padding: 0.4rem 0.6rem; font-size: 0.68rem; }

  /* ── Contenido: centra el bloque cuando sobra alto (los
        ::before/::after con margin auto reparten el espacio) ── */
  .container { padding: 0.9rem 1.1rem; }

  /* Solo ENTREGAR y RECOGER se fijan a una pantalla (centradas, sin scroll).
     El resto de páginas (inicio, listados, admin) fluyen con scroll normal. */
  body.kiosk-fit .container {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  body.kiosk-fit .container::before { content: ''; margin-top: auto; }
  body.kiosk-fit .container::after  { content: ''; margin-bottom: auto; }

  /* ── Compactar verticalmente ── */
  .section-header { text-align: center; margin-bottom: 0.9rem; }
  .section-title { font-size: 1.2rem; justify-content: center; }
  .section-subtitle { font-size: 0.75rem; }
  .card { padding: 1.1rem; margin-bottom: 0.75rem; }
  .field-hint { display: none; }          /* pistas fuera: ahorran alto */
  .form-group { margin-bottom: 0.8rem !important; }
  hr { margin: 0.8rem 0 !important; }

  /* Controles táctiles más cómodos */
  .form-input, .form-control, select { min-height: 48px; }
  .btn { min-height: 48px; }

  /* Pantalla de inicio (bienvenida): protagonista en vertical */
  .welcome-wrap { min-height: 0; gap: 1.5rem; padding: 0.5rem 0; }
  .welcome-logo img { height: 260px; }
  .welcome-title { font-size: 0.9rem; }
  .welcome-btns { max-width: 660px; gap: 1.1rem; }
  .welcome-btn { min-height: 200px; gap: 1rem; }
  .welcome-btn .wb-icon { font-size: 3.6rem; }
  .welcome-btn .wb-label { font-size: 1.2rem; }
  .welcome-btn .wb-sub { font-size: 0.8rem; max-width: 240px; }
  .welcome-status {
    width: 100%;
    max-width: 660px;
    justify-content: space-around;
    padding: 0.9rem 1rem;
  }
  .welcome-status .ws-item span { font-size: 1.7rem; }

  /* Teclado PIN cómodo para dedos — la pantalla del kiosk (~800px de ancho
     en vertical) tiene hueco de sobra, que aproveche más espacio en vez de
     quedarse pequeño en medio de la pantalla. */
  .recoger-logo { height: 170px; }
  .pin-display { padding: 0.7rem 0.4rem; margin-bottom: 0.9rem; }
  .numpad { max-width: 440px; }
  .numpad-btn { min-height: 72px; font-size: 1.6rem; }

  /* ════════════════════════════════════════════════════════════
     ADMINISTRACIÓN (panel con sidebar) en vertical 10"
     El admin es largo y necesita scroll: anulamos el centrado del
     kiosk público y activamos el modo "drawer" del sidebar (mismo
     patrón que ≤768px) para todo el rango vertical (≈800px de
     ancho no llegaba a ≤768px y el sidebar se comía la pantalla).
     ════════════════════════════════════════════════════════════ */

  /* El admin NO se centra ni se comprime: flujo normal con scroll desde arriba.
     Usamos la clase body.is-admin (no :has(), que el Chromium del kiosk puede
     no soportar y dejaría el menú/contenido fuera de pantalla). */
  body.is-admin .container {
    display: block;
    padding: 0;
    flex: none;
  }

  /* Sidebar como cajón deslizante + hamburguesa visible */
  .dashboard-layout { display: block; margin: 0; min-height: unset; }
  .sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    z-index: 499;
    transition: left 0.25s ease;
    overflow-y: auto;
    padding-top: 56px;          /* altura de la navbar kiosk */
  }
  .sidebar.mobile-open { left: 0; }
  .sidebar-backdrop.open { display: block; }
  .dashboard-mobile-toggle { display: flex; }
  .dashboard-content { padding: 1rem 1.1rem 2.5rem; overflow-y: visible; }

  /* Enlaces del menú más altos para dedos */
  .sidebar-link { padding: 0.8rem 0.75rem; font-size: 0.82rem; min-height: 46px; }
  .sidebar-section { margin-bottom: 1rem; }

  /* Cuadrículas a una columna: caben de sobra en 800px verticales */
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 1rem; }
  .form-grid-halves { grid-template-columns: 1fr; }
  .cam-grid, .user-grid { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin-bottom: 1.25rem; }

  /* Cabeceras y filtros apilados en columna */
  .page-header > div,
  .dashboard-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .filter-form { flex-direction: column; gap: 0.7rem; }
  .filter-form .form-group { min-width: 0; width: 100%; }

  /* Tablas: caben sin scroll lateral ocultando columnas secundarias
     (igual que en móvil ≤520px) y dejando que el texto que quede envuelva
     en vez de forzar una fila ancha. overflow-x se deja solo como red de
     seguridad, ya no debería hacer falta. */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* width:100% (regla base) le impide crecer aunque el contenido no quepa
     tras ocultar columnas y envolver texto — con eso el scroll de arriba
     nunca tenía nada que desplazar. min-width:100% deja que siga llenando
     el ancho normalmente, pero puede superarlo si de verdad hace falta. */
  .table { width: auto; min-width: 100%; font-size: 0.72rem; }
  .table th { padding: 0.5rem 0.55rem; font-size: 0.65rem; white-space: normal; }
  .table td { padding: 0.5rem 0.55rem; white-space: normal; overflow-wrap: anywhere; }

  /* ── Entregas (9 cols → 5 visibles) ────────────────────────────── */
  .table-entregas th:nth-child(2), .table-entregas td:nth-child(2),
  .table-entregas th:nth-child(5), .table-entregas td:nth-child(5),
  .table-entregas th:nth-child(7), .table-entregas td:nth-child(7),
  .table-entregas th:nth-child(8), .table-entregas td:nth-child(8) { display: none; }

  /* ── Auditoría (8 cols → 4 visibles) ───────────────────────────── */
  .table-auditoria th:nth-child(3), .table-auditoria td:nth-child(3),
  .table-auditoria th:nth-child(4), .table-auditoria td:nth-child(4),
  .table-auditoria th:nth-child(7), .table-auditoria td:nth-child(7),
  .table-auditoria th:nth-child(8), .table-auditoria td:nth-child(8) { display: none; }

  /* ── Destinatarios (8 cols → 4 visibles) ───────────────────────── */
  .table-destinatarios th:nth-child(3), .table-destinatarios td:nth-child(3),
  .table-destinatarios th:nth-child(4), .table-destinatarios td:nth-child(4),
  .table-destinatarios th:nth-child(6), .table-destinatarios td:nth-child(6),
  .table-destinatarios th:nth-child(7), .table-destinatarios td:nth-child(7) { display: none; }

  /* ── Lockers (8 cols → 4 visibles) ─────────────────────────────── */
  .table-lockers th:nth-child(4), .table-lockers td:nth-child(4),
  .table-lockers th:nth-child(5), .table-lockers td:nth-child(5),
  .table-lockers th:nth-child(6), .table-lockers td:nth-child(6),
  .table-lockers th:nth-child(7), .table-lockers td:nth-child(7) { display: none; }

  /* ── Usuarios (8 cols → 4 visibles) ────────────────────────────── */
  .table-usuarios th:nth-child(2), .table-usuarios td:nth-child(2),
  .table-usuarios th:nth-child(4), .table-usuarios td:nth-child(4),
  .table-usuarios th:nth-child(5), .table-usuarios td:nth-child(5),
  .table-usuarios th:nth-child(7), .table-usuarios td:nth-child(7) { display: none; }

  /* ── Dashboard alertas (7 cols → 5 visibles) ───────────────────── */
  .table-alertas th:nth-child(4), .table-alertas td:nth-child(4),
  .table-alertas th:nth-child(5), .table-alertas td:nth-child(5) { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   TECLADO NUMÉRICO EN PANTALLA (numpad.js)
   Aparece al tocar un campo numérico/teléfono en el kiosk.
   ══════════════════════════════════════════════════════════════ */

#kiosk-numpad {
  position: fixed;
  left: 50%;
  bottom: 0.75rem;
  transform: translate(-50%, 120%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: min(400px, calc(100vw - 1.5rem));
  padding: 0.5rem 0.7rem 0.7rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  z-index: 4000;
  transition: transform 0.22s ease;
  pointer-events: none;
}
#kiosk-numpad.open {
  transform: translate(-50%, 0);
  pointer-events: auto;
}
#kiosk-numpad .np-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}
#kiosk-numpad .kbn-btn {
  min-height: 54px;
  font-size: 1.2rem;
}

/* La barra superior (asa + minimizar) ahora se define una sola vez en
   style.css — aquí sobraba una segunda definición que competía con ella. */

/* ── Teclado QWERTY completo (campos de texto / email) ── */
#kiosk-keyboard {
  position: fixed;
  left: 50%;
  bottom: 0.75rem;
  transform: translate(-50%, 120%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: min(720px, calc(100vw - 1rem));
  padding: 0.6rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  z-index: 4000;
  transition: transform 0.22s ease;
  pointer-events: none;
}
#kiosk-keyboard.open {
  transform: translate(-50%, 0);
  pointer-events: auto;
}
#kiosk-keyboard .kb-row {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
}
#kiosk-keyboard .kb-key {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#kiosk-keyboard .kb-key:active {
  background: var(--accent);
  color: #000;
}
#kiosk-keyboard .kb-del,
#kiosk-keyboard .kb-caps { background: var(--bg-primary); flex: 1.4; }
#kiosk-keyboard.kb-mayus .kb-caps { border-color: var(--accent); color: var(--accent); }
#kiosk-keyboard .kb-space { flex: 2.5; }
#kiosk-keyboard .kb-com { flex: 1.4; font-size: 0.85rem; }
