/* =====================================================================
   movil-panel.css — El panel en el CELULAR (hasta 640 px), estilo app:
   oscuro, minimalista (estilo Square), sin amontonar, con botones grandes y sencillos.
   La TABLET y la COMPUTADORA usan el diseño de computadora (menú lateral angosto);
   en pantallas táctiles solo se agrandan los botones para el dedo.
   Solo usa las variables de color que ya existen (tema-romi360.css: claro y noche).
     · Arriba: logo pequeño, campana 🔔 y vitrina 🏪.
     · Abajo: barra que arma cada persona, con Inicio fijo al centro y ☰ Menú (todas las pantallas) a la derecha.
     · Tablas como tarjetas, listas limpias y hojas que suben desde abajo.
   ===================================================================== */

/* ---------- Barra de abajo (solo celular) ---------- */
.barra-movil, .logo-movil { display: none; }
/* "Editar barra" va en el menú lateral solo en el celular (donde está la barra) */
#btnEditarBarra { display: none; }
@media (max-width: 640px) { #btnEditarBarra { display: block; } }

@media (max-width: 640px) {
  html[data-tema] body { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

  .barra-movil {
    display: grid; align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 24;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--fondo-tarjeta, #fff) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--borde);
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  }
  html[data-tema] .barra-movil button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; color: var(--suave); padding: 6px 2px; border-radius: 16px; min-height: 58px;
    font-size: 11px; font-weight: 600; position: relative; min-width: 0; touch-action: none;
    -webkit-tap-highlight-color: transparent; transition: background .15s ease, transform .15s ease;
  }
  html[data-tema] .barra-movil button .bm-ico { font-size: 22px; line-height: 1; }
  html[data-tema] .barra-movil .bm-puntos { font-size: 24px; font-weight: 900; line-height: 22px; }
  html[data-tema] .barra-movil button .bm-txt { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  html[data-tema] .barra-movil button.activo { color: var(--texto); }
  html[data-tema] .barra-movil button.activo .bm-ico { transform: translateY(-1px); }
  html[data-tema] .barra-movil button.activo .bm-txt { font-weight: 800; }
  html[data-tema] .barra-movil button.activo::after { content: ''; position: absolute; bottom: 2px; width: 18px; height: 3px;
    border-radius: 3px; background: var(--texto); }
  html[data-tema] .barra-movil .bm-num {
    position: absolute; top: 3px; left: 50%; margin-left: 6px; background: #d93025; color: #fff;
    font-size: 10px; font-weight: 700; border-radius: 10px; padding: 0 5px; min-width: 16px; line-height: 16px;
  }
  html[data-tema] .barra-movil .bm-mas.con-aviso::before { content: ''; position: absolute; top: 8px; left: 50%; margin-left: 8px;
    width: 8px; height: 8px; border-radius: 50%; background: #d93025; }
  /* Botón de la Caja en el centro: grande, redondo y con los colores del Inicio */
  html[data-tema] .barra-movil .bm-caja { color: var(--texto); padding-top: 0; justify-content: flex-end; }
  html[data-tema] .barra-movil .bm-caja-circulo {
    width: 58px; height: 58px; margin-top: -24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 26px; background: var(--texto); color: var(--miga); border: 4px solid var(--miga);
    box-shadow: 0 6px 18px rgba(0,0,0,.28);
  }
  html[data-tema] .barra-movil .bm-caja:active .bm-caja-circulo { transform: scale(.94); }
  /* Mantener presionado: los botones tiemblan como en Android mientras se acomodan */
  html[data-tema] .barra-movil.editando .bm-boton:not(.bm-hueco) { animation: bm-temblor .3s ease-in-out infinite alternate; }
  html[data-tema] .barra-movil .bm-hueco { opacity: .25; outline: 2px dashed var(--suave); outline-offset: -4px; }
  html[data-tema] .barra-movil .bm-mas.encima { background: var(--fondo-suave); color: var(--texto); }
  @keyframes bm-temblor { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
  @media (prefers-reduced-motion: reduce) { html[data-tema] .barra-movil.editando .bm-boton { animation: none; } }
  html[data-tema] .bm-fantasma { position: fixed; z-index: 970; pointer-events: none; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; background: var(--fondo-tarjeta); color: var(--texto); border-radius: 16px; font-size: 11px; font-weight: 700;
    box-shadow: 0 14px 34px rgba(0,0,0,.35); transform: scale(1.12); }
  html[data-tema] .bm-fantasma .bm-ico { font-size: 24px; }
  html[data-tema] .bm-fantasma .bm-num { display: none; }
  .bm-quitar { position: fixed; left: 12px; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 960;
    padding: 16px; border-radius: 16px; text-align: center; font-weight: 700; font-size: 14px;
    background: color-mix(in srgb, #d93025 18%, var(--fondo-tarjeta, #fff)); color: var(--texto); border: 2px dashed #d93025;
    opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .15s ease, transform .15s ease; }
  .bm-quitar.visible { opacity: 1; transform: none; }
  .bm-quitar.encima { background: #d93025; color: #fff; }

  /* ---------- Hojas que suben desde abajo (⋮ Más, Editar barra, formularios) ---------- */
  .hoja-fondo { position: fixed; inset: 0; z-index: 950; background: rgba(0,0,0,0); display: flex; align-items: flex-end;
    transition: background .2s ease; }
  .hoja-fondo.abierta { background: rgba(0,0,0,.5); }
  html[data-tema] .hoja-movil { width: 100%; max-height: 88vh; overflow-y: auto; background: var(--fondo-tarjeta); color: var(--texto);
    border-radius: 24px 24px 0 0; padding: 6px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%); transition: transform .22s ease; }
  .hoja-fondo.abierta .hoja-movil { transform: none; }
  .hoja-asa { width: 40px; height: 4px; border-radius: 4px; background: var(--borde); margin: 4px auto 6px; }
  .hoja-cab { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 12px; }
  .hoja-cab strong { font-size: 18px; letter-spacing: -.01em; }
  html[data-tema] .hoja-cerrar { width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; background: var(--secundario);
    color: var(--secundario-texto); font-size: 16px; }
  .hoja-nota { font-size: 13px; color: var(--suave); margin: 0 0 12px; line-height: 1.4; }
  .hoja-rejilla { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
  html[data-tema] .hoja-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px;
    min-height: 0; border-radius: 16px; background: var(--fondo-suave); color: var(--texto); font-size: 12px; font-weight: 600; }
  html[data-tema] .hoja-item.activo { outline: 2px solid var(--texto); }
  .hoja-item .hoja-ico { font-size: 24px; line-height: 1; }
  .hoja-item .hoja-nom { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hoja-item .bm-num { position: absolute; top: 6px; right: 8px; background: #d93025; color: #fff; font-size: 10px; font-weight: 700;
    border-radius: 10px; padding: 0 5px; line-height: 16px; }
  .hoja-acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  html[data-tema] .hoja-accion { min-height: 52px; border-radius: 14px; background: var(--secundario); color: var(--secundario-texto);
    font-size: 15px; font-weight: 600; }
  html[data-tema] .hoja-accion.principal { background: var(--texto); color: var(--miga); }
  /* Editar barra */
  .editor-lista { list-style: none; margin: 0 0 14px; padding: 0; }
  html[data-tema] .editor-fila { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--borde);
    background: var(--fondo-tarjeta); }
  .editor-fila.moviendo { box-shadow: 0 10px 26px rgba(0,0,0,.3); border-radius: 12px; position: relative; z-index: 2; }
  .editor-ico { font-size: 22px; width: 30px; text-align: center; }
  .editor-nom { flex: 1; font-size: 15px; font-weight: 600; min-width: 0; }
  html[data-tema] .editor-asa { width: 40px; height: 44px; min-height: 0; padding: 0; background: none; color: var(--suave);
    font-size: 22px; touch-action: none; cursor: grab; }
  html[data-tema] .editor-btn { width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; background: var(--secundario);
    color: var(--secundario-texto); font-size: 18px; font-weight: 700; }
  html[data-tema] .editor-btn:disabled { opacity: .3; }
  html[data-tema] .editor-quitar { color: #d93025; }
  html[data-tema] .editor-agregar { background: var(--texto); color: var(--miga); }
  .editor-divisor { font-size: 12px; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .08em;
    padding: 14px 4px 6px; border-bottom: 1px solid var(--borde); }
  .editor-titulo { font-size: 12px; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .08em; margin: 6px 4px; }

  /* ---------- Arriba: logo pequeño, campana y vitrina (sin saludo) ---------- */
  html[data-tema] .principal > .barra { padding: 8px 12px; gap: 8px; min-height: 56px; border-bottom-color: transparent;
    padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  html[data-tema] .barra .quien, html[data-tema] .barra .foto-perfil,
  html[data-tema] .barra #btnGuia { display: none; }
  html[data-tema] .logo-movil { display: flex; align-items: center; margin-right: auto; padding: 0; min-height: 0; height: 36px;
    background: none; color: var(--texto); max-width: 55vw; }
  html[data-tema] .logo-movil img { height: 32px; max-width: 140px; object-fit: contain; border-radius: 8px; }
  html[data-tema] .logo-movil .logo-texto { font-size: 18px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  html[data-tema] .barra .notif-boton, html[data-tema] .barra #zonaTema button[data-boton-tema],
  html[data-tema] .barra > button[data-guide="ver-vitrina"] {
    width: 42px; height: 42px; min-height: 0; padding: 0; border-radius: 50%; display: inline-flex; align-items: center;
    justify-content: center; background: var(--secundario); color: var(--secundario-texto); border: none; }
  html[data-tema] .barra .notif-boton, html[data-tema] .barra #zonaTema button[data-boton-tema] { font-size: 18px; line-height: 1; }
  html[data-tema] .barra > button[data-guide="ver-vitrina"] { font-size: 0; }
  html[data-tema] .barra > button[data-guide="ver-vitrina"]::before { content: '🏪'; font-size: 19px; }
  html[data-tema] .barra > button[data-guide="ver-vitrina"].oculto { display: none; }

  /* El ☰ de arriba ya no hace falta: "Más" abre el menú */
  html[data-tema] .btn-menu { display: none !important; }
  /* El menú (Más) sale desde la izquierda ocupando casi toda la pantalla */
  html[data-tema] .menu { width: min(86vw, 320px); }
  html[data-tema] .nav button { padding: 13px 14px; font-size: 16px; }

  /* Contenido */
  html[data-tema] .contenido { padding: 14px 12px 24px; }
  html[data-tema] .titulo-seccion { font-size: 24px; }
  html[data-tema] .caja { padding: 16px; border-radius: 18px; }

  /* Tarjetas del Resumen en 2 columnas, estilo app */
  html[data-tema] .tarjetas { grid-template-columns: 1fr 1fr; gap: 10px; }
  html[data-tema] .tarjeta { padding: 14px; border-radius: 20px; }
  html[data-tema] .tarjeta .t-valor { font-size: 24px; }
  html[data-tema] .tarjeta .t-etiqueta, html[data-tema] .tarjeta .t-detalle { font-size: 12px; }

  /* Botones y campos cómodos para el dedo (16 px evita que el iPhone haga zoom) */
  html[data-tema] button { min-height: 42px; }
  html[data-tema] .ini-controles button, html[data-tema] .barra-movil button, html[data-tema] .ini-tamanos button,
  html[data-tema] .hoja-movil button.editor-btn, html[data-tema] .hoja-movil button.editor-asa, html[data-tema] .hoja-movil button.hoja-cerrar { min-height: 0; }
  html[data-tema] input[type="text"], html[data-tema] input[type="number"], html[data-tema] input[type="email"],
  html[data-tema] input[type="password"], html[data-tema] input[type="tel"], html[data-tema] input[type="date"],
  html[data-tema] select, html[data-tema] textarea { font-size: 16px; min-height: 44px; }
  html[data-tema] .agregar { flex-wrap: wrap; }
  html[data-tema] .agregar > button { flex: 1 1 auto; }
  html[data-tema] .botones > button { flex: 1 1 auto; }

  /* Listas (productos, pedidos, categorías): cada fila como tarjeta */
  html[data-tema] .lista li.producto { background: var(--fondo-tarjeta, #fff); border: 1px solid var(--borde); border-radius: 16px;
                                        padding: 12px; margin-bottom: 10px; }
  html[data-tema] .producto .info { min-width: 0; flex: 1 1 calc(100% - 70px); }
  html[data-tema] .producto .botones-prod { width: 100%; }
  html[data-tema] .producto .botones-prod button { flex: 1 1 auto; }

  /* ---------- Tablas como tarjetas ---------- */
  html[data-tema] .envoltura-excel { overflow: visible; max-height: none; border: none; }
  html[data-tema] table.como-tarjetas,
  html[data-tema] table.como-tarjetas tbody { display: block; width: 100%; border: none; }
  html[data-tema] table.como-tarjetas thead { display: none; }
  html[data-tema] table.como-tarjetas tr {
    display: block; background: var(--fondo-tarjeta, #fff); border: 1px solid var(--borde); border-radius: 16px;
    padding: 6px 14px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.03);
  }
  html[data-tema] table.como-tarjetas tr.fila-cabecera { display: none; }
  html[data-tema] table.como-tarjetas td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 0; border: none !important; border-bottom: 1px solid var(--borde) !important;
    white-space: normal; text-align: right; position: static !important; background: none !important;
    min-height: 40px; word-break: break-word;
  }
  html[data-tema] table.como-tarjetas td:last-child { border-bottom: none !important; }
  html[data-tema] table.como-tarjetas td::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left;
    font-size: 12px; font-weight: 600; color: var(--suave);
  }
  html[data-tema] table.como-tarjetas td[data-label=""]::before { content: none; }
  html[data-tema] table.como-tarjetas td[data-label=""] { justify-content: flex-end; }
  /* La primera celda es el título de la tarjeta */
  html[data-tema] table.como-tarjetas td:first-child { font-size: 16px; font-weight: 700; justify-content: flex-start; text-align: left; }
  html[data-tema] table.como-tarjetas td:first-child::before { content: none; }
  html[data-tema] table.como-tarjetas td select, html[data-tema] table.como-tarjetas td input { width: auto; max-width: 60%; }
  html[data-tema] table.como-tarjetas tbody tr:nth-child(even) td { background: none !important; }
  html[data-tema] table.como-tarjetas tfoot { display: block; }
  html[data-tema] table.como-tarjetas tfoot tr { background: var(--fondo-suave, #f7f7f7); }

  /* Ventanas y diálogos a lo ancho */
  html[data-tema] .ventana, html[data-tema] dialog { max-width: calc(100vw - 24px); }

  /* ---------- Estilo app: limpio, sin amontonar ---------- */
  html[data-tema] .contenido { padding: 6px 14px 28px; }
  html[data-tema] .titulo-seccion { font-size: 26px; margin: 4px 0 2px; }
  html[data-tema] .subtitulo { font-size: 13px; margin-bottom: 14px; }
  html[data-tema] .caja { border: none; box-shadow: none; border-radius: 20px; }
  html[data-tema] .formulario { border: none; border-radius: 18px; }
  html[data-tema] button { border-radius: 12px; font-weight: 600; }
  html[data-tema] input[type="text"], html[data-tema] input[type="number"], html[data-tema] input[type="email"],
  html[data-tema] input[type="password"], html[data-tema] input[type="tel"], html[data-tema] input[type="date"],
  html[data-tema] input[type="search"], html[data-tema] select, html[data-tema] textarea { border-radius: 12px; }
  /* Inicio: sin saludo (arriba ya va el logo). "Acomodar" va chiquito junto a Favoritos */
  html[data-tema] #sec-inicio:not(.ini-editando) .ini-cabeza { display: none; }
  html[data-tema] #sec-inicio .ini-hola { display: none; }
  html[data-tema] #sec-inicio .ini-cabeza { align-items: center; flex-wrap: nowrap; margin-bottom: 10px; }
  html[data-tema] #sec-inicio .ini-sub { font-size: 13px; }
  html[data-tema] #sec-inicio .ini-titulo-fav { margin-top: 4px; }
  html[data-tema] #sec-inicio .ini-titulo-fav .ini-der { display: inline-flex; gap: 6px; align-items: center; }
  html[data-tema] #sec-inicio .ini-acomodar-chico { display: inline-flex; }
}
}

/* ---------- Pantallas táctiles (tablet): el diseño de la computadora, con botones para el dedo ---------- */
@media (pointer: coarse) {
  html[data-tema] button { min-height: 44px; }
  html[data-tema] .nav button { padding-top: 13px; padding-bottom: 13px; }
  html[data-tema] button.secundario, html[data-tema] button.peligro { padding: 9px 14px; }
  html[data-tema] input[type="text"], html[data-tema] input[type="number"], html[data-tema] input[type="email"],
  html[data-tema] input[type="password"], html[data-tema] select, html[data-tema] textarea { min-height: 44px; font-size: 16px; }
  html[data-tema] .tabla-excel td { padding-top: 10px; padding-bottom: 10px; }
  html[data-tema] .barra-movil button, html[data-tema] .ini-controles button, html[data-tema] .ini-tamanos button,
  html[data-tema] .hoja-movil button.editor-btn, html[data-tema] .hoja-movil button.editor-asa, html[data-tema] .hoja-movil button.hoja-cerrar,
  html[data-tema] .teclado-num button { min-height: 0; }
}
