/* Modular v15 — mobile teclado + scroll táctil + chat visitante */
@media (min-width: 701px){
  body:not(.tomauno-admin-active) .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)){
    width:min(330px, calc(100vw - 28px))!important;
    max-width:min(330px, calc(100vw - 28px))!important;
    right:22px!important;
    bottom:86px!important;
  }
  body:not(.tomauno-admin-active) .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)) .chat-msgs{
    min-height:360px!important;
  }
}

@media (max-width:700px){
  html, body{
    overscroll-behavior-y:auto!important;
    touch-action:pan-y!important;
  }
  body.chat-open-mobile{
    overflow:auto!important;
    position:static!important;
  }
  .chat-popover.open,
  .chat-popover.open.expanded{
    position:fixed!important;
    left:8px!important;
    right:8px!important;
    width:auto!important;
    max-width:none!important;
    top:auto!important;
    bottom:calc(12px + env(safe-area-inset-bottom))!important;
    height:min(78dvh, 680px)!important;
    max-height:min(78dvh, 680px)!important;
    transform:none!important;
    overflow:hidden!important;
    touch-action:auto!important;
  }
  .chat-popover.open:focus-within,
  .chat-popover.open.keyboard-open{
    bottom:calc(8px + env(safe-area-inset-bottom))!important;
    height:min(58dvh, 520px)!important;
    max-height:min(58dvh, 520px)!important;
  }
  .chat-popover-inner,
  .chat-panel{
    min-height:0!important;
    overflow:hidden!important;
    touch-action:auto!important;
  }
  .chat-msgs{
    min-height:0!important;
    overflow-y:auto!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior:contain!important;
    touch-action:pan-y!important;
    padding-bottom:12px!important;
  }
  .chat-row{
    flex-shrink:0!important;
    margin-top:8px!important;
  }
  .chat-row input,
  .chat-row textarea,
  .chat-row .finput{
    font-size:16px!important;
  }
}


/* Modular v16 — teclado móvil, alertas solo admin y layout visitante */
body.tomauno-visitor-active #toast,
body.tomauno-visitor-active .admin-toast,
body.tomauno-visitor-active .admin-alert,
body.tomauno-visitor-active .human-alert,
body.tomauno-visitor-active [class*="human-alert"],
body.tomauno-visitor-active [id*="human-alert"]{
  display:none!important;
  visibility:hidden!important;
  pointer-events:none!important;
}
@media (min-width:701px){
  body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)){
    width:min(330px, calc(100vw - 30px))!important;
    max-width:min(330px, calc(100vw - 30px))!important;
    height:min(58vh, 520px)!important;
    max-height:min(58vh, 520px)!important;
    right:22px!important;
    bottom:84px!important;
  }
  body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)) .chat-popover-inner,
  body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)) .chat-panel{
    height:100%!important;
    min-height:0!important;
  }
  body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)) .chat-msgs{
    flex:1 1 auto!important;
    min-height:0!important;
    max-height:none!important;
    height:auto!important;
  }
}
@media (max-width:700px){
  html,body{touch-action:auto!important;overscroll-behavior-y:auto!important;}
  body.chat-open-mobile{overflow:auto!important;position:static!important;touch-action:auto!important;}
  .chat-popover.open,
  .chat-popover.open.expanded{
    position:fixed!important;
    left:8px!important;
    right:8px!important;
    width:auto!important;
    top:auto!important;
    bottom:calc(var(--tomauno-keyboard, 0px) + 10px + env(safe-area-inset-bottom))!important;
    height:calc(100dvh - var(--tomauno-keyboard, 0px) - 26px)!important;
    max-height:calc(100dvh - var(--tomauno-keyboard, 0px) - 26px)!important;
    min-height:320px!important;
    transform:none!important;
    touch-action:auto!important;
  }
  .chat-popover.open:focus-within,
  .chat-popover.open.keyboard-open{
    bottom:calc(var(--tomauno-keyboard, 0px) + 10px + env(safe-area-inset-bottom))!important;
    height:calc(100dvh - var(--tomauno-keyboard, 0px) - 26px)!important;
    max-height:calc(100dvh - var(--tomauno-keyboard, 0px) - 26px)!important;
  }
  .chat-popover-inner,.chat-panel{height:100%!important;min-height:0!important;overflow:hidden!important;touch-action:auto!important;}
  .chat-msgs{flex:1 1 auto!important;min-height:0!important;max-height:none!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch!important;touch-action:pan-y!important;}
  .chat-row{flex:0 0 auto!important;}
}

/* Modular v18 — visitante compacto real + teclado sin perder foco */
body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)){
  width:min(330px, calc(100vw - 18px))!important;
  max-width:min(330px, calc(100vw - 18px))!important;
  height:min(58vh, 520px)!important;
  max-height:min(58vh, 520px)!important;
  right:18px!important;
  bottom:78px!important;
}
body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)) .chat-popover-inner,
body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)) .chat-panel{
  height:100%!important;min-height:0!important;display:flex!important;flex-direction:column!important;overflow:hidden!important;
}
body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)) .chat-msgs{
  flex:1 1 auto!important;min-height:0!important;max-height:none!important;height:auto!important;padding-bottom:10px!important;
}
body.tomauno-visitor-active .chat-popover.open:not(.expanded):not(:has(.chat-inbox-side)) .chat-row{
  flex:0 0 auto!important;margin-top:8px!important;
}
body.tomauno-visitor-active .chat-popover.open.expanded:not(:has(.chat-inbox-side)),
body:not(.tomauno-admin-active) .chat-popover.open.expanded:not(:has(.chat-inbox-side)),
body.tomauno-visitor-active .chat-popover.open:not(:has(.chat-inbox-side)),
body:not(.tomauno-admin-active) .chat-popover.open:not(:has(.chat-inbox-side)){
  left:auto!important;
  top:auto!important;
  transform:none!important;
  width:min(330px, calc(100vw - 22px))!important;
  max-width:min(330px, calc(100vw - 22px))!important;
  min-width:0!important;
  right:16px!important;
  bottom:84px!important;
  height:min(58vh, 520px)!important;
  max-height:min(58vh, 520px)!important;
  min-height:0!important;
  resize:none!important;
}
body.tomauno-visitor-active #toast,
body.tomauno-visitor-active [class*="human-alert"],
body.tomauno-visitor-active [class*="admin-alert"],
body.tomauno-visitor-active [id*="human-alert"],
body.tomauno-visitor-active [id*="admin-alert"]{
  display:none!important;visibility:hidden!important;pointer-events:none!important;
}
@media(max-width:700px){
  html,body{touch-action:auto!important;overscroll-behavior-y:auto!important;}
  body.chat-open-mobile{overflow:auto!important;position:static!important;}
  body.tomauno-visitor-active .chat-popover.open,
  body.tomauno-visitor-active .chat-popover.open.expanded{
    left:8px!important;right:8px!important;width:auto!important;top:auto!important;
    bottom:calc(var(--tomauno-keyboard, 0px) + 8px + env(safe-area-inset-bottom))!important;
    height:calc(100dvh - var(--tomauno-keyboard, 0px) - 18px)!important;
    max-height:calc(100dvh - var(--tomauno-keyboard, 0px) - 18px)!important;
    min-height:260px!important;transform:none!important;
  }
  body.tomauno-visitor-active .chat-row input,
  body.tomauno-visitor-active .chat-row textarea,
  body.tomauno-visitor-active .chat-row .finput{font-size:16px!important;}
}
