/* Agregados de la versión web: ingreso, suscripción, aviso de prueba y pantallas chicas. */

body { display: flex; flex-direction: column; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }

/* Un select con opciones muy largas (una categoría de 100 letras) no empuja los demás campos fuera del formulario. */
select { max-width: 100%; }
.grid-2 > *, .form-grid > *, .campo select { min-width: 0; }
/* El nombre de la empresa en el menú: como mucho dos líneas. */
.brand-text { min-width: 0; }
.brand-text strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* Las tablas anchas se desplazan dentro de su recuadro (nunca la página entera). */
.tabla-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Los saltos de línea de los mensajes de confirmación se respetan. */
.confirmar-texto { white-space: pre-line; }

/* ---------- Modo soporte (impersonación desde el superadmin) ---------- */
.aviso-soporte { background: #4c1d95; color: #fff; padding: 8px 16px; font-size: 13px; text-align: center; flex-shrink: 0; }
.aviso-soporte a { color: #fde68a; font-weight: 700; margin-left: 6px; }

/* ---------- Aviso de días de prueba ---------- */
.aviso-prueba {
  background: #fff7e0; color: #7a5300; border-bottom: 1px solid #f1d58a;
  padding: 8px 16px; font-size: 13px; text-align: center; flex-shrink: 0;
}
.aviso-prueba a { color: var(--azul); font-weight: 700; margin-left: 6px; }
.aviso-pago-fallido { background: #fdecec; color: #8a1c1c; border-bottom-color: #f2b8b8; }
.demo-banner { flex-shrink: 0; }

.sidebar-email { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 11px; margin-bottom: 6px; }
.btn-menu { display: none; font-size: 22px; margin-right: 8px; }
.menu-fondo { display: none; }

/* ---------- Ingreso y suscripción ---------- */
.pagina-acceso { background: var(--gris); min-height: 100vh; overflow: auto; }
.acceso { width: 100%; max-width: 420px; margin: 0 auto; padding: 48px 16px 24px; }
.acceso-ancho { max-width: 560px; }
.acceso-marca { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.acceso-marca .brand-logo { background: var(--azul); color: #fff; }
.acceso-marca strong { display: block; color: var(--azul); font-size: 20px; }
.acceso-marca span { color: var(--texto-suave); font-size: 13px; }
/* Nombres y emails largos se cortan dentro de su caja (nunca ensanchan la página del celular). */
.acceso-marca > div:last-child { min-width: 0; }
.acceso-marca strong, .acceso-marca span { overflow-wrap: anywhere; }
.eleccion { display: grid; gap: 10px; margin: 16px 0 8px; }
/* El nombre del negocio que invita y los emails pueden ser largos: se cortan dentro del botón y del texto. */
.eleccion .btn { text-align: center; overflow-wrap: anywhere; }
.acceso-card p { overflow-wrap: anywhere; }
.acceso-card h1 { color: var(--azul); font-size: 20px; margin: 0 0 8px; }
.acceso-card .campo input { width: 100%; }
.acceso-card .campo select { width: 100%; }
.acceso-card .btn { width: 100%; justify-content: center; }
.acceso-card .ayuda-acciones .btn, .acceso-card .ayuda-acciones form { width: auto; }
.input-codigo { font-size: 26px; letter-spacing: 10px; text-align: center; font-weight: 700; }
.acceso-links { text-align: center; font-size: 13px; margin: 14px 0 0; }
.acceso-links a, .acceso-pie a { color: var(--azul); }
.acceso-pie { text-align: center; font-size: 12px; color: var(--texto-suave); margin-top: 18px; }
.precio { margin: 16px 0 6px; color: var(--texto-suave); }
.precio span { font-size: 32px; font-weight: 800; color: var(--azul); margin-right: 4px; }
.btn-paypal { background: #ffc439; color: #111; border-color: #ffc439; font-weight: 700; }
/* Avisos de las páginas de ingreso y suscripción (no confundir con la tarjeta .stat.aviso del dashboard) */
.pagina-acceso .aviso { background: #eef4fb; border-left: 4px solid var(--azul); padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.pagina-acceso .aviso.ok { background: #e7f6ec; border-left-color: #1f8a4c; }
.pagina-acceso .aviso.error { background: #fdecec; border-left-color: #c62828; }
.form-cancelar { margin-top: 18px; text-align: right; }
.link-peligro { background: none; border: 0; color: #c62828; text-decoration: underline; cursor: pointer; font-size: 13px; padding: 0; }

/* WhatsApp con código de país adelante */
.tel-grupo { display: flex; align-items: stretch; }
.tel-prefijo { display: flex; align-items: center; padding: 0 10px; background: var(--gris); border: 1px solid var(--gris-borde); border-right: 0; border-radius: 8px 0 0 8px; font-weight: 600; color: var(--texto-suave); }
.tel-grupo input { flex: 1; border-radius: 0 8px 8px 0; min-width: 0; }

/* ---------- Pantallas chicas: el menú lateral se despliega con ☰ ---------- */
@media (max-width: 860px) {
  .btn-menu { display: inline-flex; }
  #sidebar {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  body.menu-abierto #sidebar { transform: none; }
  /* Con el menú abierto: un fondo que lo cierra al tocarlo (y no deja que el toque llegue a la pantalla de abajo) y el
     ☰ a la vista, sobre el fondo, al lado del menú. */
  body.menu-abierto .menu-fondo { display: block; position: fixed; inset: 0; z-index: 59; background: rgba(15,30,55,.45); }
  body.menu-abierto #btnMenu { position: fixed; top: 10px; left: 250px; z-index: 70; background: var(--blanco);
                               box-shadow: 0 2px 10px rgba(0,0,0,.25); outline: none; }
  #topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
  #pageTitle { flex: 1; font-size: 18px; }
  .topbar-right { flex-wrap: wrap; width: 100%; }
  #content { padding: 16px; }
  .modal { width: calc(100vw - 24px) !important; max-width: none; }
  table { font-size: 13px; }
  thead th, tbody td { padding: 9px 10px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 auto; justify-content: center; }

  /* Formularios en una columna y campos al ancho disponible */
  .grid-2, .form-grid { grid-template-columns: 1fr; gap: 0; }
  .campo input, .campo select, .campo textarea, .modal-body input:not([type=checkbox]):not([type=radio]), .modal-body select { width: 100%; max-width: 100%; }
  .search { min-width: 0 !important; width: 100%; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar .btn { flex: 1 1 auto; justify-content: center; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat .valor { font-size: 24px; }

  /* Paginación: los botones bajan a otra línea antes de salirse de la pantalla */
  .pag-btns { flex-wrap: wrap; }

  /* Avisos de arriba más compactos */
  .aviso-prueba, .demo-banner { font-size: 12px; padding: 6px 12px; }
  .demo-banner { padding-right: 40px; position: relative; }
  .demo-cerrar { position: absolute; top: 4px; right: 6px; transform: none; }

  /* Ficha del producto buscado en el Dashboard: la etiqueta arriba del valor */
  .help-row { flex-wrap: wrap; gap: 2px 10px; }

  /* iOS agranda la página al tocar un campo con letra de menos de 16 px. */
  input, select, textarea { font-size: 16px; }
  /* Los avisos van abajo y un formulario abierto deja libre ese lugar (120 px, un aviso de hasta 4 líneas): no tapan
     ni sus botones ni su título ni la ✕. Se ve solo el último aviso. */
  #toasts { bottom: 12px; left: 12px; right: 12px; }
  .toast { min-width: 0; }
  .toast:not(:last-child) { display: none; }
  .modal-overlay { padding: 10px 12px 120px; }
  .modal { max-height: 100%; }
}
@media (max-width: 420px) {
  .stat .etiqueta { font-size: 11px; }
}

/* ---------- Celular: cada fila de las tablas de datos es una tarjeta; los encabezados quedan para ordenar ---------- */
@media (max-width: 640px) {
  .tabla-wrap.tarjetas { background: transparent; box-shadow: none; overflow: visible; border-radius: 0; }
  .tarjetas table, .tarjetas tbody { display: block; }
  .tarjetas thead { display: block; margin-bottom: 10px; }
  .tarjetas thead tr { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .tarjetas thead tr::before { content: 'Ordenar:'; font-size: 12px; font-weight: 600; color: var(--texto-suave); margin-right: 2px; }
  .tarjetas thead th { position: static; padding: 5px 10px; border-radius: 999px; font-size: 12px; text-align: left;
                       background: var(--blanco); color: var(--azul); border: 1px solid var(--gris-borde); }
  .tarjetas thead th.th-activo, .tarjetas thead th.th-sort:hover { background: var(--azul); color: #fff; border-color: var(--azul); }
  .tarjetas thead th:not(.th-sort) { display: none; }
  .tarjetas.sin-orden thead { display: none; }
  .tarjetas tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; background: var(--blanco);
                       border-radius: var(--radio); box-shadow: var(--sombra); padding: 12px 14px; margin-bottom: 10px; }
  .tarjetas tbody tr:hover { background: var(--blanco); }
  .tarjetas tbody tr.fila-baja, .tarjetas tbody tr.fila-baja:hover { background: var(--rojo-bg); }
  .tarjetas tbody tr.fila-archivada, .tarjetas tbody tr.fila-archivada:hover { background: #f4f4f5; }
  .tarjetas tbody td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
  .tarjetas tbody td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; color: var(--texto-suave); font-style: normal; }
  .tarjetas tbody td.td-acciones { grid-column: 1 / -1; border-top: 1px solid var(--gris); padding-top: 8px; }
  .tarjetas tbody td.td-acciones:empty { display: none; }
  .tarjetas .acciones { justify-content: flex-start; flex-wrap: wrap; }
  .tarjetas .acciones .btn { flex: 1 1 auto; justify-content: center; }
  .paginacion { padding-top: 4px; }
}

.ac-wrap > input { width: 100%; }
#formInvitar .search { flex: 1; }
@media (max-width: 860px) { #formInvitar .search { flex: 1 1 100%; } }

a.btn { text-decoration: none; display: inline-flex; align-items: center; }
