/* Crear y configurar bots, grupos y la memoria de un bot (bots.js). Medidas de BotsChat.swift, Bots.swift y Grupos.swift. */

.bt-centro { background: var(--tira); }
.bt-rollo { flex: 1; min-height: 0; overflow-y: auto; }
.bt-rollo.centrado { display: flex; flex-direction: column; }
.bt-columna { max-width: calc(var(--ancho, 680) * var(--u)); margin: 0 auto; padding: calc(34 * var(--u)) 32px calc(28 * var(--u)); }
.bt-rollo.centrado .bt-columna { margin: auto; padding: 24px 20px; max-width: none; }
.bt-pie { flex: none; border-top: 1px solid var(--borde); background: var(--tira); }
.bt-pie-fila { max-width: calc(var(--ancho, 680) * var(--u)); margin: 0 auto; padding: 14px 32px; display: flex; align-items: center; gap: 10px; }
.bt-error { font-size: var(--f125); line-height: 1.3; max-width: 46%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.boton.bt-grande { height: calc(30 * var(--u)); padding: 0 14px; font-size: var(--f13); }

/* MARK: Secciones y campos */

.bt-seccion { margin-top: calc(26 * var(--u)); padding-top: calc(26 * var(--u)); border-top: 1px solid color-mix(in srgb, var(--borde) 80%, transparent); }
.bt-seccion h3 { font-size: calc(14.5 * var(--u)); font-weight: 600; }
.bt-detalle { margin-top: 4px; font-size: var(--f12); color: var(--texto2); line-height: 1.45; }
.bt-campos { margin-top: calc(16 * var(--u)); display: flex; flex-direction: column; gap: calc(18 * var(--u)); align-items: stretch; }
.bt-fila { display: flex; flex-wrap: wrap; align-items: flex-start; gap: calc(18 * var(--u)) 24px; }
.bt-campo { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.bt-rotulo { font-size: var(--f115); font-weight: 500; color: var(--texto2); }
.bt-nota { font-size: var(--f115); color: var(--texto3); line-height: 1.45; }
.bt-nota.ambar { color: var(--ambar); }
.bt-nada { font-size: var(--f125); color: var(--texto3); }
.bt-lista { width: auto; max-width: 100%; min-width: calc(96 * var(--u)); }
.bt-alto { height: calc(34 * var(--u)); }
.bt-fijo { display: inline-flex; align-items: center; gap: 7px; height: calc(30 * var(--u)); font-size: var(--f13); color: var(--texto2); }
.bt-fijo.bt-alto { height: calc(34 * var(--u)); padding: 0 11px; border-radius: 8px; border: 1px solid var(--borde); background: var(--tarjeta); }
.bt-caja { border-radius: 9px; border: 1px solid var(--borde); background: var(--tarjeta); }
.bt-activo { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.bt-activo b { display: block; font-size: var(--f13); font-weight: 500; margin-bottom: 3px; }
.bt-aviso { display: flex; gap: 7px; font-size: var(--f12); color: var(--ambar); line-height: 1.45; }
.bt-aviso .ico { margin-top: 2px; }

/* MARK: La cara y la voz */

.bt-selector-cara { display: flex; flex-direction: column; align-items: flex-start; gap: calc(var(--t) * .5); }
.bt-crear .bt-selector-cara { align-items: center; }
.bt-formas { display: flex; gap: calc(var(--t) * .35 - 8px); }
.bt-formas button { padding: 4px; border-radius: calc(var(--t) * .4); box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .12s; }
.bt-formas button:hover { box-shadow: inset 0 0 0 1.5px rgba(var(--p), .18); }
.bt-formas button.elegida { box-shadow: inset 0 0 0 1.5px rgba(var(--p), .55); }
.bt-colores { display: flex; gap: calc(var(--t) * .4 - 6px); }
.bt-colores button { padding: 3px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .12s; }
.bt-colores button i { display: block; width: calc(var(--t) * .6); height: calc(var(--t) * .6); border-radius: 50%; }
.bt-colores button:hover { box-shadow: inset 0 0 0 1.5px rgba(var(--p), .2); }
.bt-colores button.elegido { box-shadow: inset 0 0 0 1.5px rgba(var(--p), .6); }

.bt-voces { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(78 * var(--u)), 1fr)); gap: 8px; width: 100%; }
.bt-voces button {
  display: flex; align-items: center; justify-content: center; gap: 5px; padding: calc(6 * var(--u)) 6px; border-radius: 9px;
  background: rgba(var(--p), .07); font-size: var(--f125); white-space: nowrap; transition: background .12s;
}
.bt-voces button:hover { background: rgba(var(--p), .12); }
.bt-voces button.elegida { background: var(--primario); color: #fff; font-weight: 600; }
.bt-voces-marco { max-width: calc(460 * var(--u)); }

/* MARK: Crear un bot de chat */

.bt-crear { width: calc(300 * var(--u)); max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: calc(22 * var(--u)); }
.bt-nombre-nuevo { height: calc(40 * var(--u)); border-radius: 10px; padding: 0 14px; font-size: calc(15 * var(--u)); text-align: center; }
.bt-crear-voz { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bt-crear-voz > span, .bt-crear-fila > span { font-size: var(--f12); color: var(--texto2); }
.bt-crear-fila { display: flex; align-items: center; gap: 8px; margin: calc(-8 * var(--u)) 0; }
.bt-crear-boton { width: 100%; height: calc(36 * var(--u)); border-radius: 10px; font-size: var(--f135); font-weight: 600; }
.bt-crear-boton:disabled { opacity: .4; }
.bt-crear-ayuda { font-size: var(--f12); color: var(--texto3); text-align: center; line-height: 1.45; }

/* MARK: Configurar un bot de chat */

.bt-cabeza { display: flex; align-items: center; gap: 16px; }
.bt-nombre { flex: 1; min-width: 0; height: calc(34 * var(--u)); border: 0; background: none; font-size: calc(22 * var(--u)); letter-spacing: -.3px; }
.bt-nombre::placeholder { color: var(--texto3); }
.bt-rutina { display: flex; align-items: flex-start; gap: 6px; padding: 10px 12px; }
.bt-rutina + .bt-rutina { border-top: 1px solid color-mix(in srgb, var(--borde) 70%, transparent); }
.bt-rutina .estira { display: flex; flex-direction: column; gap: 3px; margin-right: 6px; }
.bt-rutina b { font-size: var(--f13); font-weight: 500; }
.bt-rutina b.apagada { color: var(--texto2); }
.bt-rutina .estira span { font-size: var(--f12); color: var(--texto2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bt-rutina .interruptor { margin: 5px 0 0 4px; }

/* MARK: El bot que corre solo */

.bt-intro h1 { font-size: calc(22 * var(--u)); font-weight: 400; letter-spacing: -.3px; }
.bt-intro p { margin-top: 8px; font-size: var(--f125); color: var(--texto2); line-height: 1.5; }
.bt-intro .bt-estado { color: var(--texto3); font-size: var(--f12); }
.bt-plantillas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bt-plantillas button { display: flex; align-items: center; gap: 9px; height: calc(34 * var(--u)); padding: 0 12px; border-radius: 9px; background: rgba(var(--p), .06); font-size: var(--f125); font-weight: 500; min-width: 0; }
.bt-plantillas button:hover { background: rgba(var(--p), .1); }
.bt-plantillas .ico { color: var(--texto2); }
.bt-instrucciones { min-height: calc(150 * var(--u)); padding: 10px 12px; line-height: 1.5; }
.bt-campo .bt-instrucciones + .bt-nota { margin-top: 0; }

.bt-disparos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.bt-disparos button { display: flex; flex-direction: column; align-items: flex-start; padding: 14px; border-radius: 10px; background: var(--tarjeta); box-shadow: inset 0 0 0 1px var(--borde); text-align: left; }
.bt-disparos button:hover { background: rgba(var(--p), .07); }
.bt-disparos button .ico { color: var(--texto2); height: calc(20 * var(--u)); }
.bt-disparos button b { margin-top: calc(10 * var(--u)); font-size: var(--f13); font-weight: 600; }
.bt-disparos button span { margin-top: calc(4 * var(--u)); font-size: var(--f115); color: var(--texto2); line-height: 1.4; }
.bt-disparos button.elegido { background: color-mix(in srgb, var(--primario) 12%, transparent); box-shadow: inset 0 0 0 1.5px var(--primario); }
.bt-disparos button.elegido .ico { color: var(--primario); }
.bt-subpanel { padding: 14px; border-radius: 10px; background: rgba(var(--p), .035); display: flex; flex-direction: column; gap: 10px; }
.bt-linea { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.bt-dicho { font-size: var(--f125); color: var(--texto2); }
.bt-cada { display: inline-flex; align-items: center; gap: 8px; }
.bt-numero { width: calc(66 * var(--u)); text-align: right; font-variant-numeric: tabular-nums; }
.bt-hora { width: auto; font-variant-numeric: tabular-nums; }
.bt-comando { font-size: var(--f125); padding: 8px; resize: vertical; min-height: calc(34 * var(--u)); }
.bt-pasos { display: inline-flex; align-items: center; gap: 2px; font-size: var(--f12); }
.bt-pasos b { font-weight: 500; margin-right: 6px; }
.bt-pasos button { width: calc(22 * var(--u)); height: calc(22 * var(--u)); display: grid; place-items: center; border-radius: 6px; background: rgba(var(--p), .09); color: var(--texto2); }
.bt-pasos button:hover:not(:disabled) { background: rgba(var(--p), .16); color: var(--texto); }
.bt-pasos button:disabled { opacity: .4; }
.bt-su-vigia { display: flex; align-items: center; gap: 6px; font-size: var(--f115); color: var(--texto2); min-width: 0; }
.bt-su-vigia code { font-family: var(--mono); color: var(--texto); }
.bt-su-vigia small { font-size: inherit; color: var(--texto3); white-space: nowrap; }
.bt-url code { flex: 0 1 auto; display: block; height: calc(28 * var(--u)); line-height: calc(28 * var(--u)); padding: 0 8px; border-radius: 8px; border: 1px solid var(--borde); background: var(--tarjeta); font: var(--f12) var(--mono); }
.bt-url code.corta { line-height: calc(26 * var(--u)); }
.bt-puerto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--f115); color: var(--texto2); min-height: 16px; }
.bt-puerto > span { display: inline-flex; align-items: center; gap: 5px; }
.bt-puerto .verde { color: var(--verde); }
.bt-puerto .ambar { color: var(--ambar); }
.bt-puerto .boton { height: calc(22 * var(--u)); font-size: var(--f115); padding: 0 9px; }
.segmentos.bt-ancho { display: flex; }
.segmentos.bt-ancho button { flex: 1; justify-content: center; }

/* MARK: Lo que recuerda */

.bt-memoria { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.bt-memoria header { display: flex; align-items: center; gap: 4px; }
.bt-memoria h2 { font-size: calc(15 * var(--u)); font-weight: 600; }
.bt-memoria pre { margin: 0; padding: 12px; border-radius: 9px; border: 1px solid var(--borde); background: var(--tarjeta); font: var(--f125)/1.55 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 52dvh; overflow: auto; }
.bt-cargando { display: grid; place-items: center; height: 60px; color: var(--texto2); }
.bt-memoria-botones { display: flex; justify-content: flex-end; }

/* MARK: Grupos */

.bt-grupo { padding: 22px; display: flex; flex-direction: column; gap: calc(14 * var(--u)); }
.bt-grupo h2 { font-size: calc(16 * var(--u)); font-weight: 600; }
.bt-grupo .bt-detalle { margin: 0; }
.bt-grupo > .campo { height: calc(32 * var(--u)); font-size: var(--f135); }
.bt-grupo-lista { max-height: calc(360 * var(--u)); overflow-y: auto; display: flex; flex-direction: column; gap: calc(10 * var(--u)); margin: 0 -8px; }
.bt-grupo-lista > .bt-nada { padding: 0 8px; }
.bt-grupo-maquina { display: flex; align-items: baseline; gap: 6px; padding: 2px 8px; }
.bt-grupo-maquina b { font-size: var(--f11); font-weight: 600; color: var(--texto2); }
.bt-grupo-maquina span { font-size: var(--f105); color: var(--texto3); }
.bt-grupo-bot { display: flex; align-items: center; gap: 10px; width: 100%; height: calc(32 * var(--u)); padding: 0 8px; border-radius: 8px; font-size: var(--f13); }
.bt-grupo-bot:hover { background: rgba(var(--p), .05); }
.bt-grupo-bot .bt-marca { color: var(--texto3); }
.bt-grupo-bot.elegido .bt-marca { color: var(--azul); }
.bt-grupo-botones { display: flex; gap: 8px; margin-top: 2px; }

/* MARK: Celular (como el iPhone: una columna y botones grandes) */

@media (max-width: 760px) {
  .bt-columna { padding: 20px 16px 28px; }
  .bt-rollo.centrado .bt-columna { padding: 20px 16px; width: 100%; }
  .bt-crear { width: 100%; max-width: 380px; margin: 0 auto; }
  .bt-pie-fila { padding: 10px 16px max(10px, env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .bt-pie-fila .estira { display: none; }
  .bt-pie-fila .boton { flex: 1; }
  .bt-error { flex: 0 0 100%; max-width: none; font-size: 14px; }
  .boton.bt-grande { height: 44px; font-size: 16px; border-radius: 11px; }
  .bt-seccion { margin-top: 22px; padding-top: 22px; }
  .bt-fila { flex-direction: column; align-items: stretch; gap: 16px; }
  .bt-lista, .bt-alto, .bt-fijo.bt-alto { height: 44px; }
  .bt-fila .bt-lista { width: 100%; }
  .bt-fijo { font-size: 16px; }
  .bt-nombre-nuevo, .bt-crear-boton { height: 48px; font-size: 17px; }
  .bt-crear-fila { width: 100%; justify-content: space-between; margin: -6px 0; }
  .bt-crear-fila > span, .bt-crear-voz > span { font-size: 14px; }
  .bt-voces { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .bt-voces button { min-height: 40px; font-size: 15px; }
  .bt-formas { gap: 4px; }
  .bt-formas button { padding: 5px; }
  .bt-colores { gap: 6px; }
  .bt-colores button { padding: 7px; }
  .bt-selector-cara { align-items: center; align-self: center; }
  .bt-nombre { font-size: 22px; height: 44px; }
  .bt-instrucciones { min-height: 170px; }
  .bt-plantillas { grid-template-columns: 1fr; }
  .bt-plantillas button { height: 44px; font-size: 16px; }
  .bt-numero { width: 84px; }
  .bt-comando { min-height: 68px; font-size: 14px; }
  .bt-pasos button { width: 40px; height: 40px; }
  .bt-pasos { font-size: 15px; }
  .bt-rutina { flex-wrap: wrap; }
  .bt-rutina .estira { flex: 1 1 100%; margin: 0 0 4px; }
  .bt-rutina .interruptor { margin: 8px 0 0 auto; }
  .bt-url code { height: 40px; line-height: 38px !important; min-width: 0; flex: 1; }
  .bt-puerto .boton { height: 36px; font-size: 14px; }
  .bt-final { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }
  .bt-final .boton { height: 48px; font-size: 16px; border-radius: 12px; }
  .bt-grupo { padding: 20px 18px 6px; }
  .bt-grupo > .campo { height: 44px; font-size: 16px; }
  .bt-grupo-lista { max-height: 46dvh; }
  .bt-grupo-bot { height: 48px; font-size: 16px; gap: 12px; }
  .bt-grupo-botones .boton { flex: 1; }
  .bt-grupo-botones .estira { display: none; }
  .bt-memoria { padding: 18px 18px 6px; }
  .bt-memoria-botones .boton { flex: 1; height: 44px; font-size: 16px; }
}
